compute.r2: Predictive accuracy estimates across trees for linear or...

Description Usage Arguments Value Examples

View source: R/compute.r2.R

Description

pseudo R-square (R2) computation - proportion of total variance in response variable explained by the tree model. The function takes observed and predicted responses as input arguments and computes pseudo-R2 to determine how well the tree model fits the given data.

Usage

1
compute.r2(response, predictions)

Arguments

response

A vector of actual response of outcome variable.

predictions

A vector of predictions for the same outcome variable

Value

Predictive accuracy estimates ranging between 0 and 1.

Examples

1
2
3
4
5
6
7
# This example explains 90% of the variance
response <- matrix(c(rep(0, 100), rep(10, 100)))
predictions <-
  matrix(nrow = 200, ncol = 3,
         data = c(rep(1, 100), rep(8, 100), rep(1, 100), rep(8, 100),
                  rep(1, 100), rep(8, 100)))
compute.r2(response, predictions)

mobForest documentation built on Aug. 1, 2019, 1:05 a.m.