Hi,

Getting my head around how to add a covariate to a script.

In mx1.x, there were two 'data' statements: "SElect" and "DEfinition_variables".

**Select** is equivalent to **mxData**() and selects the variables from which expected covariances (and means) are computed.

**Definition** creates a list of covariates used to populate matrices with individual-level data, such as sex and age. (in old mx this was done using negative indices, but in OpenMx we could use the names() of the definition columns as labels signifying a matrix is to be created for every subject using definition-level data).

I can't see an OpenMx equivalent of "Definition". Hopefully this is so powerfully simple now that I am over-looking an obvious usage in OpenMx but can't see it...

Just adding covariates onto the end of the mxData() statement seems wrong when we don't want to model the covariance of these covariates with the variables in which we are interested, just model them out of the means of our mxData() columns?

Is an mxCovariates(data) statement needed?

So if you had a covariates dataframe

head(covs) age1 age2 1 ... ....

You could then say:

mxModel( ... mxCovariates(covs) # setting a value to a name brings in correct row of data from covariates mxMatrix(nrow=1, ncol=nCov,free=TRUE, values=c('age1'), name="T1covs") mxMatrix(nrow=1, ncol=nCov,free=TRUE, values=c('age2'), name="T2covs") # Algebra evaluated across all subjects individually mxAlgebra(Means J+ T1covs*beta | K+ T2covs*betas, name="expMeans") )