Вот мое решение, которое можно было бы улучшить в различных измерениях, чтобы оно было аккуратным .
Требуется много ручных операций:
- Iпреобразовать
tsibble
в ts
объект и вручную указать даты для ts
. Это кажется неэффективным. - Я указываю столбцы вручную
df_unclean[, 2:14]
, чтобы применить tsclean
.
library(fable)
#> Loading required package: fabletools
library(tidyverse)
df <- structure(list(date = structure(c(
11413, 11504, 11596, 11688,
11778, 11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509,
12600, 12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330,
13422, 13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153,
14245, 14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975,
15065, 15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796,
15887, 15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617,
16709, 16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440,
17532, 17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778,
11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600,
12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422,
13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245,
14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065,
15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887,
15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709,
16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532,
17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869,
11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692,
12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514,
13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335,
14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156,
15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979,
16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801,
16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622,
17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869, 11961,
12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692, 12784,
12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514, 13604,
13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335, 14426,
14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156, 15248,
15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979, 16071,
16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801, 16892,
16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622, 17713,
17805, 11413, 11504, 11596, 11688, 11778, 11869, 11961, 12053,
12143, 12234, 12326, 12418, 12509, 12600, 12692, 12784, 12874,
12965, 13057, 13149, 13239, 13330, 13422, 13514, 13604, 13695,
13787, 13879, 13970, 14061, 14153, 14245, 14335, 14426, 14518,
14610, 14700, 14791, 14883, 14975, 15065, 15156, 15248, 15340,
15431, 15522, 15614, 15706, 15796, 15887, 15979, 16071, 16161,
16252, 16344, 16436, 16526, 16617, 16709, 16801, 16892, 16983,
17075, 17167, 17257, 17348, 17440, 17532, 17622, 17713, 17805,
11413, 11504, 11596, 11688, 11778, 11869, 11961, 12053, 12143,
12234, 12326, 12418, 12509, 12600, 12692, 12784, 12874, 12965,
13057, 13149, 13239, 13330, 13422, 13514, 13604, 13695, 13787,
13879, 13970, 14061, 14153, 14245, 14335, 14426, 14518, 14610,
14700, 14791, 14883, 14975, 15065, 15156, 15248, 15340, 15431,
15522, 15614, 15706, 15796, 15887, 15979, 16071, 16161, 16252,
16344, 16436, 16526, 16617, 16709, 16801, 16892, 16983, 17075,
17167, 17257, 17348, 17440, 17532, 17622, 17713, 17805, 11413,
11504, 11596, 11688, 11778, 11869, 11961, 12053, 12143, 12234,
12326, 12418, 12509, 12600, 12692, 12784, 12874, 12965, 13057,
13149, 13239, 13330, 13422, 13514, 13604, 13695, 13787, 13879,
13970, 14061, 14153, 14245, 14335, 14426, 14518, 14610, 14700,
14791, 14883, 14975, 15065, 15156, 15248, 15340, 15431, 15522,
15614, 15706, 15796, 15887, 15979, 16071, 16161, 16252, 16344,
16436, 16526, 16617, 16709, 16801, 16892, 16983, 17075, 17167,
17257, 17348, 17440, 17532, 17622, 17713, 17805, 11413, 11504,
11596, 11688, 11778, 11869, 11961, 12053, 12143, 12234, 12326,
12418, 12509, 12600, 12692, 12784, 12874, 12965, 13057, 13149,
13239, 13330, 13422, 13514, 13604, 13695, 13787, 13879, 13970,
14061, 14153, 14245, 14335, 14426, 14518, 14610, 14700, 14791,
14883, 14975, 15065, 15156, 15248, 15340, 15431, 15522, 15614,
15706, 15796, 15887, 15979, 16071, 16161, 16252, 16344, 16436,
16526, 16617, 16709, 16801, 16892, 16983, 17075, 17167, 17257,
17348, 17440, 17532, 17622, 17713, 17805, 11413, 11504, 11596,
11688, 11778, 11869, 11961, 12053, 12143, 12234, 12326, 12418,
12509, 12600, 12692, 12784, 12874, 12965, 13057, 13149, 13239,
13330, 13422, 13514, 13604, 13695, 13787, 13879, 13970, 14061,
14153, 14245, 14335, 14426, 14518, 14610, 14700, 14791, 14883,
14975, 15065, 15156, 15248, 15340, 15431, 15522, 15614, 15706,
15796, 15887, 15979, 16071, 16161, 16252, 16344, 16436, 16526,
16617, 16709, 16801, 16892, 16983, 17075, 17167, 17257, 17348,
17440, 17532, 17622, 17713, 17805, 11413, 11504, 11596, 11688,
11778, 11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509,
12600, 12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330,
13422, 13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153,
14245, 14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975,
15065, 15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796,
15887, 15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617,
16709, 16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440,
17532, 17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778,
11869, 11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600,
12692, 12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422,
13514, 13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245,
14335, 14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065,
15156, 15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887,
15979, 16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709,
16801, 16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532,
17622, 17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869,
11961, 12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692,
12784, 12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514,
13604, 13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335,
14426, 14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156,
15248, 15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979,
16071, 16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801,
16892, 16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622,
17713, 17805, 11413, 11504, 11596, 11688, 11778, 11869, 11961,
12053, 12143, 12234, 12326, 12418, 12509, 12600, 12692, 12784,
12874, 12965, 13057, 13149, 13239, 13330, 13422, 13514, 13604,
13695, 13787, 13879, 13970, 14061, 14153, 14245, 14335, 14426,
14518, 14610, 14700, 14791, 14883, 14975, 15065, 15156, 15248,
15340, 15431, 15522, 15614, 15706, 15796, 15887, 15979, 16071,
16161, 16252, 16344, 16436, 16526, 16617, 16709, 16801, 16892,
16983, 17075, 17167, 17257, 17348, 17440, 17532, 17622, 17713,
17805
), class = c("yearquarter", "Date")), Series = c(
"10", "10",
"10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
"10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
"10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
"10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
"10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
"10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10",
"10", "10", "10", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "101", "101", "101", "101", "101", "101", "101", "101",
"101", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1011", "1011", "1011", "1011", "1011", "1011", "1011", "1011",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1012",
"1012", "1012", "1012", "1012", "1012", "1012", "1012", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "1013", "1013",
"1013", "1013", "1013", "1013", "1013", "1013", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "102", "102", "102",
"102", "102", "102", "102", "102", "102", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1021", "1021", "1021", "1021",
"1021", "1021", "1021", "1021", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1022", "1022", "1022", "1022", "1022",
"1022", "1022", "1022", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1023", "1023", "1023", "1023", "1023", "1023",
"1023", "1023", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1025", "1025", "1025", "1025", "1025", "1025", "1025",
"1025", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1026", "1026", "1026", "1026", "1026", "1026", "1026", "1026",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1027",
"1027", "1027", "1027", "1027", "1027", "1027", "1027", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029", "1029", "1029",
"1029", "1029", "1029", "1029", "1029", "1029"
), value = c(
0.4,
0.6, 0.5, -0.1, 0.2, 0.8, 0.7, 0.1, 0.2, 0.4, 0.5, 0.1, 0.1,
1, 0.9, 0.1, 0.6, 1.1, 0.6, 0.3, 0.4, 1.1, 1, -0.6, 0.8, 0.9,
0.7, -0.5, 0.3, 0.5, 0.3, -1.9, 0.2, 0.4, 0.2, -1.3, 0.4, 0.6,
0.6, -0.9, 0.6, 0.7, 0.6, -1.7, 2, -0.6, 0.5, -0.7, 0.8, 0.7,
0.6, -0.1, 0.3, 0.7, 0.9, -0.6, 0.6, 1, 0.9, -0.5, 0.8, 0.9,
0.7, -1.1, 1, 0.7, 0.8, -0.5, 0.8, 0.7, 1, 0.6, 0.6, 0.2, -0.9,
0.3, 0.5, 0.2, -0.9, 0.3, -0.2, -0.2, 0, 0.5, 0.6, 0.5, -0.1,
0.8, 0.8, 0.4, 0, 0.9, 0.7, 0.5, -0.6, 0.6, 0.5, -0.1, -0.8,
0.1, -0.1, -0.6, -2.9, -0.7, -0.3, -1, -2.4, 0, -0.2, -0.4, -2.2,
0, 0, -0.4, -1.2, 0, 0.2, 0.1, -1, 0.4, 0.7, 0.1, -0.4, 0.9,
0.6, 0.4, -0.5, 0.6, 0.6, 0.4, -0.5, 0.8, 0.6, 0.4, -1.1, 1.2,
0.7, 0.5, 0.2, 1, 0.7, 0.7, -0.1, 0.4, -0.1, -1.3,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
0.9, 2.1, 1.9, 0.5, -0.7, 2.1, 2.1, 1.4, -0.9, 1.7, 1.4, -0.3,
-1.4, 1.9, 1.7, -0.3, -1.1, 1.8, 1.5, 0, -1.3, 2, 1.8, -2.7,
2, 2.2, 1.9, -2.7, 2, 2.3, 1.7, -2.7, 1.7, 2.2, 1.5, -2.8, 1.6,
1.8, 1.8, -0.2, 1.5, 1.6, 1, -8, 11.4, -7.3, 0.4, -38.4, 0.4,
0.6, 0.2, 0.1, 1.2, 0.9, 0.5, -0.4, 0.3, 0.9, 0.4, -0.6, 0.6,
0.7, 0.4, -1.4, 1.3, 0.9, 0.4, -0.3, 0.8, 0.8, 0.5, -6.9, -8.7,
-11.4, 1.9, 0.4, 3.4, 0.6, 1.6, 0.6, 5, 8.7, 3, -6.4, 15.2, 10.8,
1.2, 2.1, 9.7, -3.7, -6.2, -7.1, 7.3, 4.9, -8.1, -0.4, 1.9, 8,
3.6, -8.7, 1.8, -3, -13.2, 4.7, 0.8, 7.1, -5.3, -9.8, 3.8, 7.8,
-4.7, 1.8, 2.3, 12.4, -14.8, 7.6, 7.9, 3.4, -13.2, 4.1, -4.1,
10.3, -0.8, -12.1, 6.3, 13.9, -14.7, 5.1, 6.4, 11.2, -7.1, 5.1,
17.1, 1.4, -15.4, -3.5, -4.8, 9.2, -34.6, 0.1, 3.1, 7.9
)), row.names = c(
NA,
-923L
), key = structure(list(Series = c(
"10", "101", "1011",
"1012", "1013", "102", "1021", "1022", "1023", "1025", "1026",
"1027", "1029"
), .rows = list(
1:71, 72:142, 143:213, 214:284,
285:355, 356:426, 427:497, 498:568, 569:639, 640:710, 711:781,
782:852, 853:923
)), row.names = c(NA, -13L), class = c(
"tbl_df",
"tbl", "data.frame"
), .drop = TRUE), index = structure("date", ordered = TRUE), index2 = "date", interval = structure(list(
year = 0, quarter = 1, month = 0, week = 0, day = 0, hour = 0,
minute = 0, second = 0, millisecond = 0, microsecond = 0,
nanosecond = 0, unit = 0
), class = "interval"), class = c(
"tbl_ts",
"tbl_df", "tbl", "data.frame"
))
df
#> # A tsibble: 923 x 3 [1Q]
#> # Key: Series [13]
#> date Series value
#> <qtr> <chr> <dbl>
#> 1 2001 Q2 10 0.4
#> 2 2001 Q3 10 0.6
#> 3 2001 Q4 10 0.5
#> 4 2002 Q1 10 -0.1
#> 5 2002 Q2 10 0.2
#> 6 2002 Q3 10 0.8
#> 7 2002 Q4 10 0.7
#> 8 2003 Q1 10 0.1
#> 9 2003 Q2 10 0.2
#> 10 2003 Q3 10 0.4
#> # ... with 913 more rows
df_unclean <- df %>%
pivot_wider(names_from = Series, values_from = value) %>%
as.data.frame() %>%
ts(frequency = 4, start = c(2001, 2), end = c(2018, 4))
df_clean <- sapply(X = df_unclean[, 2:14], FUN = forecast::tsclean) %>%
as_tibble() %>%
mutate(
date = tsibble::yearquarter(seq(as.Date("2001/04/1"),
as.Date("2018/10/1"), by = "quarter"))
) %>%
pivot_longer(-date, names_to = "sector", values_to = "diff") %>%
as_tsibble(index = date, key = sector)
#> Registered S3 method overwritten by 'xts':
#> method from
#> as.zoo.xts zoo
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
#> Registered S3 methods overwritten by 'forecast':
#> method from
#> fitted.fracdiff fracdiff
#> residuals.fracdiff fracdiff
df_clean
#> # A tsibble: 923 x 3 [1Q]
#> # Key: sector [13]
#> date sector diff
#> <qtr> <chr> <dbl>
#> 1 2001 Q2 10 0.4
#> 2 2001 Q3 10 0.6
#> 3 2001 Q4 10 0.5
#> 4 2002 Q1 10 -0.1
#> 5 2002 Q2 10 0.2
#> 6 2002 Q3 10 0.8
#> 7 2002 Q4 10 0.7
#> 8 2003 Q1 10 -0.901
#> 9 2003 Q2 10 0.2
#> 10 2003 Q3 10 0.4
#> # ... with 913 more rows
Создано в 2019-11-26 Представить пакет (v0.3.0)