The mice function is one of the most used functions to
apply multiple imputation. This page shows how functions in the
psfmi package can be easily used in combination with
mice. In this way multivariable models can easily be
developed in combination with mice.
You can install the released version of psfmi with:
And the development version from GitHub with:
You can install the released version of mice with:
library(psfmi)
library(mice)
#>
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following objects are masked from 'package:base':
#>
#> cbind, rbind
imp <- mice(lbp_orig, m=5, maxit=5)
#>
#> iter imp variable
#> 1 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
data_comp <- complete(imp, action = "long", include = FALSE)
library(psfmi)
pool_lr <- psfmi_lr(data=data_comp, nimp=5, impvar=".imp",
formula=Chronic ~ Gender + Smoking + Function +
JobControl + JobDemands + SocialSupport, method="D1")
pool_lr$RR_model
#> $`Step 1 - no variables removed -`
#> term estimate std.error statistic df p.value
#> 1 (Intercept) 0.360843017 2.63350260 0.13702019 58.18996 0.891487829
#> 2 Gender -0.369984852 0.41536562 -0.89074501 143.13565 0.374560777
#> 3 Smoking 0.079487860 0.33851522 0.23481326 149.34554 0.814675315
#> 4 Function -0.136222381 0.04333466 -3.14349720 139.51290 0.002039817
#> 5 JobControl 0.004760001 0.02173199 0.21903195 55.50945 0.827428533
#> 6 JobDemands -0.003265227 0.03827702 -0.08530514 95.84354 0.932196747
#> 7 SocialSupport 0.038696408 0.05724475 0.67598175 133.61770 0.500220563
#> OR lower.EXP upper.EXP
#> 1 1.4345382 0.007370138 279.2213527
#> 2 0.6907448 0.303908626 1.5699731
#> 3 1.0827324 0.554654435 2.1135853
#> 4 0.8726486 0.800995509 0.9507113
#> 5 1.0047713 0.961959524 1.0494885
#> 6 0.9967401 0.923812549 1.0754247
#> 7 1.0394549 0.928182701 1.1640665Back to Examples
library(psfmi)
library(mice)
imp <- mice(lbp_orig, m=5, maxit=5)
#>
#> iter imp variable
#> 1 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 1 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 2 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 3 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 4 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 1 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 2 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 3 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 4 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
#> 5 5 Carrying Pain Tampascale Function Radiation Age Satisfaction JobControl JobDemands SocialSupport
data_comp <- complete(imp, action = "long", include = FALSE)
library(psfmi)
pool_lr <- psfmi_lr(data=data_comp, nimp=5, impvar=".imp",
formula=Chronic ~ Gender + Smoking + Function +
JobControl + JobDemands + SocialSupport,
p.crit = 0.157, method="D1", direction = "FW")
#> Entered at Step 1 is - Function
#>
#> Selection correctly terminated,
#> No new variables entered the model
pool_lr$RR_model_final
#> $`Final model`
#> term estimate std.error statistic df p.value OR
#> 1 (Intercept) 1.2791315 0.46176592 2.770086 154.6972 0.0062907643 3.5935174
#> 2 Function -0.1451103 0.04123427 -3.519168 154.1061 0.0005693155 0.8649269
#> lower.EXP upper.EXP
#> 1 1.4433272 8.9469438
#> 2 0.7972654 0.9383306Back to Examples