# NOT RUN {
# }
# NOT RUN {
## impose missing data for example
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
set.seed(12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
## impute missing data
library(Amelia)
set.seed(12345)
HS.amelia <- amelia(HSMiss, m = 20, noms = "school", p2s = FALSE)
imps <- HS.amelia$imputations
## specify CFA model from lavaan's ?cfa help page
HS.model <- '
speed =~ c(L1, L1)*x7 + c(L1, L1)*x8 + c(L1, L1)*x9
'
out <- cfa.mi(HS.model, data = imps, group = "school", std.lv = TRUE)
## Mode 1: Score test for releasing equality constraints
## default test: Li et al.'s (1991) "D2" method
lavTestScore.mi(out, cumulative = TRUE)
## Rubin's rules
lavTestScore.mi(out, test = "Rubin")
## Mode 2: Score test for adding currently fixed-to-zero parameters
lavTestScore.mi(out, add = 'x7 ~~ x8 + x9')
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab