Exercise

# Evaluating a recursive partitioning model

Consider this model formula about runners' net times: `net ~ age + sex`

. The graphic shows the recursive partitioning for this formula. At the very bottom of the tree, in circles, are values for the response variable. At the very top is the *root*. (Modeling convention is to draw such trees upside down compared to the familiar botantical form, where the roots are at the bottom.)

Training an `rpart()`

model amounts to finding a set of divisions of the cases. Starting with all the cases at the root, the model divides them up into two groups: males on the left and females on the right. For males, a further split is made based on age: those younger than 50 and those 50 and over. Similarly, females are also split on age, with a cut-point of 46 years. So, for a 40 year-old female, the model output is 93 (with the same units as the response variable: minutes).

The `rpart()`

function uses a sensible default for when to stop dividing subgroups. You can exercise some control over this with the `cp`

argument.

Using the console, train a model with the same formula as used in the graphic, but with a value of `cp = 0.001`

. Display the model as a tree. Your commands will look like this:

```
model_2 <- rpart(___, data = Runners, cp = 0.001)
prp(model_2, type = 3)
```

The `prp()`

function plots the model as a tree. `type = 3`

is one of several available formats. In this model (with `cp = 0.001`

), what is the model output for a 58 year-old female?

Instructions

**50 XP**

##### Possible Answers

- 97 minutes
- 93 minutes
- 98 minutes
- 104 minutes