You are here

Direction of causation model

2 posts / 0 new
Last post
ECTore's picture
Offline
Joined: 11/06/2017 - 09:45
Direction of causation model
AttachmentSize
Binary Data DOC model .R8.2 KB

Hello,

I have a question regarding the Direction of Causation (DOC) model. I have found a very useful script at the following link and I'm trying to modify it according to my dataset: http://ibg.colorado.edu/cdrom2016/verhulst/Causation/DOC%20student.R.

I have 2 observed variables (x and y, both continuous) and I would like to verify if their association is causal (i.e. if x causes y. The inverse direction is not possible as x comes before y).

I have attached the modified script for you to have a look. When I run the Cholesky and the DOC models, I get this error:
"Error: Unknown expected covariance name 'expCovMZ' detected in the expectation function of model 'MZ'".
I suppose the problem is in the factor loadings function, but I can't fix it (probably because I'm not sure I understand what 'factor loadings' are). Can anyone help me?

Also, I would like to further modify this script in order to 1) control for a few confounding factors (of which only one- sex- can vary between co-twins) and 2) to control for the effect of a moderator (which does not vary between co-twins and is continuous) on the x variable only. Is it possible? Any suggestions will be much appreciated!

Thank you so much for your help!

Elena

AdminNeale's picture
Offline
Joined: 03/01/2013 - 14:09
Script error

These lines:

MZ <- mxModel("MZ", DataMZ, MZobj)
DZ <- mxModel("DZ", DataDZ, DZobj)

seem to lack the expected covariance matrices desired. The MZ and DZ objects should at least include

DZ <- mxModel("DZ", DataDZ, DZobj, expCovDZ, FacCovDZ, specCovDZ, FacLoadtw)
MZ <- mxModel("MZ", DataMZ, MZobj, expCovMZ, FacCovMZ, specCovMZ, FacLoadtw)

But even more needs to be added... you can see how my debugging was plodding along with these steps:

> MZ <- mxModel("MZ", DataMZ, MZobj, expCovMZ)
> 
> DZ <- mxModel("DZ", DataDZ, DZobj, expCovDZ)
> CholModel <- mxModel("Chol", ACEchol, MZ, DZ, minus2ll, obj, fitFunction)
> 
> CholFit  <- mxRun(CholModel)        # Run Latent DOC ACE model
Error: Unknown reference 'FacCovMZ' detected in the entity 'expCovMZ' in model 'MZ'
> 
> MZ <- mxModel("MZ", DataMZ, MZobj, expCovMZ, facCovMZ)
Error in mxModel("MZ", DataMZ, MZobj, expCovMZ, facCovMZ) : 
  object 'facCovMZ' not found
> MZ <- mxModel("MZ", DataMZ, MZobj, expCovMZ, FacCovMZ)
> DZ <- mxModel("DZ", DataDZ, DZobj, expCovDZ, FacCovDZ)
> CholModel <- mxModel("Chol", ACEchol, MZ, DZ, minus2ll, obj, fitFunction)
> CholFit  <- mxRun(CholModel)        # Run Latent DOC ACE model
Error: Unknown reference 'specCovMZ' detected in the entity 'expCovMZ' in model 'MZ'
> MZ <- mxModel("MZ", DataMZ, MZobj, expCovMZ, FacCovMZ, specCovMZ)
> DZ <- mxModel("DZ", DataDZ, DZobj, expCovDZ, FacCovDZ, specCovDZ)
> CholModel <- mxModel("Chol", ACEchol, MZ, DZ, minus2ll, obj, fitFunction)
> CholFit  <- mxRun(CholModel)        # Run Latent DOC ACE model
Error: Unknown reference 'FacLoadtw' detected in the entity 'FacCovMZ' in model 'MZ'
> DZ <- mxModel("DZ", DataDZ, DZobj, expCovDZ, FacCovDZ, specCovDZ, FacLoadtw)
> MZ <- mxModel("MZ", DataMZ, MZobj, expCovMZ, FacCovMZ, specCovMZ, FacLoadtw)
> CholModel <- mxModel("Chol", ACEchol, MZ, DZ, minus2ll, obj, fitFunction)
> CholFit  <- mxRun(CholModel)        # Run Latent DOC ACE model

I am not sure why such a badly broken script is on the website, I'll ping Brad about it. With respect to adding covariates, that is certainly possible but I am not aware of such scripts. I would perhaps use umx to build a similar model without causal paths, then add them in, at least until such time as direction of causation models are added to umx - which I hope will be later this year, Dr. Bates willing...

Log in or register to post comments