| 1 |
March 30 2014 |
| 2 |
|
| 3 |
Use of slm it is sometimes impeded by the fact that model.matrix |
| 4 |
require a construction of a dense form of X. This can be circumvented |
| 5 |
by using the sparse model matrix construction in the Matrix package, or |
| 6 |
less directly by just constructing X in csr form and using slm.fit.csr |
| 7 |
for estimation. A downside of the latter strategy is that summary() |
| 8 |
can't be used on the resulting object, but something like the following |
| 9 |
hack can be used: |
| 10 |
|
| 11 |
function (object, correlation = FALSE, ...) |
| 12 |
{ |
| 13 |
Chol <- object$chol |
| 14 |
n <- length(object$residuals) |
| 15 |
p <- object$chol@nrow |
| 16 |
rdf <- n - p |
| 17 |
r <- residuals(object) |
| 18 |
rss <- sum(r^2) |
| 19 |
resvar <- rss/rdf |
| 20 |
R <- backsolve(Chol, diag(p)) |
| 21 |
sqrt(diag(R) * resvar) |
| 22 |
} |
| 23 |
|
| 24 |
It might be nice to regularize this... |
| 25 |
|