mase | R Documentation |
Calculate the mean absolute scaled error. This metric is scale independent and symmetric. It is generally used for comparing forecast error in time series settings. Due to the time series nature of this metric, it is necessary to order observations in ascending order by time.
mase(data, ...)
## S3 method for class 'data.frame'
mase(
data,
truth,
estimate,
m = 1L,
mae_train = NULL,
na_rm = TRUE,
case_weights = NULL,
...
)
mase_vec(
truth,
estimate,
m = 1L,
mae_train = NULL,
na_rm = TRUE,
case_weights = NULL,
...
)
data |
A |
... |
Not currently used. |
truth |
The column identifier for the true results
(that is |
estimate |
The column identifier for the predicted
results (that is also |
m |
An integer value of the number of lags used to calculate the
in-sample seasonal naive error. The default is used for non-seasonal time
series. If each observation was at the daily level and the data showed weekly
seasonality, then |
mae_train |
A numeric value which allows the user to provide the
in-sample seasonal naive mean absolute error. If this value is not provided,
then the out-of-sample seasonal naive mean absolute error will be calculated
from |
na_rm |
A |
case_weights |
The optional column identifier for case weights. This
should be an unquoted column name that evaluates to a numeric column in
|
mase()
is different from most numeric metrics. The original implementation
of mase()
calls for using the in-sample naive mean absolute error to
compute scaled errors with. It uses this instead of the out-of-sample error
because there is a chance that the out-of-sample error cannot be computed
when forecasting a very short horizon (i.e. the out of sample size is only
1 or 2). However, yardstick
only knows about the out-of-sample truth
and
estimate
values. Because of this, the out-of-sample error is used in the
computation by default. If the in-sample naive mean absolute error is
required and known, it can be passed through in the mae_train
argument
and it will be used instead. If the in-sample data is available, the
naive mean absolute error can easily be computed with
mae(data, truth, lagged_truth)
.
A tibble
with columns .metric
, .estimator
,
and .estimate
and 1 row of values.
For grouped data frames, the number of rows returned will be the same as the number of groups.
For mase_vec()
, a single numeric
value (or NA
).
Alex Hallam
Rob J. Hyndman (2006). ANOTHER LOOK AT FORECAST-ACCURACY METRICS FOR INTERMITTENT DEMAND. Foresight, 4, 46.
Other numeric metrics:
ccc()
,
huber_loss_pseudo()
,
huber_loss()
,
iic()
,
mae()
,
mape()
,
mpe()
,
msd()
,
poisson_log_loss()
,
rmse()
,
rpd()
,
rpiq()
,
rsq_trad()
,
rsq()
,
smape()
Other accuracy metrics:
ccc()
,
huber_loss_pseudo()
,
huber_loss()
,
iic()
,
mae()
,
mape()
,
mpe()
,
msd()
,
poisson_log_loss()
,
rmse()
,
smape()
# Supply truth and predictions as bare column names
mase(solubility_test, solubility, prediction)
library(dplyr)
set.seed(1234)
size <- 100
times <- 10
# create 10 resamples
solubility_resampled <- bind_rows(
replicate(
n = times,
expr = sample_n(solubility_test, size, replace = TRUE),
simplify = FALSE
),
.id = "resample"
)
# Compute the metric by group
metric_results <- solubility_resampled %>%
group_by(resample) %>%
mase(solubility, prediction)
metric_results
# Resampled mean estimate
metric_results %>%
summarise(avg_estimate = mean(.estimate))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.