data(GenIns)
# over-dispersed Poisson: reproduce ChainLadder estimates
fit1 <- glmReserve(GenIns)
fit1$summary
# plot of standardized residuals
sr <- resid(fit1)/sqrt(fit1$scale)
plot(fitted(fit1),sr)
# qq plot of residuals
qqnorm(sr)
qqline(sr)
# Gamma GLM:
fit2 <- glmReserve(GenIns,var.power=2)
fit2$summary
# plot of standardized residuals
sr <- resid(fit2)/sqrt(fit2$scale)
plot(fitted(fit2),sr)
# qq plot of residuals
qqnorm(sr)
qqline(sr)
# Now suppose we have an exposure measure
# we can put it as an offset term in the model
# to do this, use the "exposure" attribute of the 'triangle'
expos <- (7 + 1:10*0.4)*1000000
GenIns2 <- GenIns
attr(GenIns2,"exposure") <- expos
fit3 <- glmReserve(GenIns2)
fit3$summary
# use bootstrapping to compute prediction error
set.seed(11)
fit4 <- glmReserve(GenIns,mse.method="bootstrap")
fit4$summary
Run the code above in your browser using DataLab