Pseudo R-Squared
Returns (weighted) proportion of deviance explained, see reference below. For the mean-squared error as deviance, this equals the usual (weighted) R-squared. The higher, the better.
r_squared(actual, predicted, w = NULL, deviance_function = mse, ...)
actual |
Observed values. |
predicted |
Predicted values. |
w |
Optional case weights. |
deviance_function |
A positive (deviance) function taking four arguments: "actual", "predicted", "w" and "...". |
... |
Further arguments passed to |
For simplicity, the deviance gain is calculated regarding the null model derived from the actual values.
A numeric vector of length one.
Cohen, Jacob. et al. (2002). Applied Multiple Regression/Correlation Analysis for the Behavioral Sciences (3rd ed.). Routledge. ISBN 978-0805822236.
r_squared(1:10, c(1, 1:9)) r_squared(1:10, c(1, 1:9), w = rep(1, 10)) r_squared(1:10, c(1, 1:9), w = 1:10) r_squared(1:10, c(1, 1:9), deviance_function = deviance_normal) r_squared(0:2, c(0.1, 1, 2), deviance_function = deviance_poisson) r_squared(0:2, c(0.1, 1, 2), w = rep(1, 3), deviance_function = deviance_poisson) r_squared(0:2, c(0.1, 1, 2), deviance_function = deviance_tweedie, tweedie_p = 1) r_squared(0:2, c(0.1, 1, 2), w = rep(1, 3), deviance_function = deviance_tweedie, tweedie_p = 1) # respect to own deviance formula myTweedie <- function(actual, predicted, w = NULL, ...) { deviance_tweedie(actual, predicted, w, tweedie_p = 1.5, ...) } r_squared(1:10, c(1, 1:9), deviance_function = myTweedie)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.