Skip to contents

Make data stacks for joint model specification in INLA

Usage

make_inlamemi_stacks(
  formula_moi,
  formula_imp,
  formula_mis = NULL,
  family_moi = "gaussian",
  data,
  error_type = "classical",
  error_variable = NULL,
  repeated_observations = FALSE,
  vars = NULL
)

Arguments

formula_moi

an object of class "formula", describing the main model to be fitted.

formula_imp

an object of class "formula", describing the imputation model for the mismeasured and/or missing observations.

formula_mis

an object of class "formula", describing the missingness model. Does not need to have a response variable, since this will always be a binary missingness indicator.

family_moi

a string indicating the likelihood family for the model of interest (the main model).

data

an object of class data.frame or list containing the variables in the model.

error_type

type of error (one or more of "classical", "berkson", "missing")

error_variable

character vector with the name(s) of the variable(s) with error.

repeated_observations

Does the variable with measurement error and/or missingness have repeated observations? If so, set this to "TRUE". In that case, when specifying the formula, use the name of the variable without any numbers, but when specifying the data, make sure that the repeated measurements end in a number, i.e "sbp1" and "sbp2".

vars

Results from a call to "extract_variables_from_formula" function. If this is not passed as an argument, it is called inside the function.

Value

An object of class inla.stack with data structured according to specified formulas and error models.

Examples

make_inlamemi_stacks(formula_moi = y ~ x + z,
                   formula_imp = x ~ z,
                   data = simple_data,
                   error_type = "classical")
#> Data stack with
#>   data:    (y_moi, x_classical, x_imp), size: 3000
#>   effects: (beta.0, beta.x, beta.z, id.x, weight.x, alpha.x.0, alpha.x.z), size: 3000
#>   A:       3000 times 3000
#>   response: 1 response objects