knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(miceafter) library(mice) library(magrittr) library(dplyr)
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("mwheymans/miceafter")
You can install mice with:
install.packages("mice")
lbp_orig is a dataset that is part of the miceafter package with missing values. So we first impute them with the mice
function. Than we use the mids2milist
function to turn a mids
object, as a result of using mice
, into a milist
object with multiply imputed datasets. Than we use the with
function to apply repeated logistic regression analyses. With the pool_glm
function we obtain the results for the pooled model.
library(mice) library(miceafter) imp <- mice(lbp_orig, m=5, maxit=5, printFlag = FALSE) dat_imp <- mids2milist(imp) ra <- with(dat_imp, expr = glm(Chronic ~ factor(Carrying) + Gender + Smoking + Function + JobControl + JobDemands + SocialSupport, family = binomial)) poolm <- pool_glm(ra, method="D1") poolm$pmodel poolm$pmultiparm
Back to [Examples]
The lbp_orig is a dataset that is part of the miceafter package with missing values. So we first impute them with the mice
function. Than we use the mids2milist
function to turn a mids
object, as a result of using mice
, into a milist
object with multiply imputed datasets. Than we use the with
function to apply repeated linear regression analyses. With the pool_glm
function we obtain the results for the pooled model.
library(mice) library(miceafter) imp <- mice(lbp_orig, m=5, maxit=5, printFlag = FALSE) dat_imp <- mids2milist(imp) ra <- with(dat_imp, expr = glm(Pain ~ factor(Carrying) + Gender + Smoking + Function + JobControl + JobDemands + SocialSupport)) poolm <- pool_glm(ra, method="D1") poolm$pmodel poolm$pmultiparm
Back to [Examples]
We follow the same procedure as the first example but also apply model selection here.
library(mice) library(miceafter) imp <- mice(lbp_orig, m=5, maxit=5, printFlag = FALSE) dat_imp <- mids2milist(imp) ra <- with(dat_imp, expr = glm(Chronic ~ factor(Carrying) + Gender + Smoking + Function + JobControl + JobDemands + SocialSupport, family = binomial)) poolm <- pool_glm(ra, method="D1", p.crit = 0.15, direction = "BW") poolm$pmodel poolm$pmultiparm
Back to [Examples]
We follow the same procedure as the second example but also apply model selection here.
library(mice) library(miceafter) imp <- mice(lbp_orig, m=5, maxit=5, printFlag = FALSE) dat_imp <- mids2milist(imp) ra <- with(dat_imp, expr = glm(Pain ~ factor(Carrying) + Gender + Smoking + Function + JobControl + JobDemands + SocialSupport)) poolm <- pool_glm(ra, method="D1", p.crit = 0.15, direction = "BW") poolm$pmodel poolm$pmultiparm
Back to [Examples]
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.