Hi all,
I have been trying to replicate measurement invariance for the CFA model with ordinal data (theta parametrization) in Kline (2015) but have failed due to convergence issues (even after roughly adjusting starting values for thresholds based on lavaan output). I also tried mxAutoStart(). I am wondering if I am missing something.
library(OpenMx) radloffdata <- read.table("https://www.guilford.com/add/kline/radloff-lavaan.txt", sep="\t", header = FALSE) colnames(radloffdata) <- c("x1", "x2", "x3", "x4", "x5", "g") radloffdata[,1] <- ordered(radloffdata[,1]) radloffdata[,2] <- ordered(radloffdata[,2]) radloffdata[,3] <- ordered(radloffdata[,3]) radloffdata[,4] <- ordered(radloffdata[,4]) radloffdata[,5] <- ordered(radloffdata[,5]) rawData1 <- subset(radloffdata, g == 1) rawData2 <- subset(radloffdata, g == 2) # common parameters alphas <- mxPath(from = "one", to = c("x1", "x2", "x3", "x4", "x5"), arrows = 1, free = FALSE, values = 0) varDep <- mxPath(from = "depression", arrows = 2, free = TRUE, values = .5) lambdas <- mxPath(from = "depression", to = c("x1", "x2", "x3", "x4", "x5"), arrows = 1, free = c(FALSE, TRUE, TRUE, TRUE, TRUE), values = c(1, 1, 1, 1, 1)) # model for group 1 dataRaw1 <- mxData(observed = rawData1, type = "raw") kappa1 <- mxPath(from = "one", to = "depression", arrows = 1, free = FALSE, values = 0, labels = "kappa1") thetas1 <- mxPath(from = c("x1", "x2", "x3", "x4", "x5"), arrows = 2, free = FALSE, values = 1) thresholds1 <- mxThreshold(vars = c("x1", "x2", "x3", "x4", "x5"), nThresh = c(3, 3, 3, 3, 3), free = TRUE, values = c(1, 1.5, 2.5, 1.5, 2, 2.5, 1, 2, 2.5, .5, 1.5, 2, 1, 2, 2.5), labels = c("t11", "t12", "t13", "t21", "t22", "t23", "t31", "t32", "t33", "t41", "t42", "t43", "t51", "t52", "t53")) m1 <- mxModel("m1", type = "RAM", manifestVars = c("x1", "x2", "x3", "x4", "x5"), latentVars = "depression", dataRaw1, alphas, kappa1, lambdas, thetas1, varDep, thresholds1) # model for group 2 dataRaw2 <- mxData(observed = rawData2, type = "raw") kappa2 <- mxPath(from = "one", to = "depression", arrows = 1, free = TRUE, values = .5, labels = "kappa2") thetas2 <- mxPath(from = c("x1", "x2", "x3", "x4", "x5"), arrows = 2, free = TRUE, values = .7) thresholds2 <- mxThreshold(vars = c("x1", "x2", "x3", "x4", "x5"), nThresh = c(3, 3, 3, 3, 3), free = TRUE, values = c(1, 1.5, 2, 1.5, 2.2, 2.7, 1, 1.5, 2, .5, .7, 1, 1, 1.5, 2), labels = c("t11", "t12", "t2_13", "t21", "t2_22", "t2_23", "t31", "t2_32", "t2_33", "t41", "t2_42", "t2_43", "t51", "t2_52", "t2_53")) m2 <- mxModel("m2", type = "RAM", manifestVars = c("x1", "x2", "x3", "x4", "x5"), latentVars = "depression", dataRaw2, alphas, kappa2, lambdas, thetas2, varDep, thresholds2) # combine and run models MGOrd <- mxModel("MG Configural Invariance", m1, m2, mxFitFunctionMultigroup(c("m1.fitfunction", "m2.fitfunction"))) MGOrdFit <- mxRun(MGOrd) MGOrdRef <- mxRefModels(MGOrdFit, run = TRUE) summary(MGOrdFit, refModels = MGOrdRef)