Studying joint effects in a regression
By arthur charpentier on Thursday, October 7 2010, 14:17 - actuariat 10/11 STT6705V - Permalink
We've seen in the previous post (here) how important the *-cartesian
product to model joint effected in the regression. Consider the case of
two explanatory variates, one continuous (
, the age of the driver) and one qualitative (
, gasoline versus diesel).
- The additive model

Then, given
(the exposure, assumed to be constant) and 

> reg=glm(nbre~bs(ageconducteur)+carburant+offset(exposition),
+ data=sinistres,family="poisson")
> ageD=data.frame(ageconducteur=seq(17,90),carburant="D",exposition=1)
> ageE=data.frame(ageconducteur=seq(17,90),carburant="E",exposition=1)
> yD=predict(reg,newdata=ageD,type="response")
> yE=predict(reg,newdata=ageE,type="response")
> lines(ageD$ageconducteur,yD,col="blue",lwd=2)
> lines(ageE$ageconducteur,yE,col="red",lwd=2)


).> plot(ageD$ageconducteur,yD/yE)

- The nonadditive model
> reg=glm(nbre~bs(ageconducteur)*carburant+offset(exposition),
+ data=sinistres,family="poisson")
> ageD=data.frame(ageconducteur=seq(17,90),carburant="D",exposition=1)
> ageE=data.frame(ageconducteur=seq(17,90),carburant="E",exposition=1)
> yD=predict(reg,newdata=ageD,type="response")
> yE=predict(reg,newdata=ageE,type="response")
> lines(ageD$ageconducteur,yD,col="blue",lwd=2)
> lines(ageE$ageconducteur,yE,col="red",lwd=2)


is not constant any longer,

- Mixing additive and nonadditive
> reg=glm(nbre~bs(ageconducteur*(ageconducteur<50))+
+ bs(ageconducteur*(ageconducteur>=50))*carburant+offset(exposition),
+ data=sinistres,family="poisson")
> ageD=data.frame(ageconducteur=seq(17,90,by=.1),carburant="D",exposition=1)
> ageE=data.frame(ageconducteur=seq(17,90,by=.1),carburant="E",exposition=1)
> yD=predict(reg,newdata=ageD,type="response")
> yE=predict(reg,newdata=ageE,type="response")
> lines(ageD$ageconducteur,yD,col="blue",lwd=2)
> lines(ageE$ageconducteur,yE,col="red",lwd=2)









