regression | R Documentation |
Case-weighted versions of typical regression metrics:
mse()
: Mean-squared error.
rmse()
: Root-mean-squared error.
mae()
: Mean absolute error.
medae()
: Median absolute error.
mape()
: Mean absolute percentage error.
prop_within()
: Proportion of predictions that are within a given tolerance
around the actual values.
deviance_normal()
: Average (unscaled) normal deviance. Equals MSE, and also the
average Tweedie deviance with p = 0
.
deviance_poisson()
: Average (unscaled) Poisson deviance. Equals average Tweedie
deviance with p=1
.
deviance_gamma()
: Average (unscaled) Gamma deviance. Equals average Tweedie
deviance with p=2
.
deviance_tweedie()
: Average Tweedie deviance with parameter
p \in \{0\} \cup [1, \infty)
, see reference.
Lower values mean better performance. Notable exception is prop_within()
,
where higher is better.
mse(actual, predicted, w = NULL, ...)
rmse(actual, predicted, w = NULL, ...)
mae(actual, predicted, w = NULL, ...)
medae(actual, predicted, w = NULL, ...)
mape(actual, predicted, w = NULL, ...)
prop_within(actual, predicted, w = NULL, tol = 1, ...)
deviance_normal(actual, predicted, w = NULL, ...)
deviance_poisson(actual, predicted, w = NULL, ...)
deviance_gamma(actual, predicted, w = NULL, ...)
deviance_tweedie(actual, predicted, w = NULL, tweedie_p = 0, ...)
actual |
Observed values. |
predicted |
Predicted values. |
w |
Optional case weights. |
... |
Further arguments passed to |
tol |
Predictions in |
tweedie_p |
Tweedie power |
A numeric vector of length one.
The values of actual
and predicted
can be any real numbers, with the following
exceptions:
mape()
: Non-zero actual values.
deviance_poisson()
: Non-negative actual values and predictions.
deviance_gamma()
: Strictly positive actual values and predictions.
Jorgensen, B. (1997). The Theory of Dispersion Models. Chapman & Hall/CRC. ISBN 978-0412997112.
y <- 1:10
pred <- c(1:9, 12)
w <- 1:10
rmse(y, pred)
sqrt(mse(y, pred)) # Same
mae(y, pred)
mae(y, pred, w = w)
medae(y, pred, w = 1:10)
mape(y, pred)
prop_within(y, pred)
deviance_normal(y, pred)
deviance_poisson(y, pred)
deviance_gamma(y, pred)
deviance_tweedie(y, pred, tweedie_p = 0) # Normal
deviance_tweedie(y, pred, tweedie_p = 1) # Poisson
deviance_tweedie(y, pred, tweedie_p = 2) # Gamma
deviance_tweedie(y, pred, tweedie_p = 1.5, w = 1:10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.