You are here

mxData: cov to take lower, upper, and full?

It would be very handy if, when type="cov", mxData could intelligently take lower, upper and full covariance matrices. Because a matrix or dataframe will be provided, the difference between the types is that one or other triangle will be full of 0s or NAs.

i.e., that this would work:

data = read.moments(file = "", diag = T)
1
.3 1
.4 .35 1

mxData(data, type="cov",numObs=100)

without first requiring
data[upper.tri(data)] = data[lower.tri(data)]

I guess the code would check for symmetry, then reflect the non-zero triangle into the empty triangle using lower.tri(), upper.tri() and t()

Ideally, detecting that the diagonal is missing would cause it to be filled with 1s.

Reporter: 
Created: 
Wed, 11/25/2009 - 12:51
Updated: 
Fri, 11/27/2009 - 16:49

Comments

This feature could be implemented by writing your own function that converts lower and upper matrices to symmetric matrices. I prefer not to add additional features to the library in cases when these features can be implemented with a user level function.

ok, i've added that to my textmate library...

should this not throw an error?

library(sem)
data = read.moments(file = "", diag = T)
1
.3 1
.4 .35 1

mxData(data, type="cov",numObs=100)

I'd expect something like "covariance matrices must be symmetrical"

Fixed in r989.