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