Filter a table of forecasts to include only those present for a value of a given column.
Source:R/filter_to_subset_forecasts.R
filter_to_subset_forecasts.Rd
Filter a table of forecasts to include only those present for a value of a given column.
Arguments
- tbl
Table of forecasts or scores to filter, as a valid input to
scoringutils::get_forecast_unit()
.- comparator_value
Character scalar of comparator value for which to compute subset forecasts.
- compare
Name of the column containing the comparator value. Default
"model"
.
Value
Table filtered to containing only forecasts that are also
present in the comparator_value
forecasts.
Examples
filter_to_subset_forecasts(
scoringutils::example_quantile,
"EuroCOVIDhub-ensemble")
#> 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
#> <char> <Date> <char> <num> <char>
#> 1: DE 2021-05-08 Cases 106987 Germany
#> 2: DE 2021-05-08 Cases 106987 Germany
#> 3: DE 2021-05-08 Cases 106987 Germany
#> 4: DE 2021-05-08 Cases 106987 Germany
#> 5: DE 2021-05-08 Cases 106987 Germany
#> ---
#> 20397: IT 2021-07-24 Deaths 78 Italy
#> 20398: IT 2021-07-24 Deaths 78 Italy
#> 20399: IT 2021-07-24 Deaths 78 Italy
#> 20400: IT 2021-07-24 Deaths 78 Italy
#> 20401: IT 2021-07-24 Deaths 78 Italy
#> forecast_date quantile_level predicted model horizon
#> <Date> <num> <int> <char> <num>
#> 1: 2021-05-03 0.010 82466 EuroCOVIDhub-ensemble 1
#> 2: 2021-05-03 0.025 86669 EuroCOVIDhub-ensemble 1
#> 3: 2021-05-03 0.050 90285 EuroCOVIDhub-ensemble 1
#> 4: 2021-05-03 0.100 95341 EuroCOVIDhub-ensemble 1
#> 5: 2021-05-03 0.150 99171 EuroCOVIDhub-ensemble 1
#> ---
#> 20397: 2021-07-12 0.850 352 epiforecasts-EpiNow2 2
#> 20398: 2021-07-12 0.900 397 epiforecasts-EpiNow2 2
#> 20399: 2021-07-12 0.950 499 epiforecasts-EpiNow2 2
#> 20400: 2021-07-12 0.975 611 epiforecasts-EpiNow2 2
#> 20401: 2021-07-12 0.990 719 epiforecasts-EpiNow2 2
scoringutils::example_quantile |>
scoringutils::score() |>
filter_to_subset_forecasts("EuroCOVIDhub-ensemble")
#> location target_end_date target_type location_name forecast_date
#> <char> <Date> <char> <char> <Date>
#> 1: DE 2021-05-08 Cases Germany 2021-05-03
#> 2: DE 2021-05-08 Cases Germany 2021-05-03
#> 3: DE 2021-05-08 Cases Germany 2021-05-03
#> 4: DE 2021-05-08 Deaths Germany 2021-05-03
#> 5: DE 2021-05-08 Deaths Germany 2021-05-03
#> ---
#> 883: IT 2021-07-24 Deaths Italy 2021-07-12
#> 884: IT 2021-07-24 Deaths Italy 2021-07-05
#> 885: IT 2021-07-24 Deaths Italy 2021-07-12
#> 886: IT 2021-07-24 Deaths Italy 2021-07-05
#> 887: IT 2021-07-24 Deaths Italy 2021-07-12
#> model horizon wis overprediction underprediction
#> <char> <num> <num> <num> <num>
#> 1: EuroCOVIDhub-ensemble 1 7990.854783 2.549870e+03 0.0000000
#> 2: EuroCOVIDhub-baseline 1 16925.046957 1.527583e+04 0.0000000
#> 3: epiforecasts-EpiNow2 1 25395.960870 1.722226e+04 0.0000000
#> 4: EuroCOVIDhub-ensemble 1 53.880000 0.000000e+00 0.6086957
#> 5: EuroCOVIDhub-baseline 1 46.793043 2.130435e+00 0.0000000
#> ---
#> 883: EuroCOVIDhub-baseline 2 80.336957 3.608696e+00 0.0000000
#> 884: UMass-MechBayes 3 4.881739 4.347826e-02 0.0000000
#> 885: UMass-MechBayes 2 25.581739 1.782609e+01 0.0000000
#> 886: epiforecasts-EpiNow2 3 19.762609 5.478261e+00 0.0000000
#> 887: epiforecasts-EpiNow2 2 66.161739 4.060870e+01 0.0000000
#> dispersion bias interval_coverage_50 interval_coverage_90 ae_median
#> <num> <num> <lgcl> <lgcl> <num>
#> 1: 5440.985217 0.50 TRUE TRUE 12271
#> 2: 1649.220870 0.95 FALSE FALSE 25620
#> 3: 8173.700000 0.90 FALSE TRUE 44192
#> 4: 53.271304 -0.10 TRUE TRUE 14
#> 5: 44.662609 0.30 TRUE TRUE 15
#> ---
#> 883: 76.728261 0.20 TRUE TRUE 53
#> 884: 4.838261 0.10 TRUE TRUE 1
#> 885: 7.755652 0.80 FALSE TRUE 46
#> 886: 14.284348 0.50 TRUE TRUE 26
#> 887: 25.553043 0.90 FALSE TRUE 108