## S3 method for class 'numeric'
rrmse(actual, predicted, normalization = 1L, ...)
## S3 method for class 'numeric'
weighted.rrmse(actual, predicted, w, normalization = 1L, ...)
rrmse(...)
weighted.rrmse(...)
relative root mean squared error
rrmse.numeric | R Documentation |
Description
The rrmse()
-function computes the Relative Root Mean Squared Error between the observed and predicted <numeric>
vectors. The weighted.rrmse()
function computes the weighted Relative Root Mean Squared Error.
Usage
Arguments
actual
|
A |
predicted
|
A |
normalization
|
A |
…
|
Arguments passed into other methods. |
w
|
A |
Value
A <numeric>
vector of length 1.
Calculation
The metric is calculated as,
\[ \frac{RMSE}{\gamma} \]
Where \(\gamma\) is the normalization factor.
Examples
# 1) fit a linear
# regression
<- lm(
model ~ .,
mpg data = mtcars
)
# 1.1) define actual
# and predicted values
# to measure performance
<- mtcars$mpg
actual <- fitted(model)
predicted
# 2) evaluate in-sample model
# performance using Relative Root Mean Squared Error (RRMSE)
cat(
"IQR Relative Root Mean Squared Error", rrmse(
actual = actual,
predicted = predicted,
normalization = 2
),"IQR Relative Root Mean Squared Error (weighted)", weighted.rrmse(
actual = actual,
predicted = predicted,
w = mtcars$mpg/mean(mtcars$mpg),
normalization = 2
),sep = "\n"
)