I am trying to read in the variance-covariance matrix written out by LISREL in the following format as plain text, separated by spaces:
0.23675E+01 0.86752E+00 0.28675E+01 -0.36190E+00 -0.36190E+00 0.25381E+01 -0.32571E+00 -0.32571E+00 0.84425E+00 0.25598E+01 -0.37680E+00 -0.37680E+00 0.53136E+00 0.47822E+00 0.21120E+01 -0.37680E+00 -0.37680E+00 0.53136E+00 0.47822E+00 0.91200E+00 0.21120E+01
This is actually the bottom diagonal matrix (including the diagonal):
0.23675E+01 0.86752E+00 0.28675E+01 -0.36190E+00 -0.36190E+00 0.25381E+01 -0.32571E+00 -0.32571E+00 0.84425E+00 0.25598E+01 -0.37680E+00 -0.37680E+00 0.53136E+00 0.47822E+00 0.21120E+01 -0.37680E+00 -0.37680E+00 0.53136E+00 0.47822E+00 0.91200E+00 0.21120E+01
I am reading values ββcorrectly with scan() or read.table(fill=T) .
However, I cannot save the read vector in the matrix correctly. Following code
S <- diag(6) S[lower.tri(S,diag=T)] <- d
fills the bottom matrix by column, while it should fill it by row.
Using matrix() allows you to use the byrow=TRUE parameter, but this will fill the entire matrix, not just the bottom half (with a diagonal).
Is it possible to have both: fill in the bottom matrix (with a diagonal) and do it line by line?
(separate release that I have: LISREL uses βD + 01β, while R only recognizes βE + 01β for scientific notation. Can you change this to R to accept also βDβ?)
matrix covariance r
mhermans
source share