| R2.ts | R Documentation |
Compute coefficient of determination (R-squared).
R2.ts(actual, prediction)
actual |
Numeric vector of observed values. |
prediction |
Numeric vector of predicted values. |
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.
Numeric scalar with R-squared.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.