Skip to contents

Performance of a uniform forecast

Usage

add_uniform_pred(
  test,
  max_score,
  discrete = TRUE,
  include_samples = FALSE,
  n_samples = NULL
)

Arguments

test

Testing dataframe. The only requirements is that it contains a column "Score".

max_score

Maximum value that the score can take

discrete

Whether to estimate a discrete or continuous historical forecast

include_samples

Whether to return samples from the historical forecast in the output

n_samples

If include_samples=TRUE, how many samples to return. When NULL, the samples 0:max_score are returned.

Value

Dataframe test appended by the columns "lpd", "RPS" (or CRPS if discrete=FALSE) and optionally "Samples"

Examples

max_score <- 100
test <- data.frame(Score = rbinom(1e2, max_score, 0.5))
add_uniform_pred(test, max_score)
#>     Score       lpd        RPS
#> 1      44 -4.615121 0.08772277
#> 2      52 -4.615121 0.08455446
#> 3      53 -4.615121 0.08504950
#> 4      49 -4.615121 0.08425743
#> 5      50 -4.615121 0.08415842
#> 6      61 -4.615121 0.09613861
#> 7      38 -4.615121 0.09841584
#> 8      49 -4.615121 0.08425743
#> 9      53 -4.615121 0.08504950
#> 10     54 -4.615121 0.08574257
#> 11     61 -4.615121 0.09613861
#> 12     49 -4.615121 0.08425743
#> 13     55 -4.615121 0.08663366
#> 14     47 -4.615121 0.08504950
#> 15     52 -4.615121 0.08455446
#> 16     54 -4.615121 0.08574257
#> 17     50 -4.615121 0.08415842
#> 18     57 -4.615121 0.08900990
#> 19     47 -4.615121 0.08504950
#> 20     48 -4.615121 0.08455446
#> 21     52 -4.615121 0.08455446
#> 22     52 -4.615121 0.08455446
#> 23     55 -4.615121 0.08663366
#> 24     49 -4.615121 0.08425743
#> 25     52 -4.615121 0.08455446
#> 26     51 -4.615121 0.08425743
#> 27     52 -4.615121 0.08455446
#> 28     47 -4.615121 0.08504950
#> 29     50 -4.615121 0.08415842
#> 30     56 -4.615121 0.08772277
#> 31     55 -4.615121 0.08663366
#> 32     47 -4.615121 0.08504950
#> 33     51 -4.615121 0.08425743
#> 34     48 -4.615121 0.08455446
#> 35     52 -4.615121 0.08455446
#> 36     53 -4.615121 0.08504950
#> 37     57 -4.615121 0.08900990
#> 38     51 -4.615121 0.08425743
#> 39     52 -4.615121 0.08455446
#> 40     51 -4.615121 0.08425743
#> 41     54 -4.615121 0.08574257
#> 42     47 -4.615121 0.08504950
#> 43     47 -4.615121 0.08504950
#> 44     48 -4.615121 0.08455446
#> 45     45 -4.615121 0.08663366
#> 46     42 -4.615121 0.09049505
#> 47     49 -4.615121 0.08425743
#> 48     44 -4.615121 0.08772277
#> 49     46 -4.615121 0.08574257
#> 50     46 -4.615121 0.08574257
#> 51     55 -4.615121 0.08663366
#> 52     51 -4.615121 0.08425743
#> 53     54 -4.615121 0.08574257
#> 54     47 -4.615121 0.08504950
#> 55     57 -4.615121 0.08900990
#> 56     38 -4.615121 0.09841584
#> 57     44 -4.615121 0.08772277
#> 58     52 -4.615121 0.08455446
#> 59     51 -4.615121 0.08425743
#> 60     49 -4.615121 0.08425743
#> 61     56 -4.615121 0.08772277
#> 62     45 -4.615121 0.08663366
#> 63     49 -4.615121 0.08425743
#> 64     42 -4.615121 0.09049505
#> 65     52 -4.615121 0.08455446
#> 66     39 -4.615121 0.09613861
#> 67     51 -4.615121 0.08425743
#> 68     56 -4.615121 0.08772277
#> 69     48 -4.615121 0.08455446
#> 70     55 -4.615121 0.08663366
#> 71     58 -4.615121 0.09049505
#> 72     48 -4.615121 0.08455446
#> 73     51 -4.615121 0.08425743
#> 74     39 -4.615121 0.09613861
#> 75     59 -4.615121 0.09217822
#> 76     50 -4.615121 0.08415842
#> 77     54 -4.615121 0.08574257
#> 78     53 -4.615121 0.08504950
#> 79     51 -4.615121 0.08425743
#> 80     42 -4.615121 0.09049505
#> 81     46 -4.615121 0.08574257
#> 82     51 -4.615121 0.08425743
#> 83     45 -4.615121 0.08663366
#> 84     49 -4.615121 0.08425743
#> 85     47 -4.615121 0.08504950
#> 86     46 -4.615121 0.08574257
#> 87     50 -4.615121 0.08415842
#> 88     49 -4.615121 0.08425743
#> 89     39 -4.615121 0.09613861
#> 90     49 -4.615121 0.08425743
#> 91     52 -4.615121 0.08455446
#> 92     60 -4.615121 0.09405941
#> 93     47 -4.615121 0.08504950
#> 94     46 -4.615121 0.08574257
#> 95     54 -4.615121 0.08574257
#> 96     48 -4.615121 0.08455446
#> 97     47 -4.615121 0.08504950
#> 98     43 -4.615121 0.08900990
#> 99     47 -4.615121 0.08504950
#> 100    49 -4.615121 0.08425743