tree.demo: Interactively demonstrate regression trees

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Interactively recursively partition a dataset to demonstrate regression trees.

Usage

1
tree.demo(x, y)

Arguments

x

The predictor variable.

y

The response variable.

Details

This function first creates a scatterplot of x and y and shows the residual sum of squares from fitting a horizontal line to the y-values.

Clicking anywhere on the graph will show an updated graph where the data is partitioned into 2 groups based on the x-value where you clicked with a horizontal line fit to each group (including showing the updated residual sum of squares). Clicking again will move the partitioning value based on the new click.

When you have found a good partitioning (reduces the RSS), right click and choose 'stop' and that partition will become fixed. Now you can click to do a second set of partions (breaking the data into 3 groups).

To finish the demo, right click and choose 'stop', then right click again and choose 'stop' again.

Value

A vector with the x-values of the cut points that you selected (sorted).

Author(s)

Greg Snow 538280@gmail.com

See Also

The rpart and tree packages

Examples

1
2
3
4
if(interactive()){
data('ethanol', package='lattice')
print(with(ethanol, tree.demo(E,NOx)))
}

Example output



TeachingDemos documentation built on April 14, 2020, 6:26 p.m.