You are here

latent difference score issues

4 posts / 0 new
Last post
rranne2@uic.edu's picture
Offline
Joined: 12/11/2018 - 00:08
latent difference score issues

Hello,

I'm using OpenMx for the first time, building a model in 4 steps. I'm having trouble running the first step that just involves creating a latent difference score using the McArdle (2008) approach. I just have two manifest variables taken at two time points, Anxiety at Time 1 and Anxiety at Time3, and I want to make a latent difference score of these two. Creating the model is not a problem and results in no error message. However, when I actually run the model, I get an error message. Here is the code I've been using and the error message I keep getting:

manifests<-names(mydata3)
latents<-"F1"

myModel5<-mxModel(model="LatenceDifferenceScoreAnxiety", type="RAM", manifestVars=manifests, latentVars=latents,
mxPath(from="Time1newanxiety", to="Time3anxiety", arrows=1, free=FALSE, values=1, labels=c("L1")),
mxPath(from = "F1", to = "Time3anxiety", arrows=1, free=FALSE , values=1, labels=c("L2")),
mxPath(from ="Time1newanxiety", to = "F1", arrows = 2, free=TRUE, values = .4, labels=c("L3")),
mxPath(from = "F1", to = "F1", arrows = 2, free=FALSE, values = 1),
mxPath(from = "Time1newanxiety", to = "Time1newanxiety", arrows=2, free=TRUE, values = .8, labels=c("e1")),
mxPath(from = "one", to = "Time1newanxiety", arrows=1, free=TRUE, values = 7.36, labels=c("manxiety1")),
mxPath(from = "one", to = "F1", arrows=1, free=TRUE, values = .1, labels=c("mchangeanxiety")),
mxData(observed=mydata3, type="raw"))

myModel5Run<-mxRun(myModel5)

"Error: The job for model 'LatenceDifferenceScoreAnxiety' exited abnormally with the error message: fit is not finite (0: The continuous part of the model implied covariance (loc2) is not positive definite in data 'LatenceDifferenceScoreAnxiety.data' row 240. Detail:
covariance = matrix(c( # 30x30 "

Then it lists a ton of zeros, then this:

"In addition: Warning message:
In model 'LatenceDifferenceScoreAnxiety' Optimizer returned a non-zero status code 10. Starting values are not feasible. Consider mxTryHard() "

I tried a lot of things to try to address the problem, including fiddling with the free values, and running mxTryHard. That resulted in another error message: " All fit attempts resulted in errors - check starting values or model specification. "

I then looked for a better way to change the values, so I used: mxGetExpected(myModel5, 'covariance'). However, this only gave me what I had already put in for the variance in Time1new anxiety (.8) and did not give me covariances for F1 and any of my manifest variables.

I used mxAutoStart(myModel5, type = c("ULS”)) to find better values. I got this error message: "Error in omxSetParameters(myModel5, values = newparams, labels = names(oldparams)) :
'labels' argument must be a character vector. "

I used mxAutoStart(myModel5, type = c("DWLS")) to find better values. I got this error message: "Error in optimize(logLikFUN, lower = pcBounds[1], upper = pcBounds[2], :
'xmin' not less than 'xmax'. "

If anyone has any ideas of what might be the problem, I would greatly appreciate it!

Thank you!!!

AdminRobK's picture
Offline
Joined: 01/24/2014 - 12:15
names(mydata3)

First off, kudos for your effort and resourcefulness at trying to find workarounds!

Let me first address the core issue. Your post doesn't give me enough information to be sure, but I think I know what's causing it. If I understand you correctly, your model-expected covariance matrix should be 2x2 and have non-zero start values, but per this,

"Error: The job for model 'LatenceDifferenceScoreAnxiety' exited abnormally with the error message: fit is not finite (0: The continuous part of the model implied covariance (loc2) is not positive definite in data 'LatenceDifferenceScoreAnxiety.data' row 240. Detail:
covariance = matrix(c( # 30x30 "

Then it lists a ton of zeros...

, the OpenMx backend thinks it should be 30x30 and contain many zeroes. I don't know anything about your dataframe, but if it contains any more than two columns, then this,

 manifests<-names(mydata3)

is going to create a vector of more than two character strings, and passing it to mxModel() as the value of argument manifestVars is going to tell OpenMx that there are more than two manifest variables being modeled, but your script never creates any two-headed paths for those manifest variables' (residual) variances. If one or more diagonal elements of the model-expected covariance matrix are fixed at zero, then none of OpenMx's optimizers will be able to get off the ground. In that case, the errors and warnings you report from your initial call to mxRun() and from your call to mxTryHard() would be as expected.

I'll assume for the rest of this post that I am correct about the cause of the core issue.

You report:

I then looked for a better way to change the values, so I used: mxGetExpected(myModel5, 'covariance'). However, this only gave me what I had already put in for the variance in Time1new anxiety (.8) and did not give me covariances for F1 and any of my manifest variables.

I don't have enough information to say whether that behavior is to be expected or if you've encountered a bug.

You report:

I used mxAutoStart(myModel5, type = c("ULS”)) to find better values. I got this error message: "Error in omxSetParameters(myModel5, values = newparams, labels = names(oldparams)) :
'labels' argument must be a character vector. "

I used mxAutoStart(myModel5, type = c("DWLS")) to find better values. I got this error message: "Error in optimize(logLikFUN, lower = pcBounds[1], upper = pcBounds[2], :
'xmin' not less than 'xmax'. "

Same story here. I don't have enough information to tell if that's expected behavior. Certainly, though, the error messages you're seeing here aren't very helpful.

rranne2@uic.edu's picture
Offline
Joined: 12/11/2018 - 00:08
thank you!

Thank you so much for replying! I think I understand the problem as well now! The only manifests I care about in this part of the model I am building out are just Anxiety at time 1 and 3. So using "manifests<-names(mydata3)" is making the model think it has to take all of my variables into account.

I am reading the data from a csv with this code:

mydata3 <-read.csv("Merged K99 & S4S 12 7 only eligible stripped down for anxiety model no missing data in R 12 11.csv")

The data in this cvs has 30 variables, hence the 30X30 I suppose. So what code should I be using instead of "manifests<-names(mydata3)" then? I was just following the OpenMx youtube tutorial and that's what they did in their model to specify the manifests, but I think they were working with a csv that was a lot smaller with a lot fewer variables. Any help would be greatly appreciated!!!

AdminRobK's picture
Offline
Joined: 01/24/2014 - 12:15
Try something like

Try something like

manifests <- c("Time1Anxiety","Time3Anxiety")

or whatever the column names of the two manifest variables happen to be.