Calculates mean absolute error (mae)
Arguments
- backtest_summary
results of
backtest()
Value
The Mean Absolute Error for each of the runs in backtest()
.
Examples
# Load the data
data(denguedat)
# Run a nowcast with very few iterations
# change to method = "sampling" when working and remove the iter = 10 (or set to iter = 2000)
now <- as.Date("1990-10-01")
ncast <- nowcast(denguedat, "onset_week", "report_week", now = now,
method = "optimization", seed = 2495624, iter = 10)
# Run a backtest for the model checking the model fit for two dates:
btest <- backtest(ncast, dates_to_test = c(as.Date("1990-06-11"), as.Date("1990-06-18")))
# Get the mean absolute error with the scoringutils package
if (requireNamespace("scoringutils", quietly = TRUE)){
calc_mae(btest)
}
#> model now horizon Strata_unified
#> <char> <Date> <num> <char>
#> 1: model_2025-05-16_19h28m25s_774518663 1990-06-11 0 No strata
#> 2: model_2025-05-16_19h28m25s_774518663 1990-06-18 0 No strata
#> mae
#> <num>
#> 1: 10.788
#> 2: 18.883