The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

RtForecastR walkthrough

library(RtForecastR)

Fit R_t and get a forecast

rt_forecast() estimates the filtered (real-time) and smoothed (retrospective) effective reproduction number from a case-count time series, and produces a genuine one-step-ahead out-of-sample forecast.

data(measles_cdmx)
fit <- rt_forecast(measles_cdmx$time, measles_cdmx$cases,
                    mean_GI = 11/7, var_GI = (4/7)^2)
fit
#> <rtforecast> 31 time points
#> Latest R_t (filtered): 0.722 (0.462-1.064) 
#> One-step-ahead forecast for time 48 :
#>   4.5 cases (95% CI: 1-10, 50% CI: 3-6)
plot(fit, which = "Rt")

plot(fit, which = "forecast")

Checking calibration

fit$predictions holds in-sample one-step-ahead predictions - a quick adequacy check:

mae(fit$predictions$cases, fit$predictions$pred_next)
#> [1] 9.38
coverage(fit$predictions$cases, fit$predictions$pred_lo95, fit$predictions$pred_hi95)
#> [1] 0.7666667

This is not genuine forecast validation, since the model has already seen nearby data. For that, run a rolling backtest: refit on data up to each week, forecast the next week, and score those forecasts against what was later observed with mae(), coverage() and wis() (using fit$forecast_quantiles). A complete worked backtest, with interpretation and cautions, is in the companion tutorial: https://github.com/rajsubediresearch/RtForecastR-tutorial.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.