Robust Regression – Robust Regression Inference and Sandwich Estimators

lmrregressionsandwich

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) (-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:

  1. The sandwich package:

    library(sandwich)    
    coeftest(model, vcov=sandwich)
    

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.

  1. 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.

    model = ols(a~b, x=TRUE)    
    robcov(model)
    
  2. 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.

Related Question