epi_measures_pipeline.Rd
Estimate time-varying measures and forecast
epi_measures_pipeline( nowcast = NULL, generation_times = NULL, min_est_date = NULL, gt_samples = 1, rt_samples = 5, rt_windows = 7, rate_window = 7, rt_prior = NULL, forecast_model = NULL, horizon = 0, verbose = TRUE )
nowcast | A nowcast as produced by |
---|---|
generation_times | A matrix with columns representing samples and rows representing the probability of the generation timebeing on that day. |
min_est_date | Date to begin estimation. |
gt_samples | Numeric, the number of samples to take from the generaiton times supplied |
rt_samples | Numeric, the number of samples to take from the estimated R distribution for each time point. |
rt_windows | Numeric vector, windows over which to estimate time-varying R. The best performing window will be selected per serial interval sample by default (based on which window best forecasts current cases). |
rate_window | Numeric, the window to use to estimate the rate of spread. |
rt_prior | A list defining the reproduction number prior containing the mean ( |
forecast_model | An uninitialised bsts model passed to |
horizon | Numeric, defaults to 0. The horizon over which to forecast Rts and cases. |
verbose | Logical, defaults to |
A list of data frames containing reproduction number estimates, case forecasts, rate of growth estimates both summarised and raw.
## Construct example distributions ## reporting delay dist delay_dist <- EpiNow::lognorm_dist_def(mean = 3, mean_sd = 1, sd = 3, sd_sd = 1, max_value = 30, samples = 1) ## incubation delay dist incubation_dist <- delay_dist ## Uses example case vector from EpiSoon cases <- data.table::setDT(EpiSoon::example_obs_cases) cases <- cases[, `:=`(confirm = as.integer(cases), import_status = "local")] ## Basic nowcast nowcast <- nowcast_pipeline(reported_cases = cases, target_date = max(cases$date), delay_defs = delay_dist, incubation_defs = incubation_dist) ## Estimate parameters estimates <- epi_measures_pipeline(nowcast[type %in% "infection_upscaled"], generation_times = EpiNow::covid_generation_times, rt_prior = list(mean_prior = 2.6, std_prior = 2))#>#>#>#>#> #>#>#> #>estimates#> $R0 #> type date rt_type bottom top lower #> 1: infection_upscaled 2020-01-08 nowcast 1.1631424 2.732865 1.1631424 #> 2: infection_upscaled 2020-01-09 nowcast 1.0492720 2.735856 2.1404290 #> 3: infection_upscaled 2020-01-10 nowcast 0.4395361 2.885327 0.5828654 #> 4: infection_upscaled 2020-01-11 nowcast 1.0720950 2.397118 1.0720950 #> 5: infection_upscaled 2020-01-12 nowcast 0.6369509 3.315359 0.6369509 #> 6: infection_upscaled 2020-01-13 nowcast 1.4827801 2.021324 1.4925594 #> 7: infection_upscaled 2020-01-14 nowcast 0.8659460 1.963255 1.2424919 #> 8: infection_upscaled 2020-01-15 nowcast 0.9709070 2.125531 0.9709070 #> 9: infection_upscaled 2020-01-16 nowcast 0.5401842 1.411443 1.1403739 #> 10: infection_upscaled 2020-01-17 nowcast 1.0169078 3.642345 1.0169078 #> 11: infection_upscaled 2020-01-18 nowcast 0.4347307 1.748744 0.4347307 #> 12: infection_upscaled 2020-01-19 nowcast 0.8767031 1.345919 1.0473065 #> 13: infection_upscaled 2020-01-20 nowcast 0.8057734 1.843686 0.8057734 #> 14: infection_upscaled 2020-01-21 nowcast 1.1978847 2.278515 1.8342091 #> 15: infection_upscaled 2020-01-22 nowcast 1.3514182 3.008245 1.3514182 #> 16: infection_upscaled 2020-01-23 nowcast 1.1298546 2.236034 1.3587778 #> 17: infection_upscaled 2020-01-24 nowcast 1.5458786 2.798829 1.5458786 #> 18: infection_upscaled 2020-01-25 nowcast 1.5206578 2.427841 1.6109979 #> 19: infection_upscaled 2020-01-26 nowcast 1.3455440 2.234988 2.0977190 #> 20: infection_upscaled 2020-01-27 nowcast 1.7569381 3.162429 2.0998206 #> 21: infection_upscaled 2020-01-28 nowcast 2.0394205 2.470876 2.2724398 #> 22: infection_upscaled 2020-01-29 nowcast 1.8325170 3.442391 1.8325170 #> 23: infection_upscaled 2020-01-30 nowcast 1.9680155 2.479604 1.9680155 #> 24: infection_upscaled 2020-01-31 nowcast 1.5142416 2.201536 1.7639043 #> 25: infection_upscaled 2020-02-01 nowcast 1.4774852 2.152972 1.7116708 #> 26: infection_upscaled 2020-02-02 nowcast 1.2374670 2.015521 1.6060546 #> 27: infection_upscaled 2020-02-03 nowcast 1.4309675 1.922489 1.4309675 #> 28: infection_upscaled 2020-02-04 nowcast 1.5700761 1.847998 1.7233534 #> 29: infection_upscaled 2020-02-05 nowcast 1.4365139 1.821215 1.5874035 #> 30: infection_upscaled 2020-02-06 nowcast 1.3481502 1.728245 1.3481502 #> 31: infection_upscaled 2020-02-07 nowcast 1.2770949 1.485900 1.3923296 #> 32: infection_upscaled 2020-02-08 nowcast 1.2336897 1.455042 1.3664692 #> 33: infection_upscaled 2020-02-09 nowcast 1.3505021 1.583305 1.4646811 #> 34: infection_upscaled 2020-02-10 nowcast 1.3460419 1.560106 1.4398453 #> 35: infection_upscaled 2020-02-11 nowcast 1.4337636 1.556797 1.5343007 #> 36: infection_upscaled 2020-02-12 nowcast 1.5215301 1.792907 1.5215301 #> 37: infection_upscaled 2020-02-13 nowcast 1.4794848 1.661244 1.4794848 #> 38: infection_upscaled 2020-02-14 nowcast 1.6638594 1.811986 1.6638594 #> 39: infection_upscaled 2020-02-15 nowcast 1.3637650 1.535037 1.3637650 #> 40: infection_upscaled 2020-02-16 nowcast 1.3055944 1.579732 1.4947549 #> 41: infection_upscaled 2020-02-17 nowcast 1.4492705 1.721302 1.4851385 #> 42: infection_upscaled 2020-02-18 nowcast 1.4057597 1.553835 1.4057597 #> 43: infection_upscaled 2020-02-19 nowcast 1.3995456 1.471819 1.4360208 #> 44: infection_upscaled 2020-02-20 nowcast 1.3029928 1.489740 1.3757843 #> 45: infection_upscaled 2020-02-21 nowcast 1.3184686 1.454882 1.3921672 #> 46: infection_upscaled 2020-02-22 nowcast 1.3432880 1.512364 1.3968339 #> 47: infection_upscaled 2020-02-23 nowcast 1.3409267 1.534036 1.3409267 #> 48: infection_upscaled 2020-02-24 nowcast 1.2975419 1.413711 1.3729645 #> 49: infection_upscaled 2020-02-25 nowcast 1.3521756 1.520289 1.4382570 #> 50: infection_upscaled 2020-02-26 nowcast 1.2713198 1.388037 1.3457011 #> 51: infection_upscaled 2020-02-27 nowcast 1.2711148 1.396039 1.3251612 #> 52: infection_upscaled 2020-02-28 nowcast 1.1853276 1.301794 1.2542129 #> 53: infection_upscaled 2020-02-29 nowcast 1.1956021 1.261747 1.2383748 #> 54: infection_upscaled 2020-03-01 nowcast 1.1917273 1.259077 1.1982088 #> 55: infection_upscaled 2020-03-02 nowcast 1.1917445 1.287847 1.1999894 #> 56: infection_upscaled 2020-03-03 nowcast 1.1157557 1.262443 1.1337585 #> 57: infection_upscaled 2020-03-04 nowcast 1.1135712 1.190618 1.1135712 #> 58: infection_upscaled 2020-03-05 nowcast 1.1269153 1.246052 1.1269153 #> 59: infection_upscaled 2020-03-06 nowcast 1.1598764 1.256630 1.2126892 #> 60: infection_upscaled 2020-03-07 nowcast 1.1757198 1.244037 1.1757198 #> 61: infection_upscaled 2020-03-08 nowcast 1.1007389 1.216609 1.2142703 #> 62: infection_upscaled 2020-03-09 nowcast 1.1529955 1.208512 1.1862978 #> 63: infection_upscaled 2020-03-10 nowcast 1.1928323 1.300817 1.2207175 #> 64: infection_upscaled 2020-03-11 nowcast 1.1887045 1.275124 1.2463304 #> 65: infection_upscaled 2020-03-12 nowcast 1.2080828 1.280472 1.2566473 #> 66: infection_upscaled 2020-03-13 nowcast 1.2113434 1.252302 1.2113434 #> 67: infection_upscaled 2020-03-14 nowcast 1.1879712 1.271537 1.1879712 #> type date rt_type bottom top lower #> upper median mean std prob_control mean_window sd_window #> 1: 1.5212676 1.5212676 1.869196 0.71730863 0.0 7 0 #> 2: 2.7358565 2.1404290 1.854206 0.74348753 0.0 7 0 #> 3: 1.6603614 1.5915486 1.431928 0.98688641 0.4 7 0 #> 4: 1.6731009 1.6731009 1.725021 0.58834047 0.0 7 0 #> 5: 1.3054933 1.3054933 1.727324 1.20554212 0.4 7 0 #> 6: 1.6582790 1.6543254 1.661854 0.21795418 0.0 7 0 #> 7: 1.6935517 1.3287830 1.418805 0.42330679 0.2 7 0 #> 8: 1.4664339 1.4664339 1.546056 0.48377984 0.2 7 0 #> 9: 1.4114433 1.1403739 1.012818 0.39387302 0.4 7 0 #> 10: 1.6411567 1.6411567 2.017893 1.00369346 0.0 7 0 #> 11: 0.6107019 0.6107019 0.907246 0.54306834 0.6 7 0 #> 12: 1.1861016 1.1859896 1.128404 0.17598867 0.2 7 0 #> 13: 1.0700319 1.0700319 1.207425 0.39858208 0.2 7 0 #> 14: 2.0839697 1.8870574 1.856327 0.40775103 0.0 7 0 #> 15: 1.5552215 1.5552215 1.963382 0.70290738 0.0 7 0 #> 16: 1.7667382 1.6233234 1.622946 0.42115238 0.0 7 0 #> 17: 1.7740350 1.7740350 2.034857 0.50940178 0.0 7 0 #> 18: 2.0042027 1.9327026 1.899280 0.35984837 0.0 7 0 #> 19: 2.2349878 2.0977190 1.973821 0.36686609 0.0 7 0 #> 20: 2.4545710 2.4175814 2.378268 0.52102310 0.0 7 0 #> 21: 2.4708755 2.2724398 2.271434 0.17222738 0.0 7 0 #> 22: 2.2535417 2.2535417 2.424157 0.62265951 0.0 7 0 #> 23: 2.0904290 2.0904290 2.163797 0.20709421 0.0 7 0 #> 24: 1.8914039 1.8605855 1.846334 0.24773127 0.0 7 0 #> 25: 1.7445707 1.7334386 1.764027 0.24363897 0.0 7 0 #> 26: 1.8197254 1.6278118 1.661316 0.28912768 0.0 7 0 #> 27: 1.5963207 1.5963207 1.662655 0.23106083 0.0 7 0 #> 28: 1.8479977 1.7233534 1.723438 0.12259701 0.0 7 0 #> 29: 1.7065016 1.6554766 1.641422 0.14288420 0.0 7 0 #> 30: 1.3811903 1.3811903 1.458651 0.15600310 0.0 7 0 #> 31: 1.4859002 1.3923296 1.381059 0.08880097 0.0 7 0 #> 32: 1.4550417 1.3664692 1.345507 0.09010572 0.0 7 0 #> 33: 1.5224457 1.4705309 1.478293 0.08595494 0.0 7 0 #> 34: 1.5134377 1.4522242 1.462331 0.08109065 0.0 7 0 #> 35: 1.5567974 1.5343007 1.503820 0.05997116 0.0 7 0 #> 36: 1.6244029 1.6244029 1.642893 0.10400197 0.0 7 0 #> 37: 1.5203942 1.5203942 1.541966 0.07379481 0.0 7 0 #> 38: 1.7183742 1.7183742 1.730204 0.06262531 0.0 7 0 #> 39: 1.4293274 1.4293274 1.448781 0.07900614 0.0 7 0 #> 40: 1.5797317 1.4947549 1.478678 0.11335697 0.0 7 0 #> 41: 1.5523145 1.5258215 1.546769 0.10516118 0.0 7 0 #> 42: 1.4387392 1.4387392 1.460865 0.06169524 0.0 7 0 #> 43: 1.4718192 1.4360208 1.431630 0.03034785 0.0 7 0 #> 44: 1.4463435 1.3959887 1.402170 0.07104636 0.0 7 0 #> 45: 1.4379479 1.3995140 1.400596 0.05281876 0.0 7 0 #> 46: 1.4429385 1.4396969 1.427024 0.06248976 0.0 7 0 #> 47: 1.3909618 1.3909618 1.420954 0.08040612 0.0 7 0 #> 48: 1.3970640 1.3822781 1.372712 0.04476615 0.0 7 0 #> 49: 1.4743305 1.4688361 1.450778 0.06243364 0.0 7 0 #> 50: 1.3880369 1.3457011 1.341646 0.04638636 0.0 7 0 #> 51: 1.3402168 1.3344023 1.333387 0.04449278 0.0 7 0 #> 52: 1.3017943 1.2542129 1.251895 0.04734009 0.0 7 0 #> 53: 1.2617469 1.2383748 1.230702 0.02712657 0.0 7 0 #> 54: 1.2240440 1.2207103 1.218753 0.02650596 0.0 7 0 #> 55: 1.2156654 1.2111573 1.221281 0.03837554 0.0 7 0 #> 56: 1.2004342 1.1877419 1.180027 0.05818080 0.0 7 0 #> 57: 1.1202680 1.1202680 1.137522 0.03185375 0.0 7 0 #> 58: 1.1511722 1.1511722 1.166593 0.04839205 0.0 7 0 #> 59: 1.2566299 1.2126892 1.204938 0.03924589 0.0 7 0 #> 60: 1.1884106 1.1884106 1.198472 0.02875397 0.0 7 0 #> 61: 1.2166093 1.2142703 1.185985 0.04962502 0.0 7 0 #> 62: 1.2085124 1.1862978 1.184512 0.02237559 0.0 7 0 #> 63: 1.2615966 1.2378995 1.242772 0.04101111 0.0 7 0 #> 64: 1.2751239 1.2463304 1.239785 0.03341344 0.0 7 0 #> 65: 1.2700863 1.2619538 1.255448 0.02796295 0.0 7 0 #> 66: 1.2253052 1.2253052 1.227756 0.01641097 0.0 7 0 #> 67: 1.2206810 1.2206810 1.220326 0.03427754 0.0 7 0 #> upper median mean std prob_control mean_window sd_window #> mean_crps sd_crps R0_range #> 1: 2.00 0 <list[5]> #> 2: 0.20 0 <list[5]> #> 3: 0.36 0 <list[5]> #> 4: 0.04 0 <list[5]> #> 5: 0.04 0 <list[5]> #> 6: 0.68 0 <list[5]> #> 7: 1.04 0 <list[5]> #> 8: 0.88 0 <list[5]> #> 9: 0.20 0 <list[5]> #> 10: 0.12 0 <list[5]> #> 11: 0.40 0 <list[5]> #> 12: 0.16 0 <list[5]> #> 13: 0.68 0 <list[5]> #> 14: 1.36 0 <list[5]> #> 15: 2.40 0 <list[5]> #> 16: 0.28 0 <list[5]> #> 17: 0.24 0 <list[5]> #> 18: 0.24 0 <list[5]> #> 19: 1.24 0 <list[5]> #> 20: 0.88 0 <list[5]> #> 21: 0.80 0 <list[5]> #> 22: 4.68 0 <list[5]> #> 23: 2.48 0 <list[5]> #> 24: 2.48 0 <list[5]> #> 25: 1.28 0 <list[5]> #> 26: 2.56 0 <list[5]> #> 27: 1.84 0 <list[5]> #> 28: 2.12 0 <list[5]> #> 29: 1.56 0 <list[5]> #> 30: 3.68 0 <list[5]> #> 31: 1.28 0 <list[5]> #> 32: 5.88 0 <list[5]> #> 33: 1.56 0 <list[5]> #> 34: 3.32 0 <list[5]> #> 35: 9.24 0 <list[5]> #> 36: 3.28 0 <list[5]> #> 37: 2.12 0 <list[5]> #> 38: 10.00 0 <list[5]> #> 39: 11.92 0 <list[5]> #> 40: 1.00 0 <list[5]> #> 41: 5.20 0 <list[5]> #> 42: 2.44 0 <list[5]> #> 43: 4.52 0 <list[5]> #> 44: 5.76 0 <list[5]> #> 45: 2.52 0 <list[5]> #> 46: 1.36 0 <list[5]> #> 47: 12.40 0 <list[5]> #> 48: 7.40 0 <list[5]> #> 49: 13.80 0 <list[5]> #> 50: 5.20 0 <list[5]> #> 51: 27.40 0 <list[5]> #> 52: 16.04 0 <list[5]> #> 53: 12.64 0 <list[5]> #> 54: 1.96 0 <list[5]> #> 55: 13.64 0 <list[5]> #> 56: 2.60 0 <list[5]> #> 57: 12.96 0 <list[5]> #> 58: 19.20 0 <list[5]> #> 59: 10.52 0 <list[5]> #> 60: 15.96 0 <list[5]> #> 61: 14.08 0 <list[5]> #> 62: 3.92 0 <list[5]> #> 63: 4.56 0 <list[5]> #> 64: 3.80 0 <list[5]> #> 65: 5.48 0 <list[5]> #> 66: 8.88 0 <list[5]> #> 67: 3.56 0 <list[5]> #> mean_crps sd_crps R0_range #> #> $rate_of_spread #> type overall_little_r time_varying_r #> 1: infection_upscaled <list[3]> <data.table[207x8]> #> #> $raw_R0 #> date R sample crps window rt_type type #> 1: 2020-01-08 1.163142 1 2.00 7 nowcast infection_upscaled #> 2: 2020-01-08 1.383608 1 2.00 7 nowcast infection_upscaled #> 3: 2020-01-08 1.521268 1 2.00 7 nowcast infection_upscaled #> 4: 2020-01-08 2.545097 1 2.00 7 nowcast infection_upscaled #> 5: 2020-01-08 2.732865 1 2.00 7 nowcast infection_upscaled #> --- #> 331: 2020-03-14 1.187971 1 3.56 7 nowcast infection_upscaled #> 332: 2020-03-14 1.190157 1 3.56 7 nowcast infection_upscaled #> 333: 2020-03-14 1.220681 1 3.56 7 nowcast infection_upscaled #> 334: 2020-03-14 1.231285 1 3.56 7 nowcast infection_upscaled #> 335: 2020-03-14 1.271537 1 3.56 7 nowcast infection_upscaled #>