Based on APC-format, generate the proper formula to pass to INLA for fitting MAPC models.
generate_MAPC_formula(
df,
APC_format,
response,
stratify_var,
age = "age",
period = "period",
cohort = "cohort",
intercept = FALSE,
apc_prior = "rw1",
apc_hyper = NULL,
random_term = TRUE,
extra.fixed = NULL,
extra.random = NULL,
extra.models = NULL,
extra.hyper = NULL
)
A formula object that can be passed to INLA to fit the desired MAPC model.
Data frame for which MAPC models should be fit
A string where lower-case letters indicate stratum-specific time effects and upper-case letters indicate shared time effects.
A string, name of the column in df
that represents the response variable.
Stratification variable. At least one time effect should be stratum-specific, and at least one should be shared.
Name of age column
Name of period column
Name of cohort column
Boolean, indicating if an overall intercept should be included in the formula.
Defaults to TRUE (optional).
Which prior model to use for the time effects.
Defaults to "rw1" (optional).
If the user wants non-default hyperpriors for the random time effects, this can be achieved by passing the entire
prior specification as a string. If e.g. hyper = list(theta = list(prior="pc.prec", param=c(0.5,0.01)))
is desired, pass the string "list(theta = list(prior="pc.prec", param=c(0.5,0.01)))
" to this argument.
Indicator, indicating if a random term should be included in the model.
Defaults to TRUE (optional).
Name of additional fixed effects.
Defaults to NULL (optional).
Name of additional random effects.
Defaults to NULL (optional).
Models for additional random effects. Supported INLA
models include 'iid'
, 'rw1'
and 'rw2'
.
Defaults to NULL (optional).
If the user wants non-default hyperpriors for the additional random effects, this can be achieved by passing the entire
prior specification as a string. If e.g. hyper = list(theta = list(prior="pc.prec", param=c(0.5,0.01)))
is desired, pass the string "list(theta = list(prior="pc.prec", param=c(0.5,0.01)))
" to this argument.