


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















- The name “CART” is copyrighted by Salford Systems (San Diego) and the
- The R package “rpart” (“Recursive PARTitioning”) is open-source
_- Easier to interpret, visualize, explain to non-tehnicians
- Algorithm is “greedy” in the sense that at each node it finds the best local choice
_- Easy to overfit
de Jong’s goal: Estimate number of claims using accidents and sd as
predictors.
dat$L_accidents = log(dat$accidents) dat$L_population = log(dat$population) library(MASS) modelA <- glm.nb(claims ~ L_accidents + offset(L_population), data = dat) print(summary(modelA))
dat$claimrate = dat$claims / dat$population * 1000
modelB <- glm.nb(claims ~ L_accidents + sd + offset(L_population), data = dat) print(summary(modelB))
suppressPackageStartupMessages(library(gamlss)) modelJ <- gamlss(claims ~ L_accidents + sd + offset(L_population), sigma.formula = ~ sd, family = PIG(), data = dat)
print(summary(modelJ))
library(rpart) set.seed(12345) dtree <- rpart( claimrate ~ accidents + sd, data = dat )
print(dtree)
plot(dtree) text(dtree) title("decision tree")
- maximum number of levels
Many leaves have relatively few observations. Perhaps we overfit. Let’s prune
the tree.