1 Для нашего примера (example 1)

1.1 Load data

ts <- read.csv("https://raw.githubusercontent.com/forvis/forvision_data/master/example1_TSTS.csv", stringsAsFactors = FALSE)
fs <- read.csv("https://raw.githubusercontent.com/forvis/forvision_data/master/example1_FTS.csv", stringsAsFactors = FALSE)
head(ts)
##   series_id   value timestamp
## 1        Y1 3103.96      1984
## 2        Y1 3360.27      1985
## 3        Y1 3807.63      1986
## 4        Y1 4387.88      1987
## 5        Y1 4936.99      1988
## 6        Y1 5379.75      1989
head(fs)
##   series_id method timestamp origin_timestamp forecast horizon     lo90
## 1        Y1      A      1989             1988  5406.43       1 5183.349
## 2        Y1      A      1990             1988  5875.96       2 5652.879
## 3        Y1      A      1991             1988  6345.48       3 6122.399
## 4        Y1      A      1990             1989  5946.48       1 6122.399
## 5        Y1      A      1991             1989  6145.48       2 6122.399
## 6        Y1      A      1991             1990  6445.48       1 6122.399
##       hi90
## 1 5629.511
## 2 6099.041
## 3 6568.561
## 4 6568.561
## 5 6568.561
## 6 6568.561

1.2 Создание AFTS без NAs и вычисление MAPEs:

library(forvision)
afts <- createAFTS(ts = ts, fs =fs, na = FALSE)
calculateMAPEs(afts)

## $MAPE
##   horizon = 1 horizon = 2 horizon = 3  average MAPE
## A    6.789741    8.930584    10.85635      8.858893
## B    7.923620    9.478999    13.58108     10.327900
## C    7.195727    9.025229    10.85635      9.025769
## 
## $rank
##   horizon = 1 horizon = 2 horizon = 3 average rank
## A           1           1         1.5     1.166667
## B           3           3         3.0     3.000000
## C           2           2         1.5     1.833333

2 Что происходит в случае нулевые или отрицательных value?

afts2 <- afts
afts2[1, 2] = 0
head(afts2)
##   series_id   value timestamp method origin_timestamp forecast horizon
## 1        Y1    0.00      1989      A             1988  5406.43       1
## 2        Y1 5379.75      1989      B             1988  5473.87       1
## 3        Y1 5379.75      1989      C             1988  5406.43       1
## 4        Y1 6158.68      1990      A             1988  5875.96       2
## 5        Y1 6158.68      1990      A             1989  5946.48       1
## 6        Y1 6158.68      1990      B             1988  6010.43       2
##       lo90     hi90
## 1 5183.349 5629.511
## 2 5250.789 5696.951
## 3 5183.349 5629.511
## 4 5652.879 6099.041
## 5 6122.399 6568.561
## 6 5787.349 6233.511
calculateMAPEs(afts2)

Error in calculateMAPEs(afts2) : The column value has negative values or zero.

3 Что происходит в случае Inf/-Inf value?

afts3 <- afts
afts3[1, 2] = Inf
head(afts3)
##   series_id   value timestamp method origin_timestamp forecast horizon
## 1        Y1     Inf      1989      A             1988  5406.43       1
## 2        Y1 5379.75      1989      B             1988  5473.87       1
## 3        Y1 5379.75      1989      C             1988  5406.43       1
## 4        Y1 6158.68      1990      A             1988  5875.96       2
## 5        Y1 6158.68      1990      A             1989  5946.48       1
## 6        Y1 6158.68      1990      B             1988  6010.43       2
##       lo90     hi90
## 1 5183.349 5629.511
## 2 5250.789 5696.951
## 3 5183.349 5629.511
## 4 5652.879 6099.041
## 5 6122.399 6568.561
## 6 5787.349 6233.511
calculateMAPEs(afts3)

Error in calculateMAPEs(afts3) : The column value has Inf or -Inf values.

4 Что происходит в случае NA, NAN value?

afts4 <- afts
afts4[1, 2] = NA
head(afts4)
##   series_id   value timestamp method origin_timestamp forecast horizon
## 1        Y1      NA      1989      A             1988  5406.43       1
## 2        Y1 5379.75      1989      B             1988  5473.87       1
## 3        Y1 5379.75      1989      C             1988  5406.43       1
## 4        Y1 6158.68      1990      A             1988  5875.96       2
## 5        Y1 6158.68      1990      A             1989  5946.48       1
## 6        Y1 6158.68      1990      B             1988  6010.43       2
##       lo90     hi90
## 1 5183.349 5629.511
## 2 5250.789 5696.951
## 3 5183.349 5629.511
## 4 5652.879 6099.041
## 5 6122.399 6568.561
## 6 5787.349 6233.511
calculateMAPEs(afts4)

Error in calculateMAPEs(afts4) : The column value has NA values