[Rd] add1.lm and add1.glm not handling weights and offsets properly (PR#8049)

From: <d.firth_at_warwick.ac.uk>
Date: Thu 04 Aug 2005 - 15:50:28 GMT


I am using R 2.1.1 under Mac OS 10.3.9.

Two related problems (see notes 1. and 2. below) are illustrated by results of the following:

y <- rnorm(10)
x <- z <- 1:10
is.na(x[9]) <- TRUE

lm0 <- lm(y ~ 1)
lm1 <- lm(y ~ 1, weights = rep(1, 10))

add1(lm0, scope = ~ x) ## works ok
add1(lm1, scope = ~ x) ## error

lm2 <- lm(y ~ 1, offset = 1:10)

add1(lm0, scope = ~ z) ## works ok
add1(lm2, scope = ~ z) ## gives incorrect results (ignores the offset)

glm0 <- glm(y ~ 1)
glm1 <- glm(y ~ 1, weights = rep(1, 10))
glm2 <- glm(y ~ 1, offset = rep(0, 10))

add1(glm0, scope = ~ x)  ## error

add1(glm1, scope = ~ x) ## error
add1(glm2, scope = ~ x) ## error

As I see it, the two problems are:

  1. add1.lm ignores any offset present in its "object" argument.
  2. add1.lm and add1.glm both take weights directly from their "object" argument, and add1.glm also does the same for any offset that is present. But this does not work when the upper scope includes missing values and na.omit is used: the weights (and offset) then have the wrong length. They should presumably be extracted instead from the reduced model frame.

If I can be of help in fixing these things, please let me know. But I don't want to make things worse, or to duplicate anyone else's work. I don't see this fixed in the bug-fix list at

   https://svn.r-project.org/R/trunk/NEWS but I haven't checked whether the same problems are in the current r-devel.

David



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Aug 05 01:53:40 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:16 GMT