# log-offset in rpart regression tree

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.

CODE

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


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:

library(rpart)
library(rpart.plot)

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


And we can check the fit versus the rate:

plot(predict(fit),dat$$Claims/dat$$Holders)