[Rd] [R] length 1 offset in glm (& lm)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Feb 25 15:40:17 CET 2009
Some digging showed that this has not worked for a long time and the
documentation is either legacy or wishful thinking. So for R-patched
the right approach is to fix the documentation and I will do so
As for model.frame() recycling: that sounds an appealing idea and I
don't think I would want to confine it to case of length one: exact
repeats recycling are allowed in a number of places. And re Peter's
example, this could be done only when it is unambiguous, or only where
there is a response or .... But that will have to wait for another
day (or another hand).
On Wed, 25 Feb 2009, Prof Brian Ripley wrote:
> On Wed, 25 Feb 2009, Heather Turner wrote:
>> 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?)
> So let's be clear: this was the 'offset' argument' and not the offset()
> function as you refer to below.
>> 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.
> Not ignored, just not yet resolved so nothing really useful to say as yet. I
> suspect the documentation was once correct but the offset argument had some
> rather undesirable prperties at the time. And there appears to be some
> legacy code to do the recycling.
> So quite a bit of work is needed on the history to deal wth what is rather a
> small point: sorting out some problems with failing packages (rgdal and
> friends) has been a much higher priority (let alone the day jobs).
>> 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.
> That used not to be the case for the offset _argument_, so probably where the
> docs came from.
>> 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,
>> R-devel at r-project.org mailing list
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
> R-devel at r-project.org mailing list
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel