Skip to contents

Introduction

This vignette briefly outlines the functionality of EpiSoon. To get started load the required packages.

  • Load the package (bsts for models, ggplot2 for plotting, and cowplot for theming)

Forecast Rts, score and plot

  • We use an example dataframe built into the package but this could be replaced with your own data.
EpiSoon::example_obs_rts
#>          rt       date
#> 1  2.490547 2020-03-01
#> 2  2.442588 2020-03-02
#> 3  2.402473 2020-03-03
#> 4  2.335572 2020-03-04
#> 5  2.266551 2020-03-05
#> 6  2.192293 2020-03-06
#> 7  2.146429 2020-03-07
#> 8  2.104371 2020-03-08
#> 9  2.059281 2020-03-09
#> 10 2.027134 2020-03-10
#> 11 2.014678 2020-03-11
#> 12 1.998946 2020-03-12
#> 13 1.968350 2020-03-13
#> 14 1.947376 2020-03-14
#> 15 1.906984 2020-03-15
#> 16 1.812842 2020-03-16
#> 17 1.718532 2020-03-17
#> 18 1.665646 2020-03-18
#> 19 1.639927 2020-03-19
#> 20 1.633795 2020-03-20
#> 21 1.682025 2020-03-21
#> 22 1.561653 2020-03-22
  • Fit a bsts model and produce a Rt forecast. Any appropriately wrapped model can be used (see bsts_model and fable_model for an examples).
rt_forecast <- forecast_rt(EpiSoon::example_obs_rts[1:10, ],
  model = function(...) {
    EpiSoon::bsts_model(model = function(ss, y) {
      bsts::AddAutoAr(ss, y = y, lags = 10)
    }, ...)
  },
  horizon = 21, samples = 10
)

rt_forecast
#> # A tibble: 210 × 4
#>    sample date          rt horizon
#>     <int> <date>     <dbl>   <int>
#>  1      1 2020-03-11  1.95       1
#>  2      2 2020-03-11  1.87       1
#>  3      3 2020-03-11  2.05       1
#>  4      4 2020-03-11  1.87       1
#>  5      5 2020-03-11  1.96       1
#>  6      6 2020-03-11  2.20       1
#>  7      7 2020-03-11  1.99       1
#>  8      8 2020-03-11  1.81       1
#>  9      9 2020-03-11  1.92       1
#> 10     10 2020-03-11  1.99       1
#> # ℹ 200 more rows
  • Score the forecast
rt_scores <- score_forecast(rt_forecast, EpiSoon::example_obs_rts)

rt_scores
#>           date horizon  bias         dss       crps overprediction
#>         <Date>   <int> <num>       <num>      <num>          <num>
#>  1: 2020-03-11       1  -0.6 -4.26687941 0.04192063              0
#>  2: 2020-03-12       2  -0.6 -3.02850406 0.07785852              0
#>  3: 2020-03-13       3  -0.6 -2.30966555 0.10380478              0
#>  4: 2020-03-14       4  -0.6 -1.77641556 0.10445634              0
#>  5: 2020-03-15       5  -0.4 -1.28192670 0.10950395              0
#>  6: 2020-03-16       6  -0.2 -0.88634354 0.13719163              0
#>  7: 2020-03-17       7  -0.2 -0.53970598 0.11916345              0
#>  8: 2020-03-18       8   0.0 -0.26053507 0.11733866              0
#>  9: 2020-03-19       9   0.0  0.06612982 0.11786249              0
#> 10: 2020-03-20      10  -0.4  0.38330523 0.15899679              0
#> 11: 2020-03-21      11  -0.4  0.59570852 0.19924557              0
#> 12: 2020-03-22      12  -0.2  0.83983548 0.17020136              0
#>     underprediction dispersion   log_score        mad   ae_median      se_mean
#>               <num>      <num>       <num>      <num>       <num>        <num>
#>  1:     0.021262509 0.02065812 -1.09398992 0.08995963 0.056398410 0.0027938743
#>  2:     0.043143145 0.03471537 -0.23501059 0.13332185 0.091215633 0.0073746656
#>  3:     0.061318072 0.04248671  0.07029008 0.14297986 0.132407802 0.0098568424
#>  4:     0.027088236 0.07736810 -0.13236855 0.22651493 0.146235082 0.0099815360
#>  5:     0.021912568 0.08759138  0.02974890 0.33013908 0.117221454 0.0052856962
#>  6:     0.019146931 0.11804470  0.30112305 0.43517231 0.148961189 0.0003712525
#>  7:     0.001745678 0.11741777  0.23579815 0.45209167 0.022941969 0.0031058838
#>  8:     0.000000000 0.11733866  0.17107458 0.39142197 0.042827480 0.0106513393
#>  9:     0.000000000 0.11786249  0.08867359 0.39513915 0.006737829 0.0232891476
#> 10:     0.032783719 0.12621307  0.21859328 0.41619226 0.130263976 0.0125321098
#> 11:     0.047152021 0.15209355  0.50025344 0.56261141 0.211715315 0.0117916476
#> 12:     0.013714110 0.15648725  0.42448296 0.52268099 0.094946098 0.0861271392
  • Summarise the forecast scores
summarise_scores(rt_scores)
#> # A tibble: 10 × 8
#>    score             bottom    lower   median    mean   upper    top     sd
#>    <chr>              <dbl>    <dbl>    <dbl>   <dbl>   <dbl>  <dbl>  <dbl>
#>  1 ae_median        0.0112   0.0530   0.106    0.100   0.136  0.194  0.0597
#>  2 bias            -0.6     -0.6     -0.4     -0.35   -0.2    0      0.228 
#>  3 crps             0.0518   0.104    0.118    0.121   0.143  0.191  0.0417
#>  4 dispersion       0.0245   0.0686   0.117    0.0974  0.120  0.155  0.0450
#>  5 dss             -3.93    -1.91    -0.713   -1.04    0.145  0.773  1.56  
#>  6 log_score       -0.858   -0.0108   0.130    0.0482  0.252  0.479  0.417 
#>  7 mad              0.102    0.206    0.393    0.342   0.439  0.552  0.158 
#>  8 overprediction   0        0        0        0       0      0      0     
#>  9 se_mean          0.00104  0.00474  0.00992  0.0153  0.0120 0.0688 0.0231
#> 10 underprediction  0        0.0107   0.0216   0.0241  0.0354 0.0574 0.0195
  • Summarise the forecast
summarised_rt_forecast <- summarise_forecast(rt_forecast)

summarised_rt_forecast
#> # A tibble: 21 × 9
#>    date       horizon median  mean    sd bottom lower upper   top
#>    <date>       <int>  <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>
#>  1 2020-03-11       1   1.96  1.96 0.110  1.81   1.87  1.99  2.20
#>  2 2020-03-12       2   1.91  1.91 0.212  1.62   1.81  1.94  2.37
#>  3 2020-03-13       3   1.84  1.87 0.314  1.44   1.68  1.88  2.60
#>  4 2020-03-14       4   1.80  1.85 0.420  1.37   1.62  1.92  2.86
#>  5 2020-03-15       5   1.79  1.83 0.550  1.16   1.61  2.06  3.17
#>  6 2020-03-16       6   1.66  1.79 0.676  1.07   1.50  2.05  3.47
#>  7 2020-03-17       7   1.70  1.77 0.803  0.899  1.37  1.90  3.82
#>  8 2020-03-18       8   1.62  1.77 0.919  0.805  1.37  1.90  4.17
#>  9 2020-03-19       9   1.63  1.79 1.08   0.707  1.48  1.91  4.66
#> 10 2020-03-20      10   1.50  1.75 1.27   0.491  1.39  1.92  5.15
#> # ℹ 11 more rows
  • Plot the forecast against observed data
plot_forecast(summarised_rt_forecast, EpiSoon::example_obs_rts)

Forecast cases, score and plot

  • Forecasting cases requires the observed cases on which the observed Rt estimates were based
EpiSoon::example_obs_cases
#> # A tibble: 63 × 2
#>    cases date      
#>    <dbl> <date>    
#>  1     1 2020-01-20
#>  2     0 2020-01-21
#>  3     1 2020-01-22
#>  4     0 2020-01-23
#>  5     0 2020-01-24
#>  6     0 2020-01-25
#>  7     1 2020-01-26
#>  8     0 2020-01-27
#>  9     0 2020-01-28
#> 10     0 2020-01-29
#> # ℹ 53 more rows
  • It also requires an assumption to be made about the serial interval (defined using probability distribution).
EpiSoon::example_serial_interval
#>         1    2    3    4    5    6    7    8    9   10   11   12   14 
#> 0.00 0.03 0.25 0.17 0.09 0.15 0.13 0.05 0.05 0.03 0.02 0.01 0.01 0.01
  • Forecast cases (using the case data on which the observed Rt estimates were based)
case_forecast <- forecast_cases(EpiSoon::example_obs_cases, rt_forecast,
  serial_interval = EpiSoon::example_serial_interval
)

case_forecast
#>      sample       date cases horizon
#>       <num>     <Date> <int>   <int>
#>   1:      1 2020-03-11   147       1
#>   2:      1 2020-03-12   177       2
#>   3:      1 2020-03-13   213       3
#>   4:      1 2020-03-14   261       4
#>   5:      1 2020-03-15   314       5
#>  ---                                
#> 206:     10 2020-03-27   507      17
#> 207:     10 2020-03-28   569      18
#> 208:     10 2020-03-29   491      19
#> 209:     10 2020-03-30   610      20
#> 210:     10 2020-03-31   659      21
  • Score the cases forecast
case_scores <- score_case_forecast(case_forecast, EpiSoon::example_obs_cases)

case_scores
#>           date horizon  bias       dss   crps overprediction underprediction
#>         <Date>   <int> <num>     <num>  <num>          <num>           <num>
#>  1: 2020-03-11       1   0.0  4.904574   2.29            0.0    0.000000e+00
#>  2: 2020-03-12       2  -0.4  6.191340   6.27            0.0    1.000000e+00
#>  3: 2020-03-13       3  -0.2  7.810147   7.93            0.0    4.000000e-01
#>  4: 2020-03-14       4   0.0  8.622401  14.57            0.0   -5.329071e-15
#>  5: 2020-03-15       5   0.2  9.532459  18.47            0.8    0.000000e+00
#>  6: 2020-03-16       6   0.6 10.782962  30.23            4.6    0.000000e+00
#>  7: 2020-03-17       7   0.2 11.851515  51.18            8.4    0.000000e+00
#>  8: 2020-03-18       8   0.0 12.777103  57.56            0.0    0.000000e+00
#>  9: 2020-03-19       9   0.0 13.855333  83.82            0.0    0.000000e+00
#> 10: 2020-03-20      10  -0.2 14.969060 116.87            0.0    1.000000e+00
#> 11: 2020-03-21      11  -0.2 16.054158 195.96            0.0    2.130000e+01
#> 12: 2020-03-22      12   0.4 17.322897 304.86           24.4    0.000000e+00
#>     dispersion log_score      mad ae_median    se_mean
#>          <num>     <num>    <num>     <num>      <num>
#>  1:       2.29  3.042475   5.9304       0.0       1.21
#>  2:       5.27  4.292595  24.4629       4.5       0.25
#>  3:       7.53  4.395320  24.4629       4.0      53.29
#>  4:      14.57  5.014852  40.7715      12.5       8.41
#>  5:      17.67  5.240384  54.8562       9.0     858.49
#>  6:      25.63  5.523580  95.6277      21.5    7140.25
#>  7:      42.78  6.094497 157.1556      51.5   18550.44
#>  8:      57.56  6.241611 208.3053       1.5   36404.64
#>  9:      83.82  6.459608 251.3007      16.5   92842.09
#> 10:     115.87  6.682583 246.1116      19.5  277412.89
#> 11:     174.66  7.022725 335.0676     156.0  685087.29
#> 12:     280.46  7.118067 470.7255     144.5 3870269.29
  • Summarise the cases scores
summarise_scores(case_scores)
#> # A tibble: 10 × 8
#>    score              bottom lower   median        mean    upper     top      sd
#>    <chr>               <dbl> <dbl>    <dbl>       <dbl>    <dbl>   <dbl>   <dbl>
#>  1 ae_median        4.12e- 1  4.38    14.5      36.8     2.9 e+1 1.53e+2 5.48e+1
#>  2 bias            -3.45e- 1 -0.2      0         0.0333  2   e-1 5.45e-1 2.81e-1
#>  3 crps             3.38e+ 0 12.9     40.7      74.2     9.21e+1 2.75e+2 9.22e+1
#>  4 dispersion       3.11e+ 0 12.8     34.2      69.0     9.18e+1 2.51e+2 8.47e+1
#>  5 dss              5.26e+ 0  8.42    11.3      11.2     1.41e+1 1.70e+1 3.94e+0
#>  6 log_score        3.39e+ 0  4.86     5.81      5.59    6.52e+0 7.09e+0 1.25e+0
#>  7 mad              1.10e+ 1 36.7    126.      160.      2.47e+2 4.33e+2 1.46e+2
#>  8 overprediction   0         0        0         3.18    1.75e+0 2.00e+1 7.17e+0
#>  9 se_mean          5.14e- 1 42.1  12845.   415719.      1.39e+5 2.99e+6 1.11e+6
#> 10 underprediction -3.86e-15  0        0         1.98    5.5 e-1 1.57e+1 6.10e+0
  • Summarise the cases forecast
summarised_case_forecast <- summarise_case_forecast(case_forecast)

summarised_case_forecast
#> # A tibble: 21 × 9
#>    date       horizon median  mean     sd bottom lower upper   top
#>    <date>       <int>  <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl> <dbl>
#>  1 2020-03-11       1   167   166.   12.2    147   163   171   188
#>  2 2020-03-12       2   190.  194.   23.3    169   169   190   240
#>  3 2020-03-13       3   204   215.   51.8    142   180   213   337
#>  4 2020-03-14       4   238.  254.   78.5    160   208   262   445
#>  5 2020-03-15       5   282   302.  120.     177   242   315   610
#>  6 2020-03-16       6   288.  350.  212.     139   272   373   908
#>  7 2020-03-17       7   348.  432.  366.     143   205   395  1424
#>  8 2020-03-18       8   342.  534.  592.     142   142   354  2172
#>  9 2020-03-19       9   383   704. 1024.     102   310   559  3575
#> 10 2020-03-20      10   434.  981. 1788.      94   277   603  6032
#> # ℹ 11 more rows
  • Plot the forecast against observed case data
plot_forecast(summarised_case_forecast, EpiSoon::example_obs_cases)

Use iterative fitting to explore a forecast

  • To explore the quality of a models forecast it can help to iteratively forecast from each available data point. This is supported in EpiSoon using the following:
it_rt_forecast <- iterative_rt_forecast(EpiSoon::example_obs_rts,
  model = function(...) {
    EpiSoon::bsts_model(model = function(ss, y) {
      bsts::AddAutoAr(ss, y = y, lags = 10)
    }, ...)
  },
  horizon = 7, samples = 10, min_points = 4
)

it_rt_forecast
#> # A tibble: 1,260 × 5
#>    forecast_date sample date          rt horizon
#>    <chr>          <int> <date>     <dbl>   <int>
#>  1 2020-03-05         1 2020-03-06  2.19       1
#>  2 2020-03-05         2 2020-03-06  2.31       1
#>  3 2020-03-05         3 2020-03-06  2.24       1
#>  4 2020-03-05         4 2020-03-06  2.08       1
#>  5 2020-03-05         5 2020-03-06  2.28       1
#>  6 2020-03-05         6 2020-03-06  2.15       1
#>  7 2020-03-05         7 2020-03-06  2.16       1
#>  8 2020-03-05         8 2020-03-06  2.26       1
#>  9 2020-03-05         9 2020-03-06  2.21       1
#> 10 2020-03-05        10 2020-03-06  2.23       1
#> # ℹ 1,250 more rows
  • We can then iteratively forecast cases using the following:
it_cases_forecast <- iterative_case_forecast(
  it_fit_samples = it_rt_forecast,
  cases = EpiSoon::example_obs_cases,
  serial_interval = EpiSoon::example_serial_interval
)

it_cases_forecast
#>       forecast_date sample       date cases horizon
#>              <char>  <num>     <Date> <int>   <int>
#>    1:    2020-03-05      1 2020-03-06    86       1
#>    2:    2020-03-05      1 2020-03-07    76       2
#>    3:    2020-03-05      1 2020-03-08    82       3
#>    4:    2020-03-05      1 2020-03-09    81       4
#>    5:    2020-03-05      1 2020-03-10    66       5
#>   ---                                              
#> 1256:    2020-03-22     10 2020-03-25   669       3
#> 1257:    2020-03-22     10 2020-03-26   588       4
#> 1258:    2020-03-22     10 2020-03-27   672       5
#> 1259:    2020-03-22     10 2020-03-28   584       6
#> 1260:    2020-03-22     10 2020-03-29   621       7
  • All functionality shown above is also supported for iterative forecasting.

Evaluate a model

In real world use we are likely to want to evaluate a model by iteratively forecasting Rts and cases, summarising these forecasts, scoring them and then returning them in a sensible format. These steps are all contained in the evaluate_model function.

model_eval <- evaluate_model(EpiSoon::example_obs_rts,
  EpiSoon::example_obs_cases,
  model = function(...) {
    EpiSoon::bsts_model(model = function(ss, y) {
      bsts::AddAutoAr(ss, y = y, lags = 10)
    }, ...)
  },
  horizon = 21, samples = 10,
  serial_interval = EpiSoon::example_serial_interval
)

model_eval
#> $forecast_rts
#> # A tibble: 399 × 10
#>    forecast_date date       horizon median  mean    sd bottom lower upper   top
#>    <chr>         <date>       <int>  <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>
#>  1 2020-03-04    2020-03-05       1   2.30  2.26 0.182 1.75    2.26  2.31  2.40
#>  2 2020-03-04    2020-03-06       2   2.30  2.21 0.313 1.36    2.17  2.32  2.45
#>  3 2020-03-04    2020-03-07       3   2.27  2.12 0.508 0.715   2.15  2.29  2.48
#>  4 2020-03-04    2020-03-08       4   2.23  2.03 0.716 0.0474  2.05  2.26  2.53
#>  5 2020-03-04    2020-03-09       5   2.17  2.01 0.733 0       2.01  2.29  2.57
#>  6 2020-03-04    2020-03-10       6   2.14  1.98 0.732 0       1.94  2.23  2.60
#>  7 2020-03-04    2020-03-11       7   2.10  1.97 0.740 0       1.93  2.24  2.67
#>  8 2020-03-04    2020-03-12       8   2.05  1.97 0.743 0       1.82  2.18  2.64
#>  9 2020-03-04    2020-03-13       9   2.01  1.94 0.753 0       1.75  2.11  2.68
#> 10 2020-03-04    2020-03-14      10   2.00  1.92 0.763 0       1.69  2.07  2.72
#> # ℹ 389 more rows
#> 
#> $rt_scores
#>      forecast_date       date horizon  bias        dss       crps
#>             <char>     <Date>   <int> <num>      <num>      <num>
#>   1:    2020-03-04 2020-03-05       1   0.6 -3.5066176 0.02435233
#>   2:    2020-03-04 2020-03-06       2   0.6 -2.4250734 0.06289341
#>   3:    2020-03-04 2020-03-07       3   0.6 -1.4573688 0.07011137
#>   4:    2020-03-04 2020-03-08       4   0.4 -0.7617366 0.09159354
#>   5:    2020-03-04 2020-03-09       5   0.4 -0.7210385 0.10343993
#>  ---                                                             
#> 167:    2020-03-19 2020-03-21       2  -0.8 -1.1852827 0.08661630
#> 168:    2020-03-19 2020-03-22       3  -0.4 -5.8838246 0.02126621
#> 169:    2020-03-20 2020-03-21       1  -0.6 -5.3199530 0.02384127
#> 170:    2020-03-20 2020-03-22       2   0.0 -3.0472682 0.04651778
#> 171:    2020-03-21 2020-03-22       1   1.0 -3.2176047 0.05631644
#>      overprediction underprediction dispersion  log_score        mad  ae_median
#>               <num>           <num>      <num>      <num>      <num>      <num>
#>   1:     0.00671177     0.000000000 0.01764056 -1.7331282 0.05315893 0.03279765
#>   2:     0.02764666     0.000000000 0.03524676 -0.7448557 0.12627796 0.10675989
#>   3:     0.02621642     0.000000000 0.04389495 -0.7759505 0.16299330 0.12006801
#>   4:     0.03394458     0.000000000 0.05764896 -0.4893418 0.18700899 0.12456683
#>   5:     0.03405054     0.000000000 0.06938939 -0.2917767 0.20955012 0.11038333
#>  ---                                                                           
#> 167:     0.00000000     0.078739278 0.00787702 -0.4443722 0.02462206 0.11687595
#> 168:     0.00000000     0.007076893 0.01418932 -1.6517020 0.04878211 0.03965038
#> 169:     0.00000000     0.009532557 0.01430871 -1.6557728 0.05489284 0.03325382
#> 170:     0.00000000     0.000000000 0.04651778 -0.7506340 0.14348333 0.05736374
#> 171:     0.04296477     0.000000000 0.01335166 -1.0835648 0.03210339 0.06150011
#>           se_mean
#>             <num>
#>   1: 8.510265e-05
#>   2: 3.557970e-04
#>   3: 6.197036e-04
#>   4: 5.027910e-03
#>   5: 2.622510e-03
#>  ---             
#> 167: 1.175799e-02
#> 168: 7.441686e-04
#> 169: 8.643219e-04
#> 170: 5.933604e-03
#> 171: 6.919049e-03
#> 
#> $forecast_cases
#> # A tibble: 171 × 10
#>    forecast_date date       horizon median  mean     sd bottom lower upper   top
#>    <chr>         <date>       <int>  <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl> <dbl>
#>  1 2020-03-04    2020-03-05       1   66    67.2   8.11     56    63    69    85
#>  2 2020-03-04    2020-03-06       2   87.5  83.7  12.6      50    87    93    93
#>  3 2020-03-04    2020-03-07       3  104    95.7  25.2      30    97   110   120
#>  4 2020-03-04    2020-03-08       4  134.  123.   45.3       1   125   145   159
#>  5 2020-03-04    2020-03-09       5  149   144.   55.2       0   129   154   199
#>  6 2020-03-04    2020-03-10       6  190.  179.   70.4       0   173   219   249
#>  7 2020-03-04    2020-03-11       7  242.  222.   92.1       0   196   266   338
#>  8 2020-03-04    2020-03-12       8  264.  257.  109.        0   260   353   382
#>  9 2020-03-04    2020-03-13       9  336.  317.  151.        0   241   381   544
#> 10 2020-03-04    2020-03-14      10  374.  388.  203.        0   234   385   741
#> # ℹ 161 more rows
#> 
#> $case_scores
#>      sample forecast_date       date horizon  bias       dss   crps
#>      <char>        <char>     <Date>   <int> <num>     <num>  <num>
#>   1:      1    2020-03-04 2020-03-05       1   0.4  4.378420   1.92
#>   2:      1    2020-03-04 2020-03-06       2   0.8  5.761836  10.03
#>   3:      1    2020-03-04 2020-03-07       3   0.6  6.455313   8.53
#>   4:      1    2020-03-04 2020-03-08       4   0.8  7.763714  22.43
#>   5:      1    2020-03-04 2020-03-09       5   0.8  8.196747  26.79
#>  ---                                                               
#> 167:      1    2020-03-19 2020-03-21       2  -1.0 18.814871 102.84
#> 168:      1    2020-03-19 2020-03-22       3   1.0 27.170116 139.98
#> 169:      1    2020-03-20 2020-03-21       1  -1.0 16.711055  75.32
#> 170:      1    2020-03-20 2020-03-22       2   1.0 15.009446 153.53
#> 171:      1    2020-03-21 2020-03-22       1   1.0 49.980404 173.05
#>      overprediction underprediction dispersion log_score     mad ae_median
#>               <num>           <num>      <num>     <num>   <num>     <num>
#>   1:            0.2             0.0       1.72  2.810788  4.4478       3.0
#>   2:            8.4             0.0       1.63  5.814449  6.6717      14.5
#>   3:            4.6             0.0       3.93  4.242292  9.6369      16.0
#>   4:           17.4             0.0       5.03  5.729672 14.8260      32.5
#>   5:           20.8             0.0       5.99  6.082825 19.2738      33.0
#>  ---                                                                      
#> 167:            0.0            96.5       6.34 24.549517 20.7564     110.5
#> 168:          131.1             0.0       8.88 14.136924 40.7715     159.5
#> 169:            0.0            68.5       6.82  9.908901 27.4281      92.5
#> 170:          138.7             0.0      14.83  9.820728 58.5627     186.0
#> 171:          163.5             0.0       9.55 37.218259 24.4629     178.5
#>       se_mean
#>         <num>
#>   1:    17.64
#>   2:   114.49
#>   3:    59.29
#>   4:   445.21
#>   5:   767.29
#>  ---         
#> 167: 14665.21
#> 168: 25632.01
#> 169:  8372.25
#> 170: 37094.76
#> 171: 35494.56
  • All functionality outlined above can be applied to this output but a special plotting function (plot_forecast_evaluation) is also provided. First evaluate the Rt forecast against observed values.
plot_forecast_evaluation(model_eval$forecast_rts,
  EpiSoon::example_obs_rts,
  horizon_to_plot = 7
)

  • Then evaluate forecast cases against observed values.
plot_forecast_evaluation(model_eval$forecast_cases,
  EpiSoon::example_obs_cases,
  horizon_to_plot = 7
)

Wrapper functions

EpiSoon provides several wrapper functions (compare_models and compare_timeseries). These both wrap evaluate_model and can be used to rapidly explore several forecasting models (compare_models) against multiple time series (compare_timeseries). All lower level summary and plotting functions can be then used with the output of these wrappers to explore the results. See the function documentation for further details.

Supporting generic modelling packages

EpiSoon supports the use of generic forecasting models if they are used in a wrapper that accepts a standardised set of inputs and outputs its forecast in the form the package expects. Examples of model wrappers are those for the bsts and fable packages (bsts_model and fable_model). See the examples and documentation for fable_model for further details.