MULTIPLE IMPUTATION SCORE TEST
Appendix
R Syntax for the Real Data Example
## Rosenberg (1979) Self-Esteem Scale data provided by
## http://personality-testing.info/_rawdata/
## R scripts that import data, impose missing values, and multiply impute the
## data can be found on this project's Open Science Framework (OSF) page:
## https://osf.io/m2gd8/
## -----------------------
## Import the Imputed Data
## -----------------------
## stored as a single stacked data.frame with an indicator variable
allimps <- read.csv(file = "rosenimps.csv", header = FALSE,
col.names = c("imp", colnames(cdata)))
## extract the rows for each imputation, store as a list of imputations
impList <- lapply(1:max(allimps$imp),
function(m) allimps[allimps$imp == m, -1])
## NOTE: Annotated syntax on our OSF page also reverse-scores items
## ------------------------
## Analyze the Imputed Data
## ------------------------
## load semTools (at least version 0.5-1.921), which also loads lavaan
library(semTools)
## if your version is not up to date, install the development version:
## devtools::install_github("simsem/semTools/semTools")
## specify the restricted model
(model <- paste("F =~", paste0("X", 1:10, collapse = " + ")))
## fit the model to imputed data
fit.imps <- cfa.mi(model, data = impList, std.lv = TRUE)
## obtain pooled results (estimates, fit measures)
summary(fit.imps)
fitMeasures(fit.imps)
## specify constrained parameters that could be added to the model
myResidCors <- c('X9 ~~ X10', 'X1 ~~ X2', 'X6 ~~ X7')
## request the score test, univariate tests of each parameter, and their EPCs
out.imps <- lavTestScore.mi(fit.imps, add = myResidCors, epc = TRUE,
test = "D1", asymptotic = TRUE)
## print multiparameter score test
out.imps$test
## print individual univariate tests, with expected parameter changes ...
out.imps$uni
## ... which are the usual modification indices (also with EPCs)
modindices.mi(fit.imps, op = "~~", minimum.value = 50, sort. = TRUE,
test = "D1")