I have understood that one commonly adds log(exposure) as an offset in the formula for GLMs, when dealing with poisson distributed rate data. I am dealing with insurance claim data where I want to predict the frequency i.e. #Claims/Exposure using a regression tree in R. My question is whether it is reasonable to add an log(exposure) offset here aswell? See code below for an example of what I would like to do.


tree <- rpart ( claims ~ age + ac + power + gas + brand + area + dens + ct
+ offset ( log ( expo )) ,
data = dat , method =" poisson ", parms = list ( shrink =1) ,
control = rpart . control ( xval =10 , minbucket =10000 , cp =0.001))

1 Answer 1


You can check out section 8 of the rpart vignette, and they write:

The y variable for Poisson partitioning may be a two column
matrix containing the observation time in column 1 and the number of events in column 2

So we can try that for an example:


dat = MASS::Insurance
mdl = rpart(as.matrix(dat[,c("Holders","Claims")]) ~ District + Group + Age,data=dat,method="poisson")

enter image description here

And we can check the fit versus the rate:


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.