mem_mice: estimate marginal effects at the means and modes using data objects created by mice::mice() (.mids)

mem_mice(model, mice_object, ...)

Arguments

model

a model object, either lm() or glm(), created using the original data with missing values

mice_object

an object of class .mids, created using the mice::mice() function, containing imputed data

...

additional arguments (not intended to be used)

Value

a dataframe of the pooled marginal effect estimates (pooled using Rubin's rules)

Examples

## Create dataset with missingness
data_with_missings <- mtcars |>
 missMethods::delete_MCAR(0.3, "cyl") |>
 dplyr::mutate(cyl = as.factor(cyl))

## Create model object
lm_mod <- lm(formula = mpg ~ wt + hp + cyl + cyl*wt + disp,
             data = data_with_missings)

## Impute data
imputation <- mice::mice(data = data_with_missings, m = 5, seed = 01701)
#> 
#>  iter imp variable
#>   1   1  cyl
#>   1   2  cyl
#>   1   3  cyl
#>   1   4  cyl
#>   1   5  cyl
#>   2   1  cyl
#>   2   2  cyl
#>   2   3  cyl
#>   2   4  cyl
#>   2   5  cyl
#>   3   1  cyl
#>   3   2  cyl
#>   3   3  cyl
#>   3   4  cyl
#>   3   5  cyl
#>   4   1  cyl
#>   4   2  cyl
#>   4   3  cyl
#>   4   4  cyl
#>   4   5  cyl
#>   5   1  cyl
#>   5   2  cyl
#>   5   3  cyl
#>   5   4  cyl
#>   5   5  cyl

## Estimate and pool marginal effects at the means and modes
pooled_mfx <- memice::mem_mice(model = lm_mod, mice_object = imputation)
pooled_mfx
#>   term contrast     estimate  std.error  statistic    p.value
#> 1   wt    dY/dX -1.710532125 1.16449737 -1.4689017 0.14185965
#> 2   hp    dY/dX -0.023097687 0.01121388 -2.0597403 0.03942367
#> 3  cyl    6 - 4  2.797522964 2.78338538  1.0050793 0.31532149
#> 4  cyl    8 - 4  2.311613630 3.50189399  0.6601038 0.50938103
#> 5 disp    dY/dX -0.006744283 0.01196956 -0.5634530 0.57312679