[Rd] Generic Functions for dffits and covratio

From: Viechtbauer Wolfgang (STAT) <wolfgang.viechtbauer_at_maastrichtuniversity.nl>
Date: Tue, 06 Sep 2011 17:31:18 +0200


Dear All,

A while back, I asked about the possibility of adding a generic function for dffits to stats:

https://stat.ethz.ch/pipermail/r-devel/2011-May/061011.html

I am still hoping that this would be possible. The same also applies to covratio. Currently, there are no generics for these two functions (while there are generics for cooks.distance, dfbetas, and a few more).

I think it would be more consistent to have generics for dffits and covratio as well. This would only require adding those two generics and turning the current dffits and covatio functions into dffits.default and covratio.default:

dffits <- function(model, ...)

   UseMethod("dffits")

covratio <- function(model, ...)

   UseMethod("covratio")

dffits.default <- function(model, infl = lm.influence(model, do.coef = FALSE), res = weighted.residuals(model), ...) {

    res <- res * sqrt(infl$hat)/(infl$sigma * (1 - infl$hat))     res[is.infinite(res)] <- NaN
    res
}

covratio.default <- function(model, infl = lm.influence(model, do.coef = FALSE), res = weighted.residuals(model), ...) {

   n <- nrow(qr.lm(model)$qr)
   p <- model$rank
   omh <- 1 - infl$hat
   e.star <- res/(infl$sigma * sqrt(omh))    e.star[is.infinite(e.star)] <- NaN
   1/(omh * (((n - p - 1) + e.star^2)/(n - p))^p)
}

This would allow package authors to easily add dffits and covratio methods for models other than lm and glm to their package. Making those substitutions above in another package is a bit awkward and of course leads to messages about dffits and covratio being masked.

I hope that there is some interest in this.

Best,

Wolfgang



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 06 Sep 2011 - 16:15:08 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 07 Sep 2011 - 19:40:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive