\stnd cov2cor?

5 replies [Last post]
smedland's picture
Offline
Joined: 08/04/2009

Hi
I'm looking for the OpenMx equivilent to the mx \stnd function. Searching the page the cov2cor() function within mxAlgebra pops up a couple of times but looks to have been discontinued(?) in the more recent releases - any similar function currently availble or implemented in the near future?
thanks
Sarah

mspiegel's picture
Offline
Joined: 07/31/2009
Opened a ticket for cov2cor
neale's picture
Offline
Joined: 07/31/2009
Yes, workshop participants

Yes, workshop participants are struggling in the absence of cov2cor. There's a need for it to be somewhat robust, e.g., if there's a zero or negative value in diagonal element a[i,i] then elements [i,] and [,i] of the result should be NA rather than throwing an error (though a warning may be appropriate).

smedland's picture
Offline
Joined: 08/04/2009
the work arround (below) is

the work arround (below) is hanging and taking forever - any ideas on speeding this up?

mxAlgebra( expression= solve(sqrt(I*expCovMZ)) %*% expCovMZ %*% solve(sqrt(I*expCovMZ)), name="expCorMZ" )

mspiegel's picture
Offline
Joined: 07/31/2009
We don't perform automatic

We don't perform automatic common subexpression elimination, so the matrix inverse is computed twice. Use the following:

inverse <- mxAlgebra(solve(sqrt(I * expCovMZ)), name = "inverse")
expCorMZ <- mxAlgebra(inverse %*% expCovMZ %*% inverse, name = "expCorMZ")

tbates's picture
Offline
Joined: 07/31/2009
%&% there's quadratic

%&% there's quadratic multiplier to help:
mxAlgebra(solve(sqrt(I * expCovMZ)), name = "inverse")
mxAlgebra(inverse %&% expCovMZ , name = "expCorMZ")