[R] SVD for sparse matrices
oliver.c.lyttelton at gmail.com
Sat Aug 18 19:14:36 CEST 2007
I wish to compute the SVD of a matrix M which represents n rows of
observations of p column measurements. The p measurements are sampled
from a 2 dimensional surface, such that meaningful "neighbourhood"
relationships exists between the p measurement columns.
p is too large to compute the covariance matrix directly (10,000
columns). However, by using neighbourhood information, many of the
entries (i,j) in the covariance matrix can be "masked" to zero, (on
the basis that points i and j lie too far from each other to be
considered. I will call this binary mask matrix B.
So now I have my original matrix M with n observations of p
measurements, and a sparse binary mask matrix B, with
sum(B==0)>>sum(B==1), and B[i,j]==0 indicates that the relationship
between measurements i and j are considered uninteresting.
I wish to compute the SVD of the covariance matrix t(M)%*%M, which is
too large 10,000^2 entries. However only a small subset of these
measurements are non-zero, after applying the mask B.
I have tried to read the documentation accompanying the SparseM and
Matrix packages which include sparse representations, but am stuck.
Given the original matrix M, and a function areNeighbours(i,j) which
returns true if the B[i,j]==1, can anyone furnish me with an example
of how to do this? I would be extremely grateful
Oliver Lyttelton (Phd student)
PS (I appreciate that I could compute the SVD of t(M) if n<<p but I
actively wish to "blot out" the covariance information of unrelated
pairs of measurements)
More information about the R-help