bayesvl-stan-utilities {bayesvl}R Documentation

Build Stan Models from Directed Acyclic Graphs

Description

Functions to generate Stan code and run simulations using a model object of class bayesvl, which represents a Bayesian directed acyclic graph (DAG).

Usage

bvl_model2Stan(dag, ppc = "")

bvl_modelFit(dag, data, warmup = 1000, iter = 5000, chains = 2, ppc = "", ...)

bvl_stanPriors(dag)

bvl_stanParams(dag)

bvl_formula (dag, nodeName, outcome = T, re = F)

bvl_stanLikelihood (dag)

bvl_stanLoo (dag, ...)

bvl_stanWAIC (dag, ...)

Arguments

dag

An object of class bayesvl representing the model DAG.

data

A data frame or list containing the observed data for model fitting.

warmup

Number of warmup iterations; defaults to half of iter.

iter

Total number of iterations for sampling. Default is 5000.

chains

Number of MCMC chains to run. Default is 2.

ppc

Optional: a character string containing Stan code for posterior predictive checks.

...

Additional arguments passed to underlying functions.

nodeName

The name of the node to generate formula for.

outcome

Logical. Whether to include outcome distribution. Default is TRUE.

re

Logical. Whether to recursively trace all upstream nodes. Default is FALSE.

Value

The following outputs are returned depending on the function used:

Author(s)

La Viet-Phuong, Vuong Quan-Hoang

References

For documentation, case studies, worked examples, and other tutorial materials, see:

Examples

# Design the model using a directed acyclic graph
model <- bayesvl()
model <- bvl_addNode(model, "Lie", "binom")
model <- bvl_addNode(model, "B", "binom")
model <- bvl_addNode(model, "C", "binom")
model <- bvl_addNode(model, "T", "binom")

model <- bvl_addArc(model, "B", "Lie", "slope")
model <- bvl_addArc(model, "C", "Lie", "slope")
model <- bvl_addArc(model, "T", "Lie", "slope")

# Generate Stan model code
model_string <- bvl_model2Stan(model)
cat(model_string)

# Display priors in generated Stan model
bvl_stanPriors(model)

[Package bayesvl version 1.0.0 Index]