Closed landroni closed 10 years ago
I'm not that sure of how to best implement the vcovHC seamlessly with the lm
function. The vcov.lm is rather simple:
stats:::vcov.lm
function (object, ...)
{
so <- summary.lm(object)
so$sigma^2 * so$cov.unscaled
}
Unfortunately the summary.lm
is more complex, the rms
-package has the variable object$var
and therefore all you need to do is a switch of the var in order to make it work seamlessly with predict
, contrast
, and all the other neat rms
functions. Just out of curiosity, what do you need from the lm
that the ols
doesn't have?
Hmm.. vcovHC
by default works just fine with lm
models. But I was hoping to go the opposite way: make robcov
work with lm
objects. Can the latter be done?
"Just out of curiosity, what do you need from the lm that the ols doesn't have?"
As much as I appreciate Frank's work and expertise, the ols
function is somewhat non-standard (and I'm not very familiar with it). On the other hand lm
is indeed the standard function for linear models. As such, for good or bad reasons, I'm naturally wary of using ols
..
Unfortunately I'm not enough familiar with the inner workings of lm
in order to adjust the covariance matrix. My best bet would be to implement a robcov
function that adds the class robcov and then write your own version of the predict.lm
, confint.lm
, summary.lm
... functions.
I see. Thanks a lot for the pointers.
BTW, out of curiosity, why do you prefer ols
over lm
?
I believe that the anova.rms
and the contrast
functions are killer functions. It is perhaps not that necessary for lm
but the package contains cox regression and other regression functions where it is difficult to find a replacement.
I agree though that it would be nicer to use the standard functions, getting everything working is a monumental task, even for someone as experienced as Frank Harrell; I recently wanted to use the offset-term with the Glm-function and getting it to work seamlessly was overwhelming and I had to give up on using splines in that particular case :-(
This is more of a query. Following http://stackoverflow.com/questions/8389843/clustered-standard-errors-r-panel-data/8390880#8390880 I discovered
robcov
inrms
and thenrobcovalt
inGreg
. However it seems that both these functions work exclusively withols
models fromrms
, but NOT withlm
models.Are you aware of any function that allows clustering (like
robcov
does) but forlm
models? (Before checking outGreg
, I was hoping thatrobcovalt
would extendrobcov
tolm
models, but this doesn't seem to be the case.)