fit_mice_for_diag: Create a 'mice' object for diagnostics

fit_mice_for_diagR Documentation

Create a mice object for diagnostics

Description

Function that creates a mice object for diagnostics, with m = 5. Iteratively increases the number of iterations by 5 until Rhat < Rhat.threshold for mean and variance of all variables in imputation model. Thus, accessing $iteration in the resulting mice object will give the value of maxit to be used in the final m > 5 imputation model.

Usage

fit_mice_for_diag(..., iter10 = FALSE, Rhat.threshold = 1.1, final.maxit = 100)

Arguments

...

Arguments to be passed to mice call (typically, dataframe, method vector, and prediction matrix).

iter10

Logical switch indicating whether function should use the iterative procedure to find a sufficient number of iterations. When TRUE, will stop after fitting a m = 5, maxit = 10 model. Included for convenience when working with code that includes the function.

Rhat.threshold

Maximum acceptable R-hat statistic

final.maxit

Number of iterations after which search should stop, regardless of whether Rhat threshold has been met.

Details

Always uses same random seed. Includes a dataframe with all Rhat values at each step, which can be accessessed via mice$rhat. See mice::mice for more documentation of arguments.

Examples

library(mice)
pred.matrix <- quickpred(boys, mincor = .10, minpuc = 0.50)
mice.m5 <- fit_mice_for_diag(data = boys,
                             predictorMatrix = pred.matrix,
                             method = c("pmm"))
mice.m5$m
mice.m5$iteration
mice.m5$rhat

wepelham3/sack2 documentation built on Aug. 5, 2023, 5:53 a.m.