It is simple to use the provided function glm as fit1 below. However,
without the offset argument, I tried fit2 below. The reason I used fit2 is
that (for X as predictors, b the coefficients)
fit2: log(Claims/Holders) = Xb
means
fit1: log(Claims)=Xb + log(Holders)
Obviously the results from fit2 are different from fit1.
Thanks!
######################################
library("MASS")
## main-effects fit as Poisson GLM with offset
fit1 <- glm(Claims ~ District + Group + Age + offset(log(Holders)),
data = Insurance, family = poisson)
coef(fit1)
> coef(fit1)
(Intercept) District2 District3 District4 Group.L
-1.8105078329 0.0258681909 0.0385239271 0.2342053280 0.4297075387
Group.Q Group.C Age.L Age.Q Age.C
0.0046324351 -0.0292943222 -0.3944318082 -0.0003549709 -0.0167367565
fit2 <- glm(Claims/Holders ~ District + Group + Age,
data = Insurance, family = poisson)
> coef(fit2)
(Intercept) District2 District3 District4 Group.L Group.Q
-1.86340418 0.17552458 0.11081521 0.15131076 0.43701544 -0.01530721
Group.C Age.L Age.Q Age.C
-0.06033747 -0.31976743 -0.01833841 -0.01694737
offset in glm
2 messages · John Smith, Peter Dalgaard
You need weights=Holders to make the 2nd form equivalent to the first (with a bunch of somewhat annoying and largely irrelevant warnings). This is because 300 claims from 1000 holders is more informative than 3 out of 10 even though the rate is the same. -pd
On 27 Feb 2020, at 19:15 , John Smith <jswhct at gmail.com> wrote:
It is simple to use the provided function glm as fit1 below. However,
without the offset argument, I tried fit2 below. The reason I used fit2 is
that (for X as predictors, b the coefficients)
fit2: log(Claims/Holders) = Xb
means
fit1: log(Claims)=Xb + log(Holders)
Obviously the results from fit2 are different from fit1.
Thanks!
######################################
library("MASS")
## main-effects fit as Poisson GLM with offset
fit1 <- glm(Claims ~ District + Group + Age + offset(log(Holders)),
data = Insurance, family = poisson)
coef(fit1)
coef(fit1)
(Intercept) District2 District3 District4 Group.L
-1.8105078329 0.0258681909 0.0385239271 0.2342053280 0.4297075387
Group.Q Group.C Age.L Age.Q Age.C
0.0046324351 -0.0292943222 -0.3944318082 -0.0003549709 -0.0167367565
fit2 <- glm(Claims/Holders ~ District + Group + Age,
data = Insurance, family = poisson)
coef(fit2)
(Intercept) District2 District3 District4 Group.L Group.Q
-1.86340418 0.17552458 0.11081521 0.15131076 0.43701544 -0.01530721
Group.C Age.L Age.Q Age.C
-0.06033747 -0.31976743 -0.01833841 -0.01694737
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com