HydeSim: Simulated Distributions of a Decision Network

Description Usage Arguments Details Value Author(s) Examples

View source: R/HydePosterior.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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.

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.

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).

Author(s)

Jarrod Dalton and Benjamin Nutter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)

nutterb/HydeNet documentation built on July 13, 2020, 5:21 p.m.