Working together: mice and psfmi"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

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.

Installing the psfmi and mice packages

You can install the released version of psfmi with:

install.packages("psfmi")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("mwheymans/psfmi")

You can install the released version of mice with:

install.packages("mice")

Examples

mice and psfmi for pooling logistic regression models

  library(psfmi)
  library(mice)

  imp <- mice(lbp_orig, m=5, maxit=5) 

  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

Back to [Examples]

mice and psfmi for selecting logistic regression models

  library(psfmi)
  library(mice)

  imp <- mice(lbp_orig, m=5, maxit=5) 

  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")

  pool_lr$RR_model_final

Back to [Examples]



Try the psfmi package in your browser

Any scripts or data that you put into this service are public.

psfmi documentation built on July 9, 2023, 7:02 p.m.