JAGS_formula {BayesTools} | R Documentation |
Create JAGS formula syntax and data object
Description
Creates a JAGS formula syntax, prepares data input, and
returns modified prior list for further processing in the JAGS_fit
function
Usage
JAGS_formula(formula, parameter, data, prior_list)
Arguments
formula |
formula specifying the right hand side of the assignment (the left hand side is ignored) |
parameter |
name of the parameter to be created with the formula |
data |
data.frame containing predictors included in the formula |
prior_list |
named list of prior distribution of parameters specified within
the |
Value
JAGS_formula
returns a list containing the formula JAGS syntax,
JAGS data object, and modified prior_list.
See Also
Examples
# simulate data
set.seed(1)
df <- data.frame(
y = rnorm(60),
x_cont = rnorm(60),
x_bin = rbinom(60, 1, .5),
x_fac3 = factor(rep(c("A", "B", "C"), 20), levels = c("A", "B", "C")),
x_fac4 = factor(rep(c("A", "B", "C", "D"), 15), levels = c("A", "B", "C", "D"))
)
# specify priors
prior_list <- list(
"intercept" = prior("normal", list(0, 1)),
"x_cont" = prior("normal", list(0, .5)),
"x_fac3" = prior_factor("normal", list(0, 1), contrast = "treatment"),
"x_fac4" = prior_factor("mnormal", list(0, 1), contrast = "orthonormal"),
"x_fac3:x_fac4" = prior_factor("mnormal", list(0, .5), contrast = "orthonormal")
)
# create the formula object
formula <- JAGS_formula(
formula = ~ x_cont + x_fac3 * x_fac4,
parameter = "mu", data = df, prior_list = prior_list)
[Package BayesTools version 0.2.17 Index]