## estimation constraint when analyzing correlation matrix

10 replies [Last post]
Offline
Joined: 01/06/2010

Hello,

When analyzing a correlation matrix, do I need to put a constraint to the estimated Sigma so that its diagonal equals identity during optimization? As in Mx? Or has this been taken care of already in openMx?

Suzanne

Offline
Joined: 07/31/2009
Yes, though not necessarily

Yes, though not necessarily using a constraint.

First, a discussion on analyzing correlation matrices (and an argument against using correlation matrices when covariances are available) can be found in a previous thread:

So, how would you go about constraining unit variances? You have a few options.
-Easiest is to simply let the variance terms (either full variances or residuals) be freely estimated. This will affect your fit indices unless you use type="cov" data, as models fit to 'cor' data don't consider the variance terms to be observed parameters.
-mxConstraint can be used as well, but mxConstraint should be used for inequalities only. This is second easiest, but will prevent OpenMx from calculating standard errors.
-Best solution is to make the constraint using an algebra, as discussed in the linked thread above. This is what I tend to do when I have to constrain variances to a specific value.

Offline
Joined: 01/06/2010
Dear Ryne, Thank you very

Dear Ryne,

Thank you very much for your clear response. Unfortunately, I only have correlations available as I am replicating a model from a published article. I am fitting a path model to it. I think I could specify the matrix with variances as Identity - Explained variance, but I am still figuring out what this would exactly look like.

Using a mxConstraint is also ok for me, as hopefully likelihood based confidence intervals would be available instead of SE's . But, when running I get an error: (Error in substituteOperators(as.list(retval)) : Could not find function with name diag and 1 arguments).
Maybe I am doing something obvious wrong...?

matrixI = mxMatrix( type = "Iden",nrow = 4, ncol = 4, name = "I")

algebraS = mxAlgebra(expression = solve(I-B) %*% P %*% t(solve(I-B)), name = "S", dimnames = labels)

constraint = mxConstraint(diag(S) == diag(I), name = "km")

Offline
Joined: 07/31/2009
Those three lines do not

Those three lines do not produce an error running under OpenMx 1.0.7 (see mxVersion()). I'm assuming labels has been defined to something like list(c('foo'),c('foo')).

Offline
Joined: 01/06/2010
Thanks for checking. The

Thanks for checking. The error only shows up when running the model with mxRun. I am using the latest openMx version. I attached my script....

AttachmentSize
constraint.R 1.51 KB
Offline
Joined: 07/31/2009
The issue with your code is

The issue with your code is that 'diag' isn't a function supported by mxAlgebra. Change it to 'diag2vec' and it should work. Get the help page for mxAlgebra (?mxAlgebra in the R console) to see a list of supported functions. This didn't flag until mxRun because the algebra wasn't evaluated until then.

Offline
Joined: 01/06/2010
Aaaah solved, thank you!

Aaaah solved, thank you!

Offline
Joined: 10/08/2009
Hello, If your sample size is

Hello,

If your sample size is large enough, an alternative approach is to use weighted least squares (WLS) to analyze the correlation structure. The first step is to estimate the asymptotic sampling covariance matrix of the correlation matrix. In the second step, WLS is used to analyze the correlation structure. Since a correlation structure is analyzed, the diagonal elements, e.g., error variances, are not part of the model.

This approach has been implemented in metaSEM (http://courses.nus.edu.sg/course/psycwlm/internet/metaSEM/) which depends on OpenMx . The following is an example:

#### Analysis of correlation structure
R1 <- matrix(c(1.00, 0.22, 0.24, 0.18,
0.22, 1.00, 0.30, 0.22,
0.24, 0.30, 1.00, 0.24,
0.18, 0.22, 0.24, 1.00), ncol=4, nrow=4)
n <- 1000
## Estimate the asymptotic sampling covariance matrix of the correlation matrix
acovR1 <- asyCov(R1, n)

P1 <- mxMatrix("Full", ncol=1, nrow=1, value=1, free=FALSE, name="P1")
L1 <- mxMatrix("Full", ncol=1, nrow=4, free=TRUE, name="L1")

## Model to be fitted
impliedR1 <- mxAlgebra(L1 %&% P1, name="impliedR1")
wls.fit1 <- wls(S=R1, acovS=acovR1, n=n, impliedS=impliedR1, matrices=c(P1, L1), cor.analysis=TRUE)
summary(wls.fit1)

Offline
Joined: 09/07/2010
Hello, Mike, Thank you for

Hello, Mike,

Thank you for pointing out this method. Would this be asymptotically equivalent to fitting the data to a covariance structure whose variances are free to be estimated and whose correlations are given by the desired structure? Is there any reference to this method?

Thanks.

Hao

Offline
Joined: 10/08/2009
Hi, Hao. It is generally

Hi, Hao.

It is generally known as the asymptotically distribution-free (ADF) by Browne (1984) and weighted least squares (WLS) in LISREL. Its performance may not be as good as the approach based on the covariance structure when the sample size is small to moderate.

Regards,
Mike

Bentler, P.M., & Savalei, V. (2010). Analysis of correlation structures: current status and open problems. In Kolenikov, S., Thombs, L., & Steinley, D. (Eds.). Recent Methodological Developments in Social Science Statistics (pp. 1-36). Hoboken, NJ: Wiley.

Browne, M. W. (1984). Asymptotically distribution-free methods for the analysis of covariance structures. British Journal of Mathematical and Statistical Psychology, 37, 62-83.

Joreskog, K. G., Sorbom, D., Du Toit, S., & Du Toit, M. (1999). LISREL 8: New Statistical Features. Chicago: Scientific Software International.

Offline
Joined: 01/06/2010
Thank you very much for

Thank you very much for sharing this option. Works fine!