Learn R Programming

HydeNet (version 0.10.11)

HydeSim: Simulated Distributions of a Decision Network

Description

The simulated distributions of the decision network can be evaluated to determine the probabilistic outcomes based on the decision inputs in the model as well as subject specific factors.

Usage

HydeSim(
  cHN,
  variable.names,
  n.iter,
  thin = 1,
  ...,
  monitor_observed = TRUE,
  bind = TRUE
)

HydePosterior(...)

Arguments

cHN

A compiledHydeNetwork object as returned by compileJagsNetwork.

variable.names

a character vector giving the names of variables to be monitored.

n.iter

number of iterations to monitor.

thin

thinning interval for monitors.

...

options arguments that are passed to the update method for jags model objects.

monitor_observed

If TRUE, the observed or fixed variables (those passed to the data argument in compileJagsNetwork) are forced into variable.names if not already provided. This is recommended, especially if you will be binding multiple JAGS runs together.

bind

Logical. If TRUE, simulated distributions will be bound into a single data frame. If FALSE, the standard output from rjags is returned.

Value

A list of class HydeSim with elements codas (the MCMC matrices from coda.samples), observed (the values of the variables that were observed), dag (the dag object for convenience in displaying the network), and factorRef (giving the mappings of factor levels to factor variables).

Details

This is essentially a wrapper around coda.samples that returns in a list the output for each run of coda.samples over the rows of the policy/decision matrix given in the data argument of compileJagsNetwork.

Examples

Run this code
# NOT RUN {
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 Distributions for a Decision Model
Net <- setDecisionNodes(Net, angio, treat)
decisionNet <- compileDecisionModel(Net, n.chains=5)
decisionsPost <- HydeSim(decisionNet, 
                               variable.names = c("d.dimer", "death"),
                               n.iter = 1000)


# }

Run the code above in your browser using DataLab