Learn R Programming

HydeNet (version 0.10.11)

writeJagsFormula: Write the JAGS Formula for a Hyde Node

Description

Based on the information provided about the node, an appropriate JAGS model is written in text. This is combined with the other node models to generate the complete network.

Usage

writeJagsFormula(fit, nodes, ...)

# S3 method for cpt writeJagsFormula(fit, nodes, ...)

# S3 method for glm writeJagsFormula(fit, nodes, bern = bern, ...)

# S3 method for lm writeJagsFormula(fit, nodes, bern, ...)

# S3 method for multinom writeJagsFormula(fit, nodes, bern = bern, ...)

# S3 method for survreg writeJagsFormula(fit, ..., bern = bern)

# S3 method for xtabs writeJagsFormula(fit, ...)

Arguments

fit

a model object

nodes

a vector of node names, usually passed from network$nodes

...

Additional arguments to be passed to other methods

bern

a vector of bernoulli node names

Details

Methods for different model objects can be written so that this function can be extended as desired.

The resulting formulas are based on the coefficient matrix of the fitted model, and the returned result is the JAGS code representing the regression equation of the model.

In the writeJagsFormula.glm method, appropriate transformations exist for the following combinations:

  1. family = binomial; link = logit

  2. family = poisson; link = log

  3. family = gaussian; link = identity (calls writeJagsFormula.lm)

See Also

writeJagsModel, writeNetworkModel

Examples

Run this code
# NOT RUN {
data(PE, package="HydeNet")
fit <- lm(d.dimer ~ pregnant + pe, data=PE)
writeJagsFormula(fit, nodes=c("d.dimer", "pregnant", "pe"))

fit.glm <- glm(death ~ pe + treat, data=PE, family="binomial")
writeJagsFormula(fit.glm, nodes=c("death", "pe", "treat"))
# }

Run the code above in your browser using DataLab