Attachment | Size |
---|---|
dataset for the described code [6] | 323.87 KB |
Hi all,
I'm currently attempting an ordered SEM model with FIML. I'm having an "MxComputeGradientDescent: fitfunction mindfulness.fitfunction is not finite" error. I can't figure out what's wrong. The warning message says something about starting values, but they all seem reasonable. Can anyone find an error?
#### make all variables ordered and create threshold matrix man.vars = r("BDI1", "SPSI52", names(k), T) thresh.vals = matrix(nrow=5, ncol=length(man.vars)) thresh.free = matrix(T, nrow=5, ncol=length(man.vars)) for (i in 1:length(man.vars)){ rng = range(k[,man.vars[i]], na.rm=T) threshholds = (seq(from=rng[1], to=rng[2])) +.5; threshholds = threshholds[which(threshholds <rng[2])] k[,man.vars[i]] = mxFactor(k[,man.vars[i]], levels=rng[1]:rng[length(rng)]) thresh.vals[1:length(threshholds),i] = threshholds } thresh.free[is.na(thresh.vals)]=F #### set up openmx model latent.vars = c("PPO", "NPO", "RPS", "ICS", "AS", "BDI", "DESCRIBING", "OBSERVING", "ACTING", "ACCEPTING") #### specity spsi factor loadings ppo = mxPath(from="PPO", to=c("SPSI7", "SPSI9", "SPSI19", "SPSI28", "SPSI38"), arrows=1, free=T, values=.3) npo = mxPath(from="NPO", to=c("SPSI1", "SPSI2", "SPSI6", "SPSI12", "SPSI13", "SPSI17", "SPSI32", "SPSI36", "SPSI41", "SPSI50"), arrows=1, free=T, values=.3) rps = mxPath(from="RPS", to=c("SPSI11", "SPSI29", "SPSI33", "SPSI44", "SPSI49", "SPSI5", "SPSI20", "SPSI39", "SPSI47", "SPSI48", "SPSI18", "SPSI24", "SPSI40", "SPSI43", "SPSI46", "SPSI25", "SPSI26", "SPSI27", "SPSI35", "SPSI37"), arrows=1, free=T, values=.3) ics = mxPath(from="ICS", to=c("SPSI3", "SPSI4", "SPSI8", "SPSI15", "SPSI21", "SPSI22", "SPSI34", "SPSI45", "SPSI51", "SPSI52"), arrows=1, free=T, values=.3) as = mxPath(from="AS", to=c("SPSI10", "SPSI14", "SPSI16", "SPSI23", "SPSI30", "SPSI31", "SPSI42"), arrows=1, free=T, values=.3) #### specify bdi factor loadings bdi = mxPath(from="BDI", to=c("BDI1", "BDI2", "BDI3", "BDI4", "BDI5", "BDI6", "BDI7", "BDI8", "BDI9", "BDI10", "BDI11", "BDI12", "BDI13", "BDI14", "BDI15", "BDI16", "BDI17", "BDI18","BDI19", "BDI20"), arrows=1, free=T, values=.3) #### specify other variables observing = mxPath(from="OBSERVING", to=c("KIMS1", "KIMS5", "KIMS9", "KIMS13", "KIMS17", "KIMS21", "KIMS25", "KIMS29", "KIMS30", "KIMS33", "KIMS37", "KIMS39"), arrows=1, free=T, values=.3) describing = mxPath(from="DESCRIBING", to=c("KIMS2", "KIMS6", "KIMS10", "KIMS14", "KIMS18", "KIMS22", "KIMS26", "KIMS34"), arrows=1, free=T, values=.3) acting = mxPath(from="ACTING", to=c("KIMS3", "KIMS7", "KIMS11", "KIMS15", "KIMS19", "KIMS23", "KIMS27", "KIMS31", "KIMS35", "KIMS38"), arrows=1, free=T, values=.3) accepting = mxPath(from="ACCEPTING", to=c("KIMS4", "KIMS8", "KIMS12", "KIMS16", "KIMS20", "KIMS24", "KIMS28", "KIMS32", "KIMS36"), arrows=1, free=T, values=.3) #### specify manifest mean and variance (fixed to 0 and 1) mn.ordinal = mxPath(from="one", to=man.vars, arrows=1, free=F, values=0) var.ordinal = mxPath(from=man.vars, arrows=2, free=F, values=1) #### latent variable variance of one and mean of 0 var.latent = mxPath(from= latent.vars, arrows=2, free=F, values=1) mn.latent = mxPath(from="one", to= latent.vars, free=F, values=0) dat = mxData(observed=k, type="raw") ##### set the threshold matrix thresh = mxMatrix(type="Full", nrow=nrow(thresh.vals), ncol=length(man.vars), dimnames=list(c(), man.vars), free=thresh.free, values=thresh.vals, name="thresh") thresh2 = mxExpectationRAM(A="A", S="S", F="F", M="M", thresholds="thresh") mod = mxModel("mindfulness", type="RAM", manifestVars=man.vars, latentVars=latent.vars, ppo, npo, rps, ics, as, bdi, observing, describing, acting, accepting, mn.ordinal, var.ordinal, var.latent, mn.latent, dat, thresh, thresh2) mxTryHard(mxRun(mod))