Hi.
I've been trying everything to get an ordinal manifest working in RAM models but I can't get it done. Also, didn't find anything online about this, as most examples have matrix specification. Would be very appreciated to get some help. Besides from the solution below, I have also tried every possible way with mxthreshold and umxthresholdmatrix.
obesityLevels = c('normal', 'obese') cutPoints = quantile(twinData[, "bmi1"], probs = .2, na.rm = TRUE) twinData$obese1 = cut(twinData$bmi1, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) twinData$obese2 = cut(twinData$bmi2, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) # Step 2: Make the ordinal variables into umxFactors (ordered, with the levels found in the data) selVars = c("obese1", "obese2") twinData[, selVars] = umxFactor(twinData[, selVars]) #tmp = umxThresholdMatrix(twinData, selDVs = selVars, sep = "", verbose = TRUE) tmp = umx_make_twin_data_nice(data=twinData, sep="", zygosity="zygosity", numbering=1:2) tmp = umx_scale_wide_twin_data(varsToScale= c("wt", "ht"), sep= "_T", data= tmp) mzData = subset(tmp, zygosity %in% c("MZFF", "MZMM")) dzData = subset(tmp, zygosity %in% c("DZFF", "DZMM")) latents = c("A1", "C1", "E1", "A2", "C2", "E2") manifests = c("obese_T1", "obese_T2") latVariances <- mxPath( from=latents, arrows=2, free=FALSE, values=1 ) manifestsVariances <- mxPath( from=manifests, arrows=2, free=FALSE, values=1 ) # means of latent variables latMeans <- mxPath( from="one", to=latents, arrows=1, free=FALSE, values=0 ) # means of observed variables obsMeans <- mxPath( from="one", to=manifests, arrows=1, free=F, values=0, labels="mean" ) # path coefficients for twin 1 pathAceT1 <- mxPath( from=c("A1","C1","E1"), to="obese_T1", arrows=1, free=TRUE, values = 1, label=c("a","c","e") ) # path coefficients for twin 2 pathAceT2 <- mxPath( from=c("A2","C2","E2"), to="obese_T2", arrows=1, free=TRUE, values = 1, label=c("a","c","e") ) # covariance between C1 & C2 covC1C2 <- mxPath( from="C1", to="C2", arrows=2, free=FALSE, values=1 ) # covariance between A1 & A2 in MZ twins covA1A2_MZ <- mxPath( from="A1", to="A2", arrows=2, free=FALSE, values=1 ) # covariance between A1 & A2 in DZ twins covA1A2_DZ <- mxPath( from="A1", to="A2", arrows=2, free=FALSE, values=.5 ) paths <- list( latVariances, latMeans, obsMeans, pathAceT1, pathAceT2, covC1C2, manifestsVariances ) dataMZ <- mxData(observed=mzData, type = "raw") dataDZ <- mxData(observed=dzData, type = "raw") #threshold <- mxThreshold(vars=c("obese_T1", "obese_T2"), nThresh=c(1), free = T) threshold <- mxMatrix("Full", nrow=1, ncol=2, byrow=T, name="thresh", dimnames = list(c(), manifests), free = c(T, T), values = c(-.8, -.8), ) expect <- mxExpectationRAM(A="A", S="S", F="F", M="M", thresholds = "thresh") fitfunction = mxFitFunctionML() modelMZ <- mxModel(model="MZ", type="RAM", manifestVars=manifests, latentVars=latents, paths, covA1A2_MZ, dataMZ, threshold, expect, fitfunction) modelDZ <- mxModel(model="DZ", type="RAM", manifestVars=manifests, latentVars=latents, paths, covA1A2_DZ, dataDZ, threshold, expect, fitfunction) obj <- mxFitFunctionMultigroup(c("MZ", "DZ")) modelACE <- mxModel("ACE", modelMZ, modelDZ, obj) fitACE <- mxRun(modelACE)
I have tried fixing the threshold across twins and zygosity, but to no avail. The results either are extremely high estimates for the paths with high SEs, or they are just plainly wrong (if compared to umx results). Help is great appreciated,
thank you