You are here

Single Common Factor Model with Some Residual Errors Correlated

4 posts / 0 new
Last post
rabil's picture
Joined: 01/14/2010 - 16:47
Single Common Factor Model with Some Residual Errors Correlated
Plain text icon forum_openmx_code.txt2.15 KB

I want to fit a single common factor model to seven different types of measurements of the same thing. However, 6 of the methods I expect to have residual errors that are positively correlated. I expect the intercorrelations to be the same among these 6 methods (fortunately) so I want to build in this assumption. There would be too many correlations to estimate separately. So I want to assume rho is the same and need to constrain, say, cov23 = sigma2sigma3rho, cov24=sigma2sigma4rho, etc. But I don't see how to do this using mxConstraints. If I include all the covariances cov23, cov24 etc. in mxPath statements, and build in the constraints directly, it tells me it doesn't know what rho is. If I code it as shown in the attached file, it estimates a model that is unidentified - every time I run it the parameter estimates change drastically. There is no way as far as I can see to code the mxPath statements so that the covariances equal the standard deviations multiplied by rho.

How can force it to estimate a common correlation rho so that the model is identified?

mhunter's picture
Joined: 07/31/2009 - 15:26

You can set a path to be the result of an algebra. For example,

mxPath(from='variable1', to='variable2', arrows=2, free=FALSE, labels='cov12[1,1]')
mxAlgebra(sigma1/sigma2*rho, name='cov12)

This sets the two-headed arrow path between variable1 and variable2 to be equal to sigma1/sigma2*rho. The square brackets in the labels for the path are important. They let OpenMx know that it's not a typical free parameter label, but rather the result of an algebra. Also, you could set up an algebra that produced a 4x4 matrix of the things you needed and just index the first row and second column in the typical R fashion as [1,2].

rabil's picture
Joined: 01/14/2010 - 16:47
I tried something similar

I tried something similar before, but it did not work. I've attached my code based on your example.

When I run it using either mxRun or mxTryHard, I get this error:

> fit.all.cov.deep2 <- mxRun(model.all.cov.deep2)
Error: Unknown reference 'rho' detected in the entity 'cov23' in model 'model_all_cov_deep2'

I received this same error in my first coding attempt and then tried the code in my previous post.

How can I fix this? Thanks.

File attachments: 
tbates's picture
Joined: 07/31/2009 - 14:25
add mxMatrix(name=rho)

In OpenMx algebras etc, variables (like rho) need to be declared in a matrix or other object before they can be used.

so I think you just need to add

rho = mxMatrix(name="rho_mat", type="Full", nrow=1, ncol=1, free=T, values=.3, label="rho")
Log in or register to post comments