writeJagsFormula: Write the JAGS Formula for a Hyde Node

Description Usage Arguments Details Author(s) See Also Examples

View source: R/writeJagsFormula.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
writeJagsFormula(fit, nodes, ...)

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

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

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

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

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

## S3 method for class '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)

Author(s)

Jarrod Dalton and Benjamin Nutter

See Also

writeJagsModel, writeNetworkModel

Examples

1
2
3
4
5
6
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"))

HydeNet documentation built on July 8, 2020, 5:15 p.m.