A few days ago, I was asked if we should spend a lot of time to choose the distribution we use, in GLMs, for (actuarial) ratemaking. On that topic, I usually claim that the family is not the most important parameter in the regression model. Consider the following dataset
> db <- data.frame(x=c(1,2,3,4,5),y=c(1,2,4,2,6)) > plot(db,xlim=c(0,6),ylim=c(-1,8),pch=19)
To visualize a regression model, use the following code
> nd=data.frame(x=seq(0,6,by=.1)) > add_predict = function(reg){ + prd1=predict(reg,newdata=nd,se.fit = TRUE,type="response") + y1=prd1$fit + y1_upp=prd1$fit+prd1$residual.scale*1.96* prd1$se.fit + y1_low=prd1$fit-prd1$residual.scale*1.96* prd1$se.fit + polygon(c(nd$x,rev(nd$x)),c(y1_upp, rev(y1_low)),col="light green",angle=90, density=40,border=NA) + lines(nd$x,y1,col="red",lwd=2) + }
For instance, with a Poisson regression (with a log link function) we get
> plot(db) > reg1=glm(y~x,family=poisson(link="log"), + data=db) > add_predict(reg1)
while, with a Gaussian regresion (but still with a log link function), we get
> plot(db) > reg2=glm(y~x,family=gaussian(link="log"), + data=db) > add_predict(reg2)
If we just care about the expected value of our prediction, the output is more or less the same
> plot(db) > lines(nd$x,predict(reg1,newdata=nd, + type="response"),col="red",lwd=1.5) > lines(nd$x,predict(reg2,newdata=nd, + type="response"),col="blue",lwd=1.5)
So, indeed, forget about the (distribution) law when running a GLM. Not convinced? Consider – on the same dataset – a Poisson regression (with an identity link function this time)
> plot(db) > reg1=glm(y~x,family=poisson(link="identity"), + data=db) > add_predict(reg1)
while, with a Gaussian regresion (but still with an identity link function), we get
> plot(db) > reg2=glm(y~x,family=gaussian(link="identity"), + data=db) > add_predict(reg2)
Again, if we just plot the expected value of our prediction, the output is more or less the same
> plot(db) > lines(nd$x,predict(reg1,newdata=nd, + type="response"),col="red",lwd=1.5) > lines(nd$x,predict(reg2,newdata=nd, + type="response"),col="blue",lwd=1.5)
So clearly, the simplistic message you should not care too much about the (distribution) law seems to be valid…
Continue reading I Fought the (distribution) Law (and the Law did not win)