Skip to contents

Calculates the absolute percent error (ape)

Usage

calc_ape(backtest_summary)

Arguments

backtest_summary

results of backtest call

Value

The Absolute Percent 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 rmse with the scoringutils package
if (requireNamespace("scoringutils", quietly = TRUE)){
  calc_ape(btest)
}
#>                                   model        now horizon Strata_unified
#>                                  <char>     <Date>   <num>         <char>
#> 1: model_2025-05-16_19h28m23s_134101439 1990-06-11       0      No strata
#> 2: model_2025-05-16_19h28m23s_134101439 1990-06-18       0      No strata
#>         ape
#>       <num>
#> 1: 1.915833
#> 2: 3.137500