Performance of (population) historical forecast
Usage
add_historical_pred(
test,
train,
max_score,
discrete = TRUE,
add_uniform = TRUE,
include_samples = FALSE,
n_samples = NULL
)
Arguments
- test
Testing dataframe. The only requirements is that it contains a column "Score".
- train
Training 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
- add_uniform
Whether to include samples from uniform distribution when computing a discrete historical forecast. This ensures that all states are visited.
- 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 function return the training set.
Value
Dataframe test
appended by the columns "lpd", "RPS" (or CRPS if discrete=FALSE) and optionally "Samples"
Details
The continuous historical forecast is calculated by considering the training set as samples from the predictive distribution.
Examples
max_score <- 100
train <- data.frame(Score = rbinom(1e2, max_score, 0.2))
test <- data.frame(Score = rbinom(1e2, max_score, 0.5))
add_historical_pred(test, train, max_score)
#> Score lpd RPS
#> 1 40 -5.303305 0.09710626
#> 2 51 -5.303305 0.14690725
#> 3 51 -5.303305 0.14690725
#> 4 55 -5.303305 0.16800178
#> 5 49 -5.303305 0.13695701
#> 6 60 -5.303305 0.19660875
#> 7 55 -5.303305 0.16800178
#> 8 53 -5.303305 0.15725551
#> 9 46 -5.303305 0.12277790
#> 10 50 -5.303305 0.14188238
#> 11 40 -5.303305 0.09710626
#> 12 55 -5.303305 0.16800178
#> 13 56 -5.303305 0.17352417
#> 14 52 -5.303305 0.15203163
#> 15 53 -5.303305 0.15725551
#> 16 55 -5.303305 0.16800178
#> 17 44 -5.303305 0.11382268
#> 18 46 -5.303305 0.12277790
#> 19 53 -5.303305 0.15725551
#> 20 45 -5.303305 0.11825054
#> 21 48 -5.303305 0.13213114
#> 22 58 -5.303305 0.18486745
#> 23 61 -5.303305 0.20262865
#> 24 43 -5.303305 0.10949432
#> 25 50 -5.303305 0.14188238
#> 26 48 -5.303305 0.13213114
#> 27 44 -5.303305 0.11382268
#> 28 42 -5.303305 0.10526546
#> 29 50 -5.303305 0.14188238
#> 30 47 -5.303305 0.12740477
#> 31 49 -5.303305 0.13695701
#> 32 47 -5.303305 0.12740477
#> 33 54 -5.303305 0.16257890
#> 34 60 -5.303305 0.19660875
#> 35 40 -5.303305 0.09710626
#> 36 59 -5.303305 0.19068835
#> 37 53 -5.303305 0.15725551
#> 38 52 -5.303305 0.15203163
#> 39 55 -5.303305 0.16800178
#> 40 46 -5.303305 0.12277790
#> 41 48 -5.303305 0.13213114
#> 42 49 -5.303305 0.13695701
#> 43 39 -5.303305 0.09317591
#> 44 55 -5.303305 0.16800178
#> 45 48 -5.303305 0.13213114
#> 46 60 -5.303305 0.19660875
#> 47 51 -5.303305 0.14690725
#> 48 49 -5.303305 0.13695701
#> 49 56 -5.303305 0.17352417
#> 50 49 -5.303305 0.13695701
#> 51 51 -5.303305 0.14690725
#> 52 52 -5.303305 0.15203163
#> 53 50 -5.303305 0.14188238
#> 54 53 -5.303305 0.15725551
#> 55 41 -5.303305 0.10113611
#> 56 49 -5.303305 0.13695701
#> 57 67 -5.303305 0.24083760
#> 58 45 -5.303305 0.11825054
#> 59 50 -5.303305 0.14188238
#> 60 47 -5.303305 0.12740477
#> 61 55 -5.303305 0.16800178
#> 62 57 -5.303305 0.17914606
#> 63 47 -5.303305 0.12740477
#> 64 50 -5.303305 0.14188238
#> 65 44 -5.303305 0.11382268
#> 66 46 -5.303305 0.12277790
#> 67 45 -5.303305 0.11825054
#> 68 47 -5.303305 0.12740477
#> 69 43 -5.303305 0.10949432
#> 70 49 -5.303305 0.13695701
#> 71 49 -5.303305 0.13695701
#> 72 51 -5.303305 0.14690725
#> 73 49 -5.303305 0.13695701
#> 74 50 -5.303305 0.14188238
#> 75 50 -5.303305 0.14188238
#> 76 47 -5.303305 0.12740477
#> 77 55 -5.303305 0.16800178
#> 78 51 -5.303305 0.14690725
#> 79 50 -5.303305 0.14188238
#> 80 55 -5.303305 0.16800178
#> 81 58 -5.303305 0.18486745
#> 82 59 -5.303305 0.19068835
#> 83 51 -5.303305 0.14690725
#> 84 45 -5.303305 0.11825054
#> 85 52 -5.303305 0.15203163
#> 86 50 -5.303305 0.14188238
#> 87 53 -5.303305 0.15725551
#> 88 59 -5.303305 0.19068835
#> 89 43 -5.303305 0.10949432
#> 90 58 -5.303305 0.18486745
#> 91 46 -5.303305 0.12277790
#> 92 37 -5.303305 0.08561372
#> 93 54 -5.303305 0.16257890
#> 94 43 -5.303305 0.10949432
#> 95 38 -5.303305 0.08934507
#> 96 39 -5.303305 0.09317591
#> 97 46 -5.303305 0.12277790
#> 98 48 -5.303305 0.13213114
#> 99 56 -5.303305 0.17352417
#> 100 42 -5.303305 0.10526546