[R] X'W in Matrix

Rafael A. Irizarry ririzarr at jhsph.edu
Fri Jun 9 05:43:56 CEST 2006


I have used the Matrix package (Version: 0.995-10) successfully 
to obtain the OLS solution for a problem where the design matrix X is 
44000x6000. X is very sparse (about 80000 non-zeros elements).

Now I want to do WLS: (X'WX)^-1X'Wy

I tried W=Diagonal(length(w),w) and

but after various minutes R gives a not enough
memory error (Im using a 64bit machine with 16Gigs of RAM).

I ended up doing this:

which takes about 1-2 minutes, but it seems a better way, using the 
diagonal matrix, should exist. If there is I'd appreciate hearing it. If 
not, Im happy waiting 1-2 minute x #of iters.


More information about the R-help mailing list