bayesvl stan utilities {bayesvl} | R Documentation |
Build RStan models from directed acyclic graph
Description
Build Stan models from directed acyclic graph of an object of class bayesvl
.
Usage
# build Stan models from directed acyclic graph.
bvl_model2Stan(dag, ppc = "")
# compile and simulate samples from the model.
bvl_modelFit(dag, data, warmup = 1000, iter = 5000, chains = 2, ppc = "", ...)
# summarize the stan priors used for the model.
bvl_stanPriors(dag)
# summarize the stan parameters used for the model.
bvl_stanParams(dag)
# summarize the generated formula at the node.
bvl_formula(dag, nodeName, outcome = T, re = F)
Arguments
dag |
an object of class |
data |
a data frame or list containing the data |
warmup |
Optional: Number of warmup iterations. By default, half of iter |
iter |
Optional: Number of iterations of sampling. Default is 5000 |
chains |
Optional: Number of independent chains to sample from. Default is 2 |
ppc |
Optional: a character string contains posterior predictive check scripts |
... |
extra arguments from the generic method |
nodeName |
A character string contains the node name |
outcome |
Optional: Whether show out distribution |
re |
Optional: Whether run recursive for all up-level nodes |
Value
bvl_model2Stan()
return character string of rstan code generated from the model.
bvl_modelFit()
return an object class bayesvl
which contains result with the following slots.
model |
Stan model code |
stanfit |
|
standata |
The data |
pars |
Parameter names monitored in samples |
formula |
Generated formula from the model |
bvl_stanPriors()
return character string of rstan priors generated from the model.
bvl_stanParams()
return character string of rstan parameters generated from the model.
Author(s)
La Viet-Phuong, Vuong Quan-Hoang
References
For documentation, case studies and worked examples, and other tutorial information visit the References section on our Github:
Examples
# Design the model in 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 the Stan model's code
model_string <- bvl_model2Stan(model)
cat(model_string)
# Show priors in generated Stan model
bvl_stanPriors(model)