Filter a table of forecasts to include only those present for all values of a given column.
Source:R/filter_to_shared_forecasts.R
filter_to_shared_forecasts.Rd
Filter a table of forecasts to include only those present for all values of a given column.
Arguments
- tbl
Table of forecasts or scores to filter, as a valid input to
scoringutils::get_forecast_unit()
.- comparator_values
Character vector of comparator values for which to compute shared forecasts. If
NULL
(default), use all unique values of the column specified incompare
.- compare
Name of the column containing the comparator values. Default
"model"
.
Value
Table filtered to containing only forecasts corresponding to
entries in comparator_values
that are present for all entries
in comparator_values
.
Examples
filter_to_shared_forecasts(
scoringutils::example_quantile,
c("EuroCOVIDhub-ensemble", "UMass-MechBayes"))
#> Forecast type: quantile
#> Forecast unit:
#> location, target_end_date, target_type, location_name, forecast_date, model,
#> and horizon
#>
#> Key: <location, target_end_date, target_type>
#> location target_end_date target_type observed location_name forecast_date
#> <char> <Date> <char> <num> <char> <Date>
#> 1: DE 2021-05-08 Deaths 1582 Germany 2021-05-03
#> 2: DE 2021-05-08 Deaths 1582 Germany 2021-05-03
#> 3: DE 2021-05-08 Deaths 1582 Germany 2021-05-03
#> 4: DE 2021-05-08 Deaths 1582 Germany 2021-05-03
#> 5: DE 2021-05-08 Deaths 1582 Germany 2021-05-03
#> ---
#> 5884: IT 2021-07-24 Deaths 78 Italy 2021-07-12
#> 5885: IT 2021-07-24 Deaths 78 Italy 2021-07-12
#> 5886: IT 2021-07-24 Deaths 78 Italy 2021-07-12
#> 5887: IT 2021-07-24 Deaths 78 Italy 2021-07-12
#> 5888: IT 2021-07-24 Deaths 78 Italy 2021-07-12
#> quantile_level predicted model horizon
#> <num> <int> <char> <num>
#> 1: 0.010 1054 EuroCOVIDhub-ensemble 1
#> 2: 0.025 1136 EuroCOVIDhub-ensemble 1
#> 3: 0.050 1192 EuroCOVIDhub-ensemble 1
#> 4: 0.100 1280 EuroCOVIDhub-ensemble 1
#> 5: 0.150 1328 EuroCOVIDhub-ensemble 1
#> ---
#> 5884: 0.850 165 UMass-MechBayes 2
#> 5885: 0.900 174 UMass-MechBayes 2
#> 5886: 0.950 191 UMass-MechBayes 2
#> 5887: 0.975 206 UMass-MechBayes 2
#> 5888: 0.990 228 UMass-MechBayes 2
scoringutils::example_quantile |>
scoringutils::score() |>
filter_to_shared_forecasts(c("EuroCOVIDhub-ensemble",
"epiforecasts-EpiNow2",
"UMass-MechBayes"))
#> location target_end_date target_type location_name forecast_date
#> <char> <Date> <char> <char> <Date>
#> 1: DE 2021-05-08 Deaths Germany 2021-05-03
#> 2: DE 2021-05-08 Deaths Germany 2021-05-03
#> 3: DE 2021-05-08 Deaths Germany 2021-05-03
#> 4: DE 2021-05-15 Deaths Germany 2021-05-03
#> 5: DE 2021-05-15 Deaths Germany 2021-05-10
#> ---
#> 353: IT 2021-07-24 Deaths Italy 2021-07-12
#> 354: IT 2021-07-24 Deaths Italy 2021-07-05
#> 355: IT 2021-07-24 Deaths Italy 2021-07-12
#> 356: IT 2021-07-24 Deaths Italy 2021-07-05
#> 357: IT 2021-07-24 Deaths Italy 2021-07-12
#> model horizon wis overprediction underprediction
#> <char> <num> <num> <num> <num>
#> 1: EuroCOVIDhub-ensemble 1 53.880000 0.00000000 0.6086957
#> 2: UMass-MechBayes 1 116.121739 0.00000000 39.0434783
#> 3: epiforecasts-EpiNow2 1 80.356522 1.04347826 0.0000000
#> 4: EuroCOVIDhub-ensemble 2 120.578696 49.65217391 0.0000000
#> 5: EuroCOVIDhub-ensemble 1 67.098261 20.73913043 0.0000000
#> ---
#> 353: EuroCOVIDhub-ensemble 2 18.658696 5.30434783 0.0000000
#> 354: UMass-MechBayes 3 4.881739 0.04347826 0.0000000
#> 355: UMass-MechBayes 2 25.581739 17.82608696 0.0000000
#> 356: epiforecasts-EpiNow2 3 19.762609 5.47826087 0.0000000
#> 357: epiforecasts-EpiNow2 2 66.161739 40.60869565 0.0000000
#> dispersion bias interval_coverage_50 interval_coverage_90 ae_median
#> <num> <num> <lgcl> <lgcl> <num>
#> 1: 53.271304 -0.1 TRUE TRUE 14
#> 2: 77.078261 -0.5 TRUE TRUE 208
#> 3: 79.313043 0.1 TRUE TRUE 24
#> 4: 70.926522 0.6 FALSE TRUE 210
#> 5: 46.359130 0.4 TRUE TRUE 111
#> ---
#> 353: 13.354348 0.4 TRUE TRUE 30
#> 354: 4.838261 0.1 TRUE TRUE 1
#> 355: 7.755652 0.8 FALSE TRUE 46
#> 356: 14.284348 0.5 TRUE TRUE 26
#> 357: 25.553043 0.9 FALSE TRUE 108