Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/compileJagsModel.R
Generates the JAGS code from the Hyde network and uses it to create an object representing a Bayesian graphical model.
1 | compileJagsModel(network, data = NULL, ...)
|
network |
An object of class |
data |
A list of data values to be observed in the nodes. It is
passed to the |
... |
Additional arguments to be passed to |
compileJagsModel is a partial wrapper for
jags.model. Running compileJagsModel(network) is
equivalent to running jags.model(textConnection(writeNetworkModel(network))).
Returns a compiledHydeNetwork object. The jags element
of this object is suitable to pass to coda.samples. Otherwise,
the primary function of the object is plotting the network with
observed data shown.
Benjamin Nutter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | data(PE, package="HydeNet")
Net <- HydeNetwork(~ wells +
pe | wells +
d.dimer | pregnant*pe +
angio | pe +
treat | d.dimer*angio +
death | pe*treat,
data = PE)
compiledNet <- compileJagsModel(Net, n.chains=5)
#* Generate the posterior distribution
Posterior <- HydeSim(compiledNet,
variable.names = c("d.dimer", "death"),
n.iter = 1000)
Posterior
#* For a single model (ie, not a decision model), the user may choose to
#* use the \code{rjags} function \code{coda.samples}.
#* However, this does not have a succinct print method
library(rjags)
s <- coda.samples(compiledNet$jags,
variable.names = c("d.dimer", "death"),
n.iter=1000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.