weighted.mse {midr} | R Documentation |
Weighted Loss Functions
Description
weighted.mse()
, weighted.rmse()
, weighted.mae()
and weighted.medae()
compute the loss based on the differences of two numeric vectors or deviations from the mean of a numeric vector.
Usage
weighted.mse(x, y = NULL, w = NULL, ..., na.rm = FALSE)
weighted.rmse(x, y = NULL, w = NULL, ..., na.rm = FALSE)
weighted.mae(x, y = NULL, w = NULL, ..., na.rm = FALSE)
weighted.medae(x, y = NULL, w = NULL, ..., na.rm = FALSE)
Arguments
x |
a numeric vector. |
y |
an optional numeric vector. If passed, the loss is calculated for the differences between |
w |
a numeric vector of sample weights for each value in |
... |
optional parameters. |
na.rm |
logical. If |
Details
weighted.mse()
returns the mean square error, weighted.rmse()
returns the root mean square error, weighted.mae()
returns the mean absolute error, and weighted.medae()
returns the median absolute error between two weighted vectors x
and y
. If y
is not passed, these functions return the corresponding statistic based on the deviations from the mean of x
.
Value
weighted.mse()
(mean square error), weighted.rmse()
(root mean square error), weighted.mae()
(mean absolute error) and weighted.medae
(median absolute error) returns a single numeric value.
Examples
weighted.rmse(x = c(0, 10), y = c(0, 0), w = c(99, 1))
weighted.mae(x = c(0, 10), y = c(0, 0), w = c(99, 1))
weighted.medae(x = c(0, 10), y = c(0, 0), w = c(99, 1))
# compute uninterpreted rate
mid <- interpret(dist ~ speed, cars)
weighted.mse(cars$dist, predict(mid, cars)) / weighted.mse(cars$dist)
mid$ratio