Skip to contents

Helper function that takes in the formulas for the model of interest and the imputation model, and groups them into responses, covariates, covariate with error and covariate(s) without error, for both sub-models.

Usage

extract_variables_from_formula(
  formula_moi,
  formula_imp,
  formula_mis = NULL,
  error_variable = 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.

error_variable

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

Value

A list containing the names of the different variables of the model. The names of the elements in the list are "response_moi" (the response for the moi), "covariates_moi" (all covariates in the moi), "error_variable" (the name of the variable with error or missing data), "covariates_error_free" (the moi covariates without error), "response_imp" (imputation model response), "covariates_imp" (imputation model covariates).

Examples

extract_variables_from_formula(formula_moi = y ~ x + z,
                               formula_imp = x ~ z)
#> $response_moi
#> [1] "y"
#> 
#> $covariates_moi
#> [1] "x" "z"
#> 
#> $random_effects_moi
#> [1] ""
#> 
#> $random_effect_variables_moi
#> [1] ""
#> 
#> $error_variable
#> [1] "x"
#> 
#> $error_interaction_list
#> [1] ""
#> 
#> $error_interaction_variables
#> [1] ""
#> 
#> $covariates_error_free
#> [1] "z"
#> 
#> $response_imp
#> $response_imp[[1]]
#> [1] "x"
#> 
#> 
#> $covariates_imp
#> $covariates_imp[[1]]
#> [1] "z"
#> 
#> 
#> $random_effects_imp
#> $random_effects_imp[[1]]
#> [1] ""
#> 
#> 
#> $random_effect_variables_imp
#> $random_effect_variables_imp[[1]]
#> [1] ""
#> 
#> 
#> $covariates_mis
#> $covariates_mis[[1]]
#> [1] ""
#> 
#> 
#> $covariates_error_free_mis_list
#> $covariates_error_free_mis_list[[1]]
#> [1] ""
#> 
#> 
#> $random_effects_mis
#> $random_effects_mis[[1]]
#> [1] ""
#> 
#> 
#> $random_effect_variables_mis
#> $random_effect_variables_mis[[1]]
#> [1] ""
#> 
#>