generate_MAPC_formula: Generate MAPC formula for INLA

View source: R/export-ModelEstimation.R

generate_MAPC_formulaR Documentation

Generate MAPC formula for INLA

Description

Based on APC-format, generate the proper formula to pass to INLA for fitting MAPC models.

Usage

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
)

Arguments

df

Data frame for which MAPC models should be fit

APC_format

A string where lower-case letters indicate stratum-specific time effects and upper-case letters indicate shared time effects.

response

A string, name of the column in df that represents the response variable.

stratify_var

Stratification variable. At least one time effect should be stratum-specific, and at least one should be shared.

age

Name of age column

period

Name of period column

cohort

Name of cohort column

intercept

Boolean, indicating if an overall intercept should be included in the formula.
Defaults to TRUE (optional).

apc_prior

Which prior model to use for the time effects.
Defaults to "rw1" (optional).

apc_hyper

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.

random_term

Indicator, indicating if a random term should be included in the model.
Defaults to TRUE (optional).

extra.fixed

Name of additional fixed effects.
Defaults to NULL (optional).

extra.random

Name of additional random effects.
Defaults to NULL (optional).

extra.models

Models for additional random effects. Supported INLA models include 'iid', 'rw1' and 'rw2'.
Defaults to NULL (optional).

extra.hyper

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.

Value

A formula object that can be passed to INLA to fit the desired MAPC model.


MAPCtools documentation built on June 25, 2025, 5:09 p.m.