Displaying 2 results from an estimated 2 matches for "coefs1".
Did you mean:
coef1
2006 Jun 09
1
X'W in Matrix
...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
2011 Jan 20
1
predict() for bootstrapped model coefficients
...ngth(names(df)),
dimnames=list(NULL, c("cons", names(df)[-1])))
set.seed(123)
while(i <= k){
l <- sample(1:length(df[, 1]), replace=T)
m <- update(b.mod, . ~ ., data=df[l, ], trace=F)
c.mat.1[i, ] <- coef(m)[1, ]
c.mat.2[i, ] <- coef(m)[2, ]
i <- i + 1
}
(coefs1 <- apply(c.mat.1, 2, mean))
(coefs2 <- apply(c.mat.2, 2, mean))
summary(predict(b.mod)==model.frame(b.mod)$y)
--
Sascha Vieweg, saschaview at gmail.com