[Rd] [R] length 1 offset in glm (& lm)

Heather Turner Heather.Turner at warwick.ac.uk
Wed Feb 25 13:48:27 CET 2009

This post about length 1 offsets on R help seems to have been ignored
(sorry deleted original email - is there a way to continue thread in
this case?)


It does seem to be a bug, in that glm does not behave as documented. In
fact the same bug applies to lm as well.

I don't think the suggested fix works though - Y isn't available until
the model frame is evaluated. Moreover you would want to evaluate the
offset as part of the model frame, to take care of the search path,
subset and na.action.

One possibility would be to modify model.frame to recycle variables of
length one. This would be a potentially useful feature from my point of
view as offset(constant) could replace Const(constant) in gnm, which is
basically a work around for this problem in the case of specifying a
constant in a nonlinear term. However, this solution may have undesired
side-effects and I don't feel too strongly about it as there are various
 work-arounds. Perhaps the simplest solution would be to modify the docs
so that offsets of length one are disallowed - it is easy enough for the
user to create a vector of the right length as necessary.

Best regards,


More information about the R-devel mailing list