mobForest (version 1.3.1)

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

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

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

Run this code
# NOT RUN {
# 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)
# }

Run the code above in your browser using DataLab