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

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Wed, 25 Feb 2009 14:41:34 +0100

Prof Brian Ripley wrote:
> On Wed, 25 Feb 2009, Kenneth Knoblauch wrote:
>

>> Hi
>>
>> Quoting Prof Brian Ripley <ripley_at_stats.ox.ac.uk>:
>>
>>> 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?)
>>>>
>>>> https://stat.ethz.ch/pipermail/r-help/2009-February/189352.html
>>>
>>> So let's be clear: this was the 'offset' argument' and not the offset()
>>> function as you refer to below.
>>
>> It occurs for both

>
> Yes (I knew). but no one (AFAICS) said the function allows length-1
> arguments: Heather is raising the possibility that it should as new
> functionality, I believe.

Makes sense to have them consistent though, and we we do advertise that recycling works for the argument. Looks like this could be fixed at the level of model.frame.default, but the sticky bit is where to get the repeat count in case the formula is something like "~-1". I don't quite fathom the current rules:

> model.frame(~-1,offset=1)

  (offset)
1 1
> model.frame(~-1,offset=1,data=aq)

  (offset)
1 1
> model.frame(Ozone~-1,offset=1,data=aq)
Error in model.frame.default(Ozone ~ -1, offset = 1, data = aq) :   variable lengths differ (found for '(offset)')
> model.frame(Ozone~-1,data=aq)

  Ozone
1 41
2 36
3 12
4 18
6 28
> model.frame(~-1,data=aq)

data frame with 0 columns and 6 rows

> foo <- 2:3
> model.frame(~foo-1,data=aq)

   foo
1 2
2 3

3 <NA>
4 <NA>
5 <NA>
6 <NA>

Warning message:
In format.data.frame(x, digits = digits, na.encode = FALSE) :   corrupt data frame: columns will be truncated or padded with NAs
> foo <- 2
> model.frame(~foo-1,data=aq)

  foo
1 2
-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 25 Feb 2009 - 12:43:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 25 Feb 2009 - 13:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive