R2.ts: R2

R2.tsR Documentation

R2

Description

Compute coefficient of determination (R-squared).

Usage

R2.ts(actual, prediction)

Arguments

actual

Numeric vector of observed values.

prediction

Numeric vector of predicted values.

Details

R-squared is computed as 1 - SSE / SST, where SSE is the sum of squared residuals and SST is the total sum of squares around the mean of actual. If actual is constant, the statistic is undefined and NA_real_ is returned.

Interpretation:

  • R2 = 1 means perfect predictions.

  • R2 = 0 means the predictor is no better than always using mean(actual).

  • R2 < 0 means the predictions are worse than that mean baseline.

In forecasting, negative R2 values are common when the horizon is difficult or when a recursive predictor accumulates error over several future steps.

Value

Numeric scalar with R-squared.


tspredit documentation built on May 15, 2026, 1:07 a.m.