Learn R Programming

miceafter

With the miceafter package you can apply statistical and pooled analyses after multiple imputation. Therefore the name ‘miceafter’. The package contains a variety of statistical tests like the pool_levenetest function to pool Levene’s tests across multiply imputed datasets or the pool_propdiff_nw function to pool the difference between proportions according to method Newcombe-Wilson. The package also contains a function pool_glm to pool and select linear and logistic regression functions. Functions can also be used in combination with the %>% (Pipe) operator.

More and more statistical analyses and pooling functions will be added over time to form a framework of statistical tests that can be applied and pooled across multiply imputed datasets.

Examples

Pooling Levene’s Test

This example shows you how to pool the Levene test across 5 multiply imputed datasets. The pooling method that is used is method D1.

library(miceafter)

# Step 1: Turn data frame with multiply imputed datasets into object of 'milist'
imp_dat <- df2milist(lbpmilr, impvar="Impnr")

# Step 2: Do repeated analyses across multiply imputed datasets
ra <- with(imp_dat, expr=levene_test(Pain ~ factor(Carrying)))

# Step 3: Pool repeated test results
res <- pool_levenetest(ra, method="D1")
res
#>       F_value df1      df2    P(>F)       RIV
#> [1,] 1.586703   2 115.3418 0.209032 0.1809493
#> attr(,"class")
#> [1] "mipool"

Pooling Levene’s Test in one Pipe

library(miceafter)
library(magrittr)

lbpmilr %>%
  df2milist(impvar="Impnr") %>%
     with(expr=levene_test(Pain ~ factor(Carrying))) %>%
                                pool_levenetest(method="D1")
#>       F_value df1      df2    P(>F)       RIV
#> [1,] 1.586703   2 115.3418 0.209032 0.1809493
#> attr(,"class")
#> [1] "mipool"

Pooling Difference between Proportions according to Newcombe-Wilson

library(miceafter)

# Step 1: Turn data frame with multiply imputed datasets into object of 'milist'
imp_dat <- df2milist(lbpmilr, impvar="Impnr")

# Step 2: Do repeated analyses across multiply imputed datasets
ra <- with(imp_dat, 
           expr=propdiff_wald(Chronic ~ Radiation, strata = TRUE))

# Step 3: Pool repeated test results
res <- pool_propdiff_nw(ra)
res
#>      Prop diff CI L NW CI U NW
#> [1,]    0.2786  0.1199   0.419
#> attr(,"class")
#> [1] "mipool"

See for more functions the package website

Main functions

The main functions of the package are the df2milist, list2milist, mids2milist and the with.milist functions. The df2milist function turns a data frame with multiply imputed datasets into an object of class milist, the list2milist does this for a list with multiply imputed datasets and the mids2milist for objects of class mids. These milist object can than be used with the with.milist function to apply repeated statistical analyses across the multiply imputed datasets. Subsequently, pooling functions are available in the form of separate pool functions.

Installation

You can install the development version from GitHub with:

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

Citation

Cite the package as:

Martijn W Heymans (2021). miceafter: Data Analysis and Pooling after Multiple Imputation. 
R package version 0.1.0. https://mwheymans.github.io/miceafter/

Copy Link

Version

Install

install.packages('miceafter')

Monthly Downloads

305

Version

0.5.0

License

GPL (>= 2)

Maintainer

Martijn Heymans

Last Published

October 2nd, 2022

Functions in miceafter (0.5.0)

cindex

Calculates the c-index and standard error
clean_P

Function to clean variables
levene_test

Calculates the Levene's test
glm_lm_fw

Forward selection of Linear regression models across multiply imputed data.
lbp_orig

Dataset of 159 Low Back Pain Patients with missing values
invlogit

Takes the inverse of a logit transformed value
invlogit_ci

Takes the inverse of logit transformed parameters and calculates the confidence intervals
lbpmicox

Survival data of 265 Low Back Pain Patients
glm_lr_bw

Backward selection of Logistic regression models in multiply imputed data.
lbpmilr

Data of 159 Low Back Pain Patients
glm_mi

Direct Pooling and model selection of Linear and Logistic regression models across multiply imputed data.
glm_lr_fw

Forward selection of Logistic regression models in multiply imputed data.
mids2milist

Turns a 'mice::mids' object into an object of class 'milist' to be further used by 'miceafter::with'
odds_ratio

Calculates the odds ratio (OR) and standard error.
pool_cindex

Calculates the pooled C-index and Confidence intervals
pool_bftest

Calculates the pooled Brown-Forsythe test.
pool_cor

Calculates the pooled correlation coefficient and Confidence intervals
pool_glm

Pools and selects Linear and Logistic regression models across multiply imputed data.
pool_prop_wald

Calculates the pooled proportion and standard error according to Wald across multiply imputed datasets.
pool_prop_nna

Calculates the pooled proportion and confidence intervals using an approximate Beta distribution.
logit_trans

Logit transformation of parameter estimates
pool_propdiff_ac

Calculates the pooled difference between proportions and standard error according to Agresti-Caffo across multiply imputed datasets.
list2milist

Turns a list object with multiply imputed datasets into an object of class 'milist'.
pool_prop_wilson

Calculates the pooled single proportion confidence intervals according to Wilson across multiply imputed datasets.
pool_D4

Pools the Likelihood Ratio tests across Multiply Imputed datasets ( method D4)
pool_D2

Combines the Chi Square statistics across Multiply Imputed datasets
pool_levenetest

Calculates the pooled Levene test.
pool_odds_ratio

Calculates the pooled odds ratio (OR) and related confidence interval.
pool_propdiff_wald

Calculates the pooled difference between proportions and standard error according to Wald across multiply imputed datasets.
pool_propdiff_nw

Calculates the pooled difference between proportions and confidence intervals according to Newcombe-Wilson (NW) across multiply imputed datasets.
prop_wald

Calculates a single proportion and related standard error according to Wald
risk_ratio

Calculates the risk ratio (RR) and standard error.
propdiff_wald

Calculates the difference between proportions and standard error according to Wald
pool_risk_ratio

Calculates the pooled risk ratio (RR) and related confidence interval.
pool_scalar_RR

Rubin's Rules for scalar estimates
propdiff_ac

Calculates the difference between proportions and standard error according to method Agresti-Caffo
t_test

Calculates the one, two and paired sample t-test
with.milist

Evaluate an Expression across a list of multiply imputed datasets
prop_nna

Calculates the posterior beta components for a single proportion
pool_t_test

Calculates the pooled t-test and Confidence intervals
bf_test

Calculates the Brown-Forsythe test.
fz2cor

Fisher z back transformation of correlation coefficient
f2chi

Converts F-values into Chi Square values
cor_est

Calculates the correlation coefficient
df2milist

Turns a data frame with multiply imputed data into an object of class 'milist'
cor2fz

Fisher z transformation of correlation coefficient
check_model

Function to check input data for function glm_mi
glm_lm_bw

Backward selection of Linear regression models across multiply imputed data.