tree.demo | R Documentation |
Interactively recursively partition a dataset to demonstrate regression trees.
tree.demo(x, y)
x |
The predictor variable. |
y |
The response variable. |
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.
A vector with the x-values of the cut points that you selected (sorted).
Greg Snow 538280@gmail.com
The rpart and tree packages
if(interactive()){
data('ethanol', package='lattice')
print(with(ethanol, tree.demo(E,NOx)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.