Skip to content
Prev 63376 / 63424 Next

weighted.residuals()

[Including Achim, since he maintains "ivreg"]

There was an intermediate version, relected in the commented-out lines, but that threw errors on 4 CRAN pakcages because some models have residuals/weights methods that do not know about type="working". More precisely, 3 of them (forecast, ivreg, robustbase) did and the 4th (insight) had a unit test comparing the output to another computation of weighted residuals, which of course is bound to fail if you change one of them.

The underlying issue is that deviance residuals (for glm and other models) are generically a bad idea for the purposes of influence measures (and other forms of model checking). They are not unbiased, and it is fairly easy to find examples where the bias is quite substantial. They specifically do not work in dfbeta() et al. if what you want is to generate the one-step approximation to the leave-one-out quantities.

An alternative would be to ask the authors of the offended packages to figure out what needs to be changed. It looks like it might be fairly easy for "ivreg" and "robustbase", which just have issues in weights() which I think could be updated to understand type="working". 


It looks like "forecast" defines a bundle of residuals() methods, but no weights() and the residuals() methods only distinguish between "innovation"/"response"/"deviance". However, it doesn't actually do influence measures, but gets in trouble with its CV() function that calls stats:::deviance.lm() via extractAIC()  which in turn does

sum(weighted.residuals(object)^2, na.rm = TRUE)

This is just plain dumb because it might as well have used deviance residuals directly (it is pretty much the definition of deviance residuals that their sum of squares is the deviance). I had in fact already changed that, so maybe the whole thing already went away for that package.

- Peter