[Rd] request for patch in "drop1" (add.R)

Ben Bolker bbolker at gmail.com
Wed Feb 23 15:14:37 CET 2011


  By changing three lines in drop1 from access based on $ to access
based on standard accessor methods (terms() and residuals()), it becomes
*much* easier to extend drop1 to work with other model types.
The use of $ rather than accessors in this context seems to be an
oversight rather than a design decision, but maybe someone knows better ...

  In particular, if one makes these changes (which I am pretty certain
will not break anything, as the original code basically mimicked the
default methods anyway), it becomes possible to make drop1() work with
mer objects (Doug Bates's new mixed model code) merely by defining:

terms.mer <- function(x, ...) {
  attr(x at frame,"terms")
}

extractAIC.default <- function(fit, scale=0, k=2, ...) {
  L <- logLik(fit)
  edf <- attr(L,"df")
  c(edf,-2*L+2*edf)
}

 Adding this definition of extractAIC.default also makes drop1() work
with lme fits ...

  Comments?  Should I submit to the bug database as "enhancement
request"?  Are there any hidden downsides to this?

  Ben Bolker
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: add_diff.txt
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20110223/0cb0c994/attachment.txt>


More information about the R-devel mailing list