Dear all.

I am trying to add age as covariant into my liability threshold model. the script runs well before I add age covariant, However, after I add age covariate into the model, OpenMx always give me this error message:

Error in if (label %in% fixedVars && startVals[[label]] != value) { :

missing value where TRUE/FALSE needed.

I googled this error message, it seem to be too many missing values in age variables. But I still can not get the answer which how to fix this issue. I am wondering is any body has experience to fix that? If so, could you give me some suggestion about that?

Thank you very much in advance!

The codes as below:

#mean

meanG

#slope

beta1
values=0, labels='betage', name="b1" )

#age matrix

ObsAge

# Matrices to calculate effect on mean (beta * definition variable)

Defage

#interception

intercep
labels="thresh", name="intercept" )

#threshold

expThresh

#correlations

corMZM
'rFM','rFS','rFS','rFS','rFS','rFD','rFD','rMS','rMS',"rMS",'rMS','rMD','rMD',

'rMZM','rBB','rBB','rBS','rBS','rBB','rBB','rBS','rBS',

'rBB','rBS','rBS','rBS','rBS','rSS'), name="expCorMZM")

corMZF
'rFM','rFD','rFD','rFS','rFS','rFD','rFD','rMD','rMD',"rMS",'rMS','rMD','rMD',

'rMZF','rBS','rBS','rSS','rSS','rBS','rBS','rSS','rSS',

'rBB','rSS','rBS','rBS','rBS','rSS'), name="expCorMZF")

corDZM
'rFM','rFS','rFS','rFS','rFS','rFD','rFD','rMS','rMS',"rMS",'rMS','rMD','rMD',

'rDZM','rBB','rBB','rBS','rBS','rBB','rBB','rBS','rBS',

'rBB','rBS','rBS','rBS','rBS','rSS'), name="expCorDZM")

corDZF
'rFM','rFD','rFD','rFS','rFS','rFD','rFD','rMD','rMD',"rMS",'rMS','rMD','rMD',

'rDZF','rBS','rBS','rSS','rSS','rBS','rBS','rSS','rSS',

'rBB','rSS','rBS','rBS','rBS','rSS'), name="expCorDZF")

corDZMF
'rFM','rFS','rFD','rFS','rFS','rFD','rFD','rMS','rMD',"rMS",'rMS','rMD','rMD',

'rDZMF','rBB','rBB','rBS','rBS','rBS','rBS','rSS','rSS',

'rBB','rBS','rBS','rBS','rBS','rSS'), name="expCorDZMF")

corDZFM
'rFM','rFD','rFS','rFS','rFS','rFD','rFD','rMD','rMS',"rMS",'rMS','rMD','rMD',

'rDZFM','rBS','rBS','rSS','rSS','rBB','rBB','rBS','rBS',

'rBB','rSS','rBS','rBS','rBS','rSS'), name="expCorDZFM")

# Data objects for Multiple Groups

dataMZM
dataDZM
dataMZF
dataDZF
dataDZMF
dataDZFM

# Objective objects for Multiple Groups

objMZM
objDZM
objMZF
objDZF
objDZMF
objDZFM

# Combine Groups

pars groupMZM groupDZM groupMZF groupDZF groupDZMF groupDZFM

minus2ll obj

twinSatModel
#------------------------------------------------------------------------

# RUN SATURATED MODEL (Tetrachoric correlations)

# -----------------------------------------------------------------------

twinSatFit
Running twin

Error in if (label %in% fixedVars && startVals[[label]] != value) { :

missing value where TRUE/FALSE needed

Hi there,

Missing values in the fitted data are OK, but OpenMx cannot handle missing values on definition variables. When there are missing values in the data to be fitted (i.e., the variables in mzmData whose tetrachoric correlations you're modeling), our FIML procedure can select the parts of the model for any given row. Definition variables change the model that is fit to the data for each row, so we don't know how you want the model changed when the definition variable is missing. You have to tell us how you want those cases handled by manipulating your data or model so that NA definition variables don't happen. If you think that the mean of each variable changes as a function of age, how should people who don't have a listed age change?

That said, we should probably improve the error message as well.

Agreed.

For the benefit of anyone who runs into this error later, the error is specifically caused because a named parameter shows up more than once in the model and at least one of those times the value is set to NA.

Probably, here, it's 'age7' or one of the other age labels. Because there's missingness in the age variable, it's given an NA value, and it shows up several times in the model because the ObsAge matrix is added to each of the group models, which are then all combined into the final model.

We'll work on making sure there's a better error message for this in the future. Thanks for reporting it, lingsuer87!

For reference by the developers, here's a miniature example that replicates the error:

Yes, as you told me OpenMx cannot handle missing values on definition variables. afther I recode missing values on definition variables as a different number. My problem is solved. Thank you very much!

I think the issue might be your use of things like all$age7. I suspect that 'all' is the name of a data frame and you intend the mxMatrix named 'Age' to be a matrix full of definition variables.

That would be written as follows

Does that help?