stretch_tsibble()stretch_tsibble() can be used to create many training sets.
.init defines length of initial training set..step defines by how much each successive training set increases in length.stretch_tsibble() with .init=3 and .step=1.relocate() to put index variables up front:google_2015_tr <- google_2015 |>
stretch_tsibble(.init = 3, .step = 1) |>
relocate(Date, Symbol, .id)
google_2015_tr# A tsibble: 31,875 x 10 [1]
# Key: Symbol, .id [250]
Date Symbol .id Open High Low Close Adj_Close Volume day
<date> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
1 2015-01-02 GOOG 1 526. 528. 521. 522. 522. 1447600 1
2 2015-01-05 GOOG 1 520. 521. 510. 511. 511. 2059800 2
3 2015-01-06 GOOG 1 512. 513. 498. 499. 499. 2899900 3
4 2015-01-02 GOOG 2 526. 528. 521. 522. 522. 1447600 1
5 2015-01-05 GOOG 2 520. 521. 510. 511. 511. 2059800 2
6 2015-01-06 GOOG 2 512. 513. 498. 499. 499. 2899900 3
7 2015-01-07 GOOG 2 504. 504. 497. 498. 498. 2065100 4
8 2015-01-02 GOOG 3 526. 528. 521. 522. 522. 1447600 1
9 2015-01-05 GOOG 3 520. 521. 510. 511. 511. 2059800 2
10 2015-01-06 GOOG 3 512. 513. 498. 499. 499. 2899900 3
# ℹ 31,865 more rows
accuracy() to evaluate forecast accuracy across training sets:# A tibble: 1 × 11
.model Symbol .type ME RMSE MAE MPE MAPE MASE RMSSE ACF1
<chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 RW(Close ~ drif… GOOG Test 0.726 11.3 7.26 0.112 1.19 1.02 1.01 0.0985
# A tibble: 8 × 11
h .model .type ME RMSE MAE MPE MAPE MASE RMSSE ACF1
<int> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 RW(Close ~ drift… Test 0.726 11.3 7.26 0.112 1.19 1.02 1.01 0.0985
2 2 RW(Close ~ drift… Test 1.52 16.9 11.0 0.228 1.82 1.54 1.51 0.509
3 3 RW(Close ~ drift… Test 2.34 20.7 14.0 0.350 2.32 1.96 1.85 0.668
4 4 RW(Close ~ drift… Test 3.15 23.7 16.0 0.474 2.65 2.24 2.12 0.749
5 5 RW(Close ~ drift… Test 3.93 26.4 17.7 0.596 2.94 2.48 2.36 0.791
6 6 RW(Close ~ drift… Test 4.71 28.7 19.3 0.718 3.21 2.71 2.57 0.827
7 7 RW(Close ~ drift… Test 5.49 31.2 21.3 0.837 3.53 2.99 2.79 0.833
8 8 RW(Close ~ drift… Test 6.27 33.3 22.6 0.958 3.75 3.17 2.98 0.848
