Hi!

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
wX=solve(X,W)

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:
wX=Matrix(as.matrix(X)*sqrt(w),sparse=TRUE)
coefs1=as.vector(solve(crossprod(wX),crossprod(X,w*y)))

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.


Thanks,
Rafael

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to