Conditional Item Infit MSQ for Multiply Imputed Data
Source:R/conditional_infit_mi.R
RMitemInfitMI.RdExtends RMitemInfit to work with multiply imputed datasets
produced by the mice package. Computes conditional infit MSQ on each
imputed dataset and pools the results using Rubin's rules.
Arguments
- mids_object
A
midsobject (multiply imputed dataset) as returned bymice::mice(). Each completed dataset must contain only the item response columns to be analysed (i.e., no ID or grouping variables). Items must be scored starting at 0 (non-negative integers).- cutoff
Optional. Default
NULL(no cutoff applied). Can be:The return value of
RMitemInfitCutofforRMitemInfitCutoffMI(a list with$item_cutoffs): the data.frame is extracted automatically and metadata is included in the kable caption.The
$item_cutoffsdata.frame directly: must have columnsItem,infit_low, andinfit_high. When provided, adds columnsInfit_low,Infit_high, andFlaggedto the result.
- output
Character string controlling the return value. Either
"kable"(default) for a formattedknitr::kable()table, or"dataframe"for the underlying data.frame.- sort
Optional character string. When
sort = "infit", rows are sorted byInfit_MSQin descending order before output.
Value
If
output = "kable": aknitr_kableobject (plain text table viaformat = "pipe") with columns "Item", "Infit MSQ", "Infit SE", "Relative location", and a caption noting the number of imputations and complete cases. Whencutoffis provided, columns "Infit low", "Infit high", and "Flagged" are also included.If
output = "dataframe": a data.frame with columnsItem,Infit_MSQ,Infit_SE, andRelative_location. Whencutoffis provided, columnsInfit_low,Infit_high, andFlaggedare also included (inserted afterInfit_SE, beforeRelative_location).
Details
For each of the m imputed datasets, the function:
Fits a Rasch model (
eRm::RM()for dichotomous data oreRm::PCM()for polytomous data).Computes conditional infit MSQ and its standard error via
iarm::out_infit().Computes item and person locations.
The per-imputation estimates are then pooled using Rubin's rules:
- Pooled MSQ
The mean of the
minfit MSQ point estimates.- Within-imputation variance
The mean of the
msquared standard errors.- Between-imputation variance
The sample variance of the
mpoint estimates.- Total variance
Within + (1 + 1/m) * Between.
- Pooled SE
The square root of the total variance.
Relative item location is the mean of per-imputation relative locations (item location minus sample mean person location).
Imputed datasets that cause model convergence failures are dropped with a warning. If all imputations fail, the function stops with an error. At least two successful imputations are required to estimate between-imputation variance.
The mice and iarm packages must be installed (they are in Suggests, not
Imports).
Examples
# \donttest{
if (requireNamespace("mice", quietly = TRUE)) {
# Create example data with missing values
set.seed(42)
sim_data <- as.data.frame(
matrix(sample(0:1, 200 * 8, replace = TRUE), nrow = 200, ncol = 8)
)
colnames(sim_data) <- paste0("Item", 1:8)
sim_data[sample(length(sim_data), 0.10 * length(sim_data))] <- NA
# Impute (use more imputations, e.g. m = 5+, in real analyses)
imp <- mice::mice(sim_data, m = 2, method = "polr", seed = 123,
printFlag = FALSE)
# Pooled infit table (no cutoffs)
RMitemInfitMI(imp)
# With simulation-based cutoffs
# (use more iterations, e.g. 250+, in real analyses)
cutoff_mi <- RMitemInfitCutoffMI(imp, iterations = 50, parallel = FALSE,
seed = 42)
RMitemInfitMI(imp, cutoff = cutoff_mi)
# As data.frame
df <- RMitemInfitMI(imp, cutoff = cutoff_mi, output = "dataframe")
}
# }