[R] use of offset - clarification

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Dec 4 08:18:03 CET 2002


On Wed, 4 Dec 2002 Alexander.Herr at csiro.au wrote:

> seems I have forgotten some basics re offset in glm:
>
> data:
> counts (y) from locations off different size (area),
> explanatory variable: x
>
> Model:
> y ~ x+offset(area)
> Predictions (pred) using Poisson errors
>
> plot(x,y) and points(x,pred) gives neat "line" of estimated values.
>
> However, for ease of understanding graphs are better using plot(x,y/area).
>
> Question:
> How to display predictions from the model in the graph (using y/area)?
> Plot(x,y/area) with points(x,pred/area) does not give neat line; predicted
> values are varying throughout the graph.
>
> My understanding was that offset(area) using glm on poisson constraints
> model by area, so pred/area should do the job.
>
> What am I doing wrong, can anyone please clarify?

It's a log-linear model, so the offset should be log(area).  The model is

log(E(y)) = beta_0 + beta_1 x + area

and you want

log(E(y)) = beta_0 + beta_1 x + log(area)

so

E(y) = area x exp(beta_0 + beta_1 x)


See
library(MASS)
?Insurance

for an example.


-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list