O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – the construction of a regression tree

A regression tree is first built by using the rpart function. The getNode function is introduced, which helps in identifying the split node at each stage, and using it we build a regression tree and verify that we had the same tree as returned by the rpart function.

  1. Load the MASS library by using library(MASS).
  2. Create the regression tree for the logarithm (to the base 10) of perf as a function of the covariates explained earlier, and display the regression tree:
    cpus.ltrpart <- rpart(log10(perf)~syct+mmin+mmax+cach+chmin+chmax, data=cpus)
    plot(cpus.ltrpart); text(cpus.ltrpart)

    The regression tree will be indicated as follows:

    Figure 6: Regression tree for the "perf" of a CPU

    We will now define ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required