Can you give me an example of the use of sandwich estimators in order to perform robust regression inference?
I can see the example in ?sandwich
, but I don't quite understand how we can go from lm(a ~ b, data)
(r-coded) to an estimate and a p value resulting from a regression model using the variance-covariance matrix returned by the function sandwich
.
Best Answer
I think there are a few approaches. I haven't looked at them all and not sure which is the best:
The
sandwich
package:But this doesn't give me the same answers I get from Stata for some reason. I've never tried to work out why, I just don't use this package.
The
rms
package: I find this a bit of a pain to work with but usually get good answers with some effort. And it is the most useful for me.You can code it from scratch (see this blog post). It looks like the most painful option, but remarkably easy and this option often works the best.
A simple / quick explanation is that Huber-White or Robust SE are derived from the data rather than from the model, and thus are robust to many model assumptions. But as always, a quick Google search will lay this out in excruciating detail if you're interested.