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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to