[Rd] eigenvector dimname convention?
Spencer Graves
spencer.graves at pdf.com
Mon Jun 9 06:55:51 CEST 2008
What are reasonable conventions for dimnames for eigenvectors?
The standard 'eigen' function discards dimnames.
If a matrix X is symmetric (and rownames = colnames), it seems
more sensible to assign rownames(eigen(X)$vectors) <- rownames(X). The
eigenvalues seem different, so I'm inclined to assign names like ev1,
ev2, ..., to the eigenvectors and use those names for the columns of
eigen(...)$vectors.
However, this analysis does not apply if rownames != colnames.
What should be done in that case? The 'solve' function uses a
convention that might help here:
tst <- matrix(1:4, 2, dimnames=list(LETTERS[1:2], letters[3:4]))
> tst
c d
A 1 3
B 2 4
solve(tst)
A B
c -2 1.5
d 1 -0.5
Tentative conclusion: If rownames != colnames (or the matrix is
not symmetric), then dimnames(eigen(X)$vectors) = dimnames(X). That's
because X = (vectors %*% values %*% solve(vectors)). If desired, the
eigenvalues can be assigned names matching colnames(X).
Does this make sense?
I ask, because I'm writing a function 'EIGEN' as a wrapper for
'eigen' that tries to preserve dimnames. This analysis suggests that
how dimnames are assigned is at least partly a matter of convention
rather than mathematics.
Thanks,
Spencer Graves
More information about the R-devel
mailing list