regression {MetricsWeighted}R Documentation

Regression Metrics

Description

Case-weighted versions of typical regression metrics:

Lower values mean better performance. Notable exception is prop_within(), where higher is better.

Usage

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, ...)

Arguments

actual

Observed values.

predicted

Predicted values.

w

Optional case weights.

...

Further arguments passed to weighted_mean() (no effect for medae()).

tol

Predictions in [\textrm{actual} \pm \textrm{tol}] count as "within" (only relevant for prop_within()).

tweedie_p

Tweedie power p \in \{0\} \cup [1, \infty).

Value

A numeric vector of length one.

Input range

The values of actual and predicted can be any real numbers, with the following exceptions:

References

Jorgensen, B. (1997). The Theory of Dispersion Models. Chapman & Hall/CRC. ISBN 978-0412997112.

Examples

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)


[Package MetricsWeighted version 1.0.3 Index]