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 class 'cpt'
writeJagsFormula(fit, nodes, ...)
## S3 method for class 'glm'
writeJagsFormula(fit, nodes, ...)
## S3 method for class 'lm'
writeJagsFormula(fit, nodes, ...)
## S3 method for class 'multinom'
writeJagsFormula(fit, nodes, ...)
## 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
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:
family = binomial; link = logit
family = poisson; link = log
family = gaussian; link = identity (calls writeJagsFormula.lm)
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(HydeNet)
Loading required package: nnet
Loading required package: rjags
Loading required package: coda
Linked to JAGS 4.1.0
Loaded modules: basemod,bugs
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HydeNet/writeJagsFormula.Rd_%03d_medium.png", width=480, height=480)
> ### Name: writeJagsFormula
> ### Title: Write the JAGS Formula for a Hyde Node
> ### Aliases: writeJagsFormula writeJagsFormula.cpt writeJagsFormula.glm
> ### writeJagsFormula.lm writeJagsFormula.multinom writeJagsFormula.xtabs
>
> ### ** Examples
>
> data(PE, package="HydeNet")
> fit <- lm(d.dimer ~ pregnant + pe, data=PE)
> writeJagsFormula(fit, nodes=c("d.dimer", "pregnant", "pe"))
[1] "d.dimer ~ 210.24251 + 68.37938*pe + 29.29496*pregnant"
>
> fit.glm <- glm(death ~ pe + treat, data=PE, family="binomial")
> writeJagsFormula(fit.glm, nodes=c("death", "pe", "treat"))
[1] "death ~ ilogit(-4.18763 + 5.48082*pe + -1.93576*treat)"
Warning message:
attributes are not identical across measure variables; they will be dropped
>
>
>
>
>
> dev.off()
null device
1
>