Skip to contents

Transform data from a format that is based on predictive samples to a format based on plain quantiles.

Usage

sample_to_quantile(data, quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), type = 7)

Arguments

data

a data.frame with samples

quantiles

a numeric vector of quantiles to extract

type

type argument passed down to the quantile function. For more information, see quantile()

Value

a data.frame in a long interval range format

Examples

sample_to_quantile(example_integer)
#>       location location_name target_end_date target_type forecast_date
#>    1:       DE       Germany      2021-01-02       Cases          <NA>
#>    2:       DE       Germany      2021-01-02       Cases          <NA>
#>    3:       DE       Germany      2021-01-02       Cases          <NA>
#>    4:       DE       Germany      2021-01-02       Cases          <NA>
#>    5:       DE       Germany      2021-01-02       Cases          <NA>
#>   ---                                                                 
#> 5151:       IT         Italy      2021-07-24      Deaths    2021-07-12
#> 5152:       IT         Italy      2021-07-24      Deaths    2021-07-12
#> 5153:       IT         Italy      2021-07-24      Deaths    2021-07-12
#> 5154:       IT         Italy      2021-07-24      Deaths    2021-07-12
#> 5155:       IT         Italy      2021-07-24      Deaths    2021-07-12
#>                      model horizon true_value quantile prediction
#>    1:                 <NA>      NA     127300     0.05         NA
#>    2:                 <NA>      NA     127300     0.25         NA
#>    3:                 <NA>      NA     127300     0.50         NA
#>    4:                 <NA>      NA     127300     0.75         NA
#>    5:                 <NA>      NA     127300     0.95         NA
#>   ---                                                            
#> 5151: epiforecasts-EpiNow2       2         78     0.05      44.90
#> 5152: epiforecasts-EpiNow2       2         78     0.25      89.25
#> 5153: epiforecasts-EpiNow2       2         78     0.50     151.50
#> 5154: epiforecasts-EpiNow2       2         78     0.75     208.00
#> 5155: epiforecasts-EpiNow2       2         78     0.95     469.10