MSE0 = ave (ybar - mu)^2, MSE = ave (fhat - mu)^2 and R^2 = (MSE0 - MSE) /
MSE0 (ESL eqs 9.23-9.24).
Usage
morie_esl_test_r2(mu, fitted, ybar)
Arguments
- mu
True mean at the test points.
- fitted
Predictions at the test points.
- ybar
Training mean.
Value
Named list: mse, mse0, r2.
References
Hastie, Tibshirani & Friedman (2009), sec. 9.4.2.
Examples
morie_esl_test_r2(c(1, 2, 3), c(1.1, 1.8, 3.3), 2.1)$r2
#> [1] 0.9310345