You are here

Correlated residuals of manifest variables

7 posts / 0 new
Last post
krzysiek's picture
Offline
Joined: 09/05/2013 - 09:49
Correlated residuals of manifest variables

Hi,

Is anybody knows how to model correlated residuals of some manifest variables in OpenMx? Can you give me any example of mxPath()
application to this issue?

best regards,
Krzysztof

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Here is something modified

Here is something modified from the Home page

require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
factorModel <- mxModel("One Factor",
      type="RAM",
      manifestVars = manifests,
      latentVars = latents,
      mxPath(from=latents, to=manifests),
      mxPath(from=manifests, arrows=2, values=.4),
      mxPath(from=latents, arrows=2,
            free=FALSE, values=1.0),
      mxPath(from=manifests[1], to=manifests[2],
            free=TRUE, arrows=2, values=.3), # Added covariance between manifests[1] and manifests[2]
      mxData(cov(demoOneFactor), type="cov",
            numObs=500))
summary(mxRun(factorModel))
tbates's picture
Offline
Joined: 07/31/2009 - 14:25
snap

krzysiek's picture
Offline
Joined: 09/05/2013 - 09:49
Still some doubts

Thank you very much! It seems to me, however, that the specified method reflects correlated manifest variables, not correlated error variance of manifests. Am I right?

Krzysiek

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
see thread 1399 to see equivalence of manifest and residuals

HI Krzysiek,

This thread answers your question: It's an illuminating read about how identical functional specifications can nevertheless require different work for the optimiser

http://openmx.psyc.virginia.edu/thread/1399

krzysiek's picture
Offline
Joined: 09/05/2013 - 09:49
Thank you!

Thank you for explanation!
Krzysiek

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
correlated residuals = mxPath(from = "var1", to = "var2")

This is easy in OpenMx: You just add paths between the variables you think have correlated residuals...
e.g., Here I add a correlation between x2 and x3 in the front-page example. it turns out to be a non-significant correlation:

require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
m1 <- mxModel("One Factor", type="RAM",
      manifestVars = manifests, 
      latentVars = latents, 
      mxPath(from = latents, to = manifests), 
      mxPath(from = manifests, arrows = 2), 
      mxPath(from = latents, arrows = 2, values = 1), 
      mxData(cov(demoOneFactor), type = "cov", numObs = nrow(demoOneFactor))
)
m1 = mxRun(m1)
m2 = mxRun(mxModel(m1, mxPath("x2", "x3", arrows = 2, values=.01), name="correlated_X2_X3"))
mxCompare(m2, m1)
 
              base comparison ep  minus2LL df        AIC   diffLL diffdf         p
1 correlated_X2_X3       <NA> 12 -3649.803  3 -0.1389409       NA     NA        NA
2 correlated_X2_X3 One Factor 11 -3648.281  4 -0.6159977 1.522943      1 0.2171746