Description Usage Arguments Value Examples
View source: R/FastMultiHorizonMCS.R
Produces Multi-Horizon Model Confidence Set and p-values as described in section 2.2. of Quadvlieg (2021).
1 2 3 4 5 6 7 8 9 10 11 |
Losses |
A list containing M matrices of dimension T by H. Each matrix contains the losses for a forecasting method. Rows correspond to time periods (T rows), columns correspond to forecast horizons (H columns). |
alpha_t |
Alpha level of critical values for pairwise tests. See Quadvlieg (2021). |
alpha_mcs |
Alpha level of the critical value for the MCS test. Denoted by alpha tilde in Quadvlieg (2021) section 2.2 |
weights |
the 1 x H vector of weights for the losses at different horizons. For instance |
L |
integer, the parameter for the moving block bootstrap |
B |
integer, the number of bootstrap iterations. Default 999 |
unif_or_average |
If equals "a", then the confidence set is calculated based on average SPA. If equals "u", then the confidence set is calculated based on uniform SPA. |
num_cores |
integer, the number of processor cores to use in parallel. |
seed |
integer, the seed for random number generation |
Returns a list of length 2. The elements of the list are:
MCS_set |
A M by 2 matrix. The first column contains the indices of the methods for which the p-value is greater than or equal to 1-alpha_mcs. The second column contains the p-values that are greater than or equal to 1-alpha_mcs. |
p_values |
A vector containing the p-values for all methods. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Trow <- 20
H <- 12
Mmethods <- 9
weights <- rep(1/H,H)
loss_list <- vector(mode = "list", length = Mmethods)
loss_list[[1]] <- matrix(rnorm(Trow*H, mean = 1), nrow = Trow, ncol = H)
loss_list[[2]] <- matrix(rnorm(Trow*H, mean = 2), nrow = Trow, ncol = H)
loss_list[[3]] <- matrix(rnorm(Trow*H, mean = 3), nrow = Trow, ncol = H)
loss_list[[4]] <- matrix(rnorm(Trow*H, mean = 2), nrow = Trow, ncol = H)
loss_list[[5]] <- matrix(rnorm(Trow*H, mean = 1), nrow = Trow, ncol = H)
loss_list[[6]] <- matrix(rnorm(Trow*H, mean = 1), nrow = Trow, ncol = H)
loss_list[[7]] <- matrix(rnorm(Trow*H, mean = 2), nrow = Trow, ncol = H)
loss_list[[8]] <- matrix(rnorm(Trow*H, mean = 3), nrow = Trow, ncol = H)
loss_list[[9]] <- matrix(rnorm(Trow*H, mean = 2), nrow = Trow, ncol = H)
loss_list[[10]] <- matrix(rnorm(Trow*H, mean = 1), nrow = Trow, ncol = H)
num_cores <- 1
seed <- 42
FastMultiHorizonMCS(loss_list, #
0.05, # alpha_t
0.05, # alpha_mcs
weights, #
3,#l
5,#b
"u", # 1 means uniform
num_cores,
seed)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.