[R] offset in glm

John Smith j@whct @end|ng |rom gm@||@com
Thu Feb 27 19:15:02 CET 2020


  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]]



More information about the R-help mailing list