Growth Model with different set of times for each subject
Posted on

Suppose I have data on n subjects with at most 3 time points. The first subject has x1, x2, and x3 responses at times 0, 1, and 2. The second has time 0, and 3, and the third only at time 0 and so forth. Would it make sense to create 3 definition variables, say d1, d2, and d3:
d1 d2 d3
0 1 2
0 3 NA
0 NA NA
and use data.d1, data.d2, and data.3 for the slope path labels in a growth model that has a latent intercept and a latent slope?
NA's in the definition variables causes error
Running Linear Growth Curve Model Path Specification
Error: The job for model 'Linear Growth Curve Model Path Specification' exited abnormally with the error message: Expected covariance matrix is not positive-definite in data row 1 at major iteration 0 (minor iteration 1).
In addition: Warning message:
In runHelper(model, frontendStart, intervals, silent, suppressWarnings, :
Not calculating confidence intervals because of error status.
If I have no NA's in the time points but replace some of the x's with NA's, I don't receive this error and the results look OK.
I've attached the modified code.
Log in or register to post comments
In reply to NA's in the definition variables causes error by rabil
Minor remark
If I run this script with
times_1b[1,5] <- NA
times_1b[2,3:5] <- NA
, I get this on "1.2.2-1986":
"The job for model 'Linear Growth Curve Model Path Specification' exited abnormally with the error message: Objective function returned a value of NaN."
Log in or register to post comments
In reply to Minor remark by brandmaier
Could you explain a bit more?
Log in or register to post comments
In reply to Could you explain a bit more? by rabil
Thanks for sharing a batter
Log in or register to post comments
In reply to NA's in the definition variables causes error by rabil
This is a great problem to be
As you've figured out for yourself, NA values for definition variables lead directly to errors. I was under the impression that we were catching this more directly and throwing an error specific to NA definition variables, but I'll look into it. Missing values for the observed data and for definition variables mean very different things. Missing data just means that we have to censor the expected covariance matrix to match the data, so if you're expected covariance matrix is for five timepoints and an individual is missing on the last two, we generate the likelihood of that data pattern for only the data they actually have.
Definition variables are quite different, as missing definition variables make it impossible to generate the expected covariance matrix in the first place. As OpenMx doesn't provide a "link" between definition and observed variables, we can't censor in the same way as with observed data.
If you have a missing definition variable that represents an observation time, you're essentially saying "I observed this person, but I don't know when." As such, you can't include that observation in a growth curve without making an assumption about when it occurred. If you're comfortable with that assumption, then make it directly and put in the observation time. If not, then remove the data at those observations and set the definition variables to a constant value like so:
x3[is.na(d3)] <- NA
d3[is.na(d3)] <- 0
Log in or register to post comments
In reply to This is a great problem to be by Ryne
Ryne wrote: As you've figured
An error is thrown when NA values for definition variables are encountered. The test script did not have NA values in its definition variables.
any(is.na(growthCurveModel$data@observed[,c('t1','t2','t3','t4','t5')])) #returns FALSE
Log in or register to post comments
In reply to Ryne wrote: As you've figured by mspiegel
The NA definition variables
Log in or register to post comments
In reply to The NA definition variables by Ryne
Whoops. You are correct, sir.
Log in or register to post comments