robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.13k stars 342 forks source link

duplicate index tsoutliers() #835

Closed jmablans closed 4 years ago

jmablans commented 4 years ago

When applying tsoutliers() to the following time series:

>dput(ts)
structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 8, 0, 9, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
10, 0, 0,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 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 
0, 0, 0, 0, 50, 0, 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 5, 0, 0, 
0, 0, 0, 0, 30, 15, 0, 0, 0, 0, 0, 0, 13, 50, 35, 0, 15, 0, 0, 
0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 84, 24, 0, 0, 
0, 0, 125, 0, 0, 82, 0, 0, 0, 7, 0, 118, 0, 0, 0, 40, 192, 122, 
15, 50, 0, 0, 53), index = structure(c(17150, 17151, 17152, 17153, 
17154, 17155, 17156, 17157, 17158, 17159, 17160, 17161, 17162, 
17163, 17164, 17165, 17166, 17167, 17168, 17169, 17170, 17171, 
17172, 17173, 17174, 17175, 17176, 17177, 17178, 17179, 17180, 
17181, 17182, 17183, 17184, 17185, 17186, 17187, 17188, 17189, 
17190, 17191, 17192, 17193, 17194, 17195, 17196, 17197, 17198, 
17199, 17200, 17201, 17202, 17203, 17204, 17205, 17206, 17207, 
17208, 17209, 17210, 17211, 17212, 17213, 17214, 17215, 17216, 
17217, 17218, 17219, 17220, 17221, 17222, 17223, 17224, 17225, 
17226, 17227, 17228, 17229, 17230, 17231, 17232, 17233, 17234, 
17235, 17236, 17237, 17238, 17239, 17240, 17241, 17242, 17243, 
17244, 17245, 17246, 17247, 17248, 17249, 17250, 17251, 17252, 
17253, 17254, 17255, 17256, 17257, 17258, 17259, 17260, 17261, 
17262, 17263, 17264, 17265, 17266, 17267, 17268, 17269, 17270, 
17271, 17272, 17273, 17274, 17275, 17276, 17277, 17278, 17279, 
17280, 17281, 17282, 17283, 17284, 17285, 17286, 17287, 17288, 
17289, 17290, 17291, 17292, 17293, 17294, 17295, 17296, 17297, 
17298, 17299, 17300, 17301, 17302, 17303, 17304, 17305, 17306, 
17307, 17308, 17309, 17310, 17311, 17312, 17313, 17314, 17315, 
17316, 17317, 17318, 17319, 17320, 17321, 17322, 17323, 17324, 
17325, 17326, 17327, 17328, 17329, 17330, 17331, 17332, 17333, 
17334, 17335, 17336, 17337, 17338, 17339, 17340, 17341, 17342, 
17343, 17344, 17345, 17346, 17347, 17348, 17349, 17350, 17351, 
17352, 17353, 17354, 17355, 17356, 17357, 17358, 17359, 17360, 
17361, 17362, 17363, 17364, 17365, 17366, 17367, 17368, 17369, 
17370, 17371, 17372, 17373, 17374, 17375, 17376, 17377, 17378, 
17379, 17380, 17381, 17382, 17383, 17384, 17385, 17386, 17387, 
17388, 17389, 17390, 17391, 17392, 17393, 17394, 17395, 17396, 
17397, 17398, 17399, 17400, 17401, 17402, 17403, 17404, 17405, 
17406, 17407, 17408, 17409, 17410, 17411, 17412, 17413, 17414, 
17415, 17416, 17417, 17418, 17419, 17420, 17421, 17422, 17423, 
17424, 17425, 17426, 17427, 17428, 17429, 17430, 17431, 17432, 
17433, 17434, 17435, 17436, 17437, 17438, 17439, 17440, 17441, 
17442, 17443, 17444, 17445, 17446, 17447, 17448, 17449, 17450, 
17451, 17452, 17453, 17454, 17455, 17456, 17457, 17458, 17459, 
17460, 17461, 17462, 17463, 17464, 17465, 17466, 17467, 17468, 
17469, 17470, 17471, 17472, 17473, 17474, 17475, 17476, 17477, 
17478, 17479, 17480, 17481, 17482, 17483, 17484, 17485, 17486, 
17487, 17488, 17489, 17490, 17491, 17492, 17493, 17494, 17495, 
17496, 17497, 17498, 17499, 17500, 17501, 17502, 17503, 17504, 
17505, 17506, 17507, 17508, 17509, 17510, 17511, 17512, 17513, 
17514, 17515, 17516, 17517, 17518, 17519, 17520, 17521, 17522, 
17523, 17524, 17525, 17526, 17527, 17528, 17529, 17530, 17531, 
17532, 17533, 17534, 17535, 17536, 17537, 17538, 17539, 17540, 
17541, 17542, 17543, 17544, 17545, 17546, 17547, 17548, 17549, 
17550, 17551, 17552, 17553, 17554, 17555, 17556, 17557, 17558, 
17559, 17560, 17561, 17562, 17563, 17564, 17565, 17566, 17567, 
17568, 17569, 17570, 17571, 17572, 17573, 17574, 17575, 17576, 
17577, 17578, 17579, 17580, 17581, 17582, 17583, 17584, 17585, 
17586, 17587, 17588, 17589, 17590, 17591, 17592, 17593, 17594, 
17595, 17596, 17597, 17598, 17599, 17600, 17601, 17602, 17603, 
17604, 17605, 17606, 17607, 17608, 17609, 17610, 17611, 17612, 
17613, 17614, 17615, 17616, 17617, 17618, 17619, 17620, 17621, 
17622, 17623, 17624, 17625, 17626, 17627, 17628, 17629, 17630, 
17631, 17632, 17633, 17634, 17635, 17636, 17637, 17638, 17639, 
17640, 17641, 17642, 17643, 17644, 17645, 17646, 17647, 17648, 
17649, 17650, 17651, 17652, 17653, 17654, 17655, 17656, 17657, 
17658, 17659, 17660, 17661, 17662, 17663, 17664, 17665, 17666, 
17667, 17668, 17669, 17670, 17671, 17672, 17673, 17674, 17675, 
17676, 17677, 17678, 17679, 17680, 17681, 17682, 17683, 17684, 
17685, 17686, 17687, 17688, 17689, 17690, 17691, 17692, 17693, 
17694, 17695, 17696, 17697, 17698, 17699, 17700, 17701, 17702, 
17703, 17704, 17705, 17706, 17707, 17708, 17709, 17710, 17711, 
17712, 17713, 17714, 17715, 17716, 17717, 17718, 17719, 17720, 
17721, 17722, 17723, 17724, 17725, 17726, 17727, 17728, 17729, 
17730, 17731, 17732, 17733, 17734, 17735, 17736, 17737, 17738, 
17739, 17740, 17741, 17742, 17743, 17744, 17745, 17746, 17747, 
17748, 17749, 17750, 17751, 17752, 17753, 17754, 17755, 17756, 
17757, 17758, 17759, 17760, 17761, 17762, 17763, 17764, 17765, 
17766, 17767, 17768, 17769, 17770, 17771, 17772, 17773, 17774, 
17775, 17776, 17777, 17778, 17779, 17780, 17781, 17782, 17783, 
17784, 17785, 17786, 17787, 17788, 17789, 17790, 17791, 17792, 
17793, 17794, 17795, 17796, 17797, 17798, 17799, 17800, 17801, 
17802, 17803, 17804, 17805, 17806, 17807, 17808, 17809, 17810, 
17811, 17812, 17813, 17814, 17815, 17816, 17817, 17818, 17819, 
17820, 17821, 17822, 17823, 17824, 17825, 17826, 17827, 17828, 
17829, 17830, 17831, 17832, 17833, 17834, 17835, 17836, 17837, 
17838, 17839, 17840, 17841, 17842, 17843, 17844, 17845, 17846, 
17847, 17848, 17849, 17850, 17851, 17852, 17853, 17854, 17855, 
17856, 17857, 17858, 17859, 17860, 17861, 17862, 17863, 17864, 
17865, 17866, 17867, 17868, 17869, 17870, 17871, 17872, 17873, 
17874, 17875, 17876, 17877, 17878, 17879, 17880, 17881, 17882, 
17883, 17884, 17885, 17886, 17887, 17888, 17889, 17890, 17891, 
17892, 17893, 17894, 17895, 17896, 17897, 17898, 17899, 17900, 
17901, 17902, 17903, 17904, 17905, 17906, 17907, 17908, 17909, 
17910, 17911, 17912, 17913, 17914, 17915, 17916, 17917, 17918, 
17919, 17920, 17921, 17922, 17923, 17924, 17925, 17926, 17927, 
17928, 17929, 17930, 17931, 17932, 17933, 17934, 17935, 17936, 
17937, 17938, 17939, 17940, 17941, 17942, 17943, 17944, 17945, 
17946, 17947, 17948, 17949, 17950, 17951, 17952, 17953, 17954, 
17955, 17956, 17957, 17958, 17959, 17960, 17961, 17962, 17963, 
17964, 17965, 17966, 17967, 17968, 17969, 17970, 17971, 17972, 
17973, 17974, 17975, 17976, 17977, 17978, 17979, 17980, 17981, 
17982, 17983, 17984, 17985, 17986, 17987, 17988, 17989, 17990, 
17991, 17992, 17993, 17994, 17995, 17996, 17997, 17998, 17999, 
18000, 18001, 18002, 18003, 18004, 18005, 18006, 18007, 18008, 
18009, 18010, 18011, 18012, 18013, 18014, 18015, 18016, 18017, 
18018, 18019, 18020, 18021, 18022, 18023, 18024, 18025, 18026, 
18027, 18028, 18029, 18030, 18031, 18032, 18033, 18034, 18035, 
18036, 18037, 18038, 18039, 18040, 18041, 18042, 18043, 18044, 
18045, 18046, 18047, 18048, 18049, 18050, 18051, 18052, 18053, 
18054, 18055, 18056, 18057, 18058, 18059, 18060, 18061, 18062, 
18063, 18064, 18065, 18066, 18067, 18068, 18069, 18070, 18071, 
18072, 18073, 18074, 18075, 18076, 18077, 18078, 18079, 18080, 
18081, 18082, 18083, 18084, 18085, 18086, 18087, 18088, 18089, 
18090, 18091, 18092, 18093, 18094, 18095, 18096, 18097, 18098, 
18099, 18100, 18101, 18102, 18103, 18104, 18105, 18106, 18107, 
18108, 18109, 18110, 18111, 18112, 18113, 18114, 18115, 18116, 
18117, 18118, 18119, 18120, 18121, 18122, 18123, 18124, 18125, 
18126, 18127, 18128, 18129, 18130, 18131, 18132, 18133, 18134, 
18135, 18136, 18137, 18138, 18139, 18140, 18141, 18142, 18143, 
18144, 18145, 18146, 18147, 18148, 18149, 18150, 18151, 18152, 
18153, 18154, 18155, 18156, 18157, 18158, 18159, 18160, 18161, 
18162, 18163, 18164, 18165, 18166, 18167, 18168, 18169, 18170, 
18171, 18172, 18173, 18174, 18175, 18176, 18177, 18178, 18179, 
18180, 18181, 18182, 18183, 18184, 18185, 18186, 18187, 18188, 
18189, 18190, 18191, 18192, 18193, 18194, 18195, 18196, 18197, 
18198, 18199, 18200, 18201, 18202, 18203, 18204), class = "Date"), class = "zoo")

and calling

outliers <- forecast::tsoutliers(ts)

the following indexes are returned and multiple indeces are returned twice (e.g. 307):

> dput(outliers$index)
c(41L, 73L, 75L, 274L, 292L, 294L, 295L, 296L, 297L, 298L, 300L, 
301L, 302L, 303L, 304L, 305L, 306L, 307L, 307L, 309L, 310L, 311L, 
312L, 313L, 314L, 315L, 316L, 317L, 318L, 318L, 319L, 319L, 320L, 
320L, 321L, 321L, 322L, 322L, 323L, 324L, 324L, 325L, 325L, 326L, 
326L, 327L, 327L, 328L, 328L, 329L, 330L, 331L, 331L, 332L, 332L, 
333L, 334L, 334L, 335L, 335L, 336L, 336L, 337L, 337L, 338L, 338L, 
339L, 339L, 340L, 342L, 343L, 343L, 344L, 344L, 345L, 345L, 346L, 
346L, 347L, 347L, 348L, 348L, 349L, 349L, 350L, 350L, 351L, 352L, 
353L, 353L, 354L, 354L, 355L, 355L, 356L, 356L, 357L, 357L, 358L, 
358L, 359L, 359L, 360L, 360L, 361L, 361L, 362L, 362L, 363L, 363L, 
364L, 364L, 365L, 365L, 366L, 366L, 367L, 367L, 368L, 368L, 369L, 
369L, 370L, 370L, 371L, 372L, 372L, 373L, 374L, 374L, 375L, 375L, 
376L, 376L, 377L, 377L, 378L, 378L, 379L, 379L, 380L, 380L, 381L, 
381L, 382L, 382L, 383L, 383L, 384L, 384L, 385L, 385L, 386L, 386L, 
387L, 387L, 388L, 388L, 389L, 389L, 390L, 391L, 392L, 393L, 394L, 
395L, 395L, 396L, 396L, 397L, 397L, 398L, 398L, 399L, 399L, 400L, 
400L, 401L, 401L, 402L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 
409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 419L, 
420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 431L, 451L, 472L, 
474L, 519L, 530L, 548L, 551L, 552L, 554L, 559L, 568L, 575L, 582L, 
600L, 621L, 625L, 637L, 638L, 639L, 640L, 641L, 642L, 643L, 644L, 
645L, 646L, 647L, 648L, 649L, 650L, 651L, 652L, 652L, 653L, 654L, 
655L, 656L, 657L, 658L, 659L, 660L, 661L, 662L, 663L, 663L, 664L, 
664L, 666L, 667L, 667L, 668L, 668L, 669L, 669L, 670L, 670L, 671L, 
671L, 672L, 673L, 673L, 674L, 674L, 675L, 675L, 676L, 676L, 677L, 
677L, 678L, 678L, 679L, 679L, 680L, 680L, 681L, 682L, 683L, 684L, 
685L, 686L, 687L, 687L, 688L, 688L, 689L, 689L, 690L, 690L, 691L, 
691L, 692L, 692L, 693L, 694L, 694L, 695L, 695L, 696L, 696L, 697L, 
697L, 698L, 698L, 699L, 699L, 700L, 700L, 701L, 701L, 702L, 702L, 
703L, 703L, 704L, 704L, 705L, 705L, 706L, 706L, 707L, 707L, 708L, 
708L, 709L, 709L, 710L, 710L, 711L, 711L, 712L, 712L, 713L, 713L, 
714L, 714L, 715L, 715L, 716L, 716L, 717L, 717L, 718L, 718L, 719L, 
719L, 720L, 720L, 721L, 721L, 722L, 722L, 723L, 723L, 724L, 724L, 
725L, 726L, 726L, 727L, 727L, 728L, 728L, 729L, 729L, 730L, 730L, 
731L, 731L, 732L, 732L, 733L, 733L, 734L, 734L, 735L, 735L, 736L, 
736L, 737L, 737L, 738L, 738L, 739L, 739L, 740L, 740L, 741L, 741L, 
742L, 742L, 743L, 743L, 744L, 744L, 745L, 745L, 746L, 746L, 747L, 
747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L, 756L, 
757L, 757L, 758L, 758L, 759L, 759L, 760L, 760L, 761L, 761L, 762L, 
762L, 763L, 763L, 764L, 764L, 765L, 765L, 766L, 766L, 767L, 767L, 
768L, 768L, 769L, 770L, 770L, 771L, 772L, 773L, 774L, 775L, 776L, 
777L, 778L, 779L, 780L, 781L, 782L, 783L, 784L, 785L, 786L, 787L, 
788L, 789L, 790L, 791L, 792L, 793L, 794L, 799L, 924L, 979L, 981L, 
999L, 1000L, 1007L, 1008L, 1008L, 1009L, 1011L, 1015L, 1027L, 
1029L, 1029L, 1030L, 1035L, 1038L, 1044L, 1048L, 1049L, 1049L, 
1050L, 1050L, 1051L, 1052L, 1055L)
Session info

``` R version 3.6.1 (2019-07-05) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.6 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] timeDate_3043.102 forecastHybrid_4.2.17 thief_0.3 caret_6.0-84 [5] ggplot2_3.2.1 lattice_0.20-38 zoo_1.8-6 prophet_0.5 [9] rlang_0.4.1 Rcpp_1.0.3 tsintermittent_1.9 MAPA_2.0.4 [13] smooth_2.5.4 greybox_0.5.6 RColorBrewer_1.1-2 forecast_8.9 [17] data.table_1.12.6 bigrquery_1.2.0 RPostgreSQL_0.6-2 DBI_1.0.0 loaded via a namespace (and not attached): [1] tseries_0.10-47 httr_1.4.1 bit64_0.9-7 jsonlite_1.6 [5] splines_3.6.1 foreach_1.4.7 prodlim_2019.11.13 StanHeaders_2.19.0 [9] RcppParallel_4.4.4 assertthat_0.2.1 TTR_0.23-5 stats4_3.6.1 [13] ipred_0.9-9 numDeriv_2016.8-1.1 pillar_1.4.2 glue_1.3.1 [17] quadprog_1.5-7 colorspace_1.4-1 recipes_0.1.7 Matrix_1.2-17 [21] plyr_1.8.4 pkgconfig_2.0.3 rstan_2.19.2 purrr_0.3.3 [25] scales_1.1.0 processx_3.4.1 gower_0.2.1 lava_1.6.6 [29] tibble_2.1.3 generics_0.0.2 xgboost_0.90.0.2 withr_2.1.2 [33] urca_1.3-0 lamW_1.3.0 nnet_7.3-12 lazyeval_0.2.2 [37] cli_1.1.0 quantmod_0.4-15 survival_2.44-1.1 magrittr_1.5 [41] crayon_1.3.4 ps_1.3.0 doParallel_1.0.15 nlme_3.1-140 [45] MASS_7.3-51.4 xts_0.11-2 class_7.3-15 pkgbuild_1.0.6 [49] loo_2.1.0 prettyunits_1.0.2 tools_3.6.1 matrixStats_0.55.0 [53] lifecycle_0.1.0 stringr_1.4.0 munsell_0.5.0 callr_3.3.2 [57] compiler_3.6.1 grid_3.6.1 nloptr_1.2.1 iterators_1.0.12 [61] gtable_0.3.0 ModelMetrics_1.2.2 codetools_0.2-16 fracdiff_1.4-2 [65] inline_0.3.15 curl_4.2 reshape2_1.4.3 R6_2.4.1 [69] gridExtra_2.3 lubridate_1.7.4 dplyr_0.8.3 bit_1.1-14 [73] stringi_1.4.3 rpart_4.1-15 tidyselect_0.2.5 lmtest_0.9-37 ```

mitchelloharawild commented 4 years ago

The forecast package is designed to work with ts objects, not zoo.

jmablans commented 4 years ago

The behaviour is the same for ts objects.

> ts <- as.ts(ts)
> outliers <- forecast::tsoutliers(ts)
> dput(outliers)
list(index = c(41L, 73L, 75L, 274L, 292L, 294L, 295L, 296L, 297L, 
298L, 300L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 307L, 309L, 
310L, 311L, 312L, 313L, 314L, 315L, 316L, 317L, 318L, 318L, 319L, 
319L, 320L, 320L, 321L, 321L, 322L, 322L, 323L, 324L, 324L, 325L, 
325L, 326L, 326L, 327L, 327L, 328L, 328L, 329L, 330L, 331L, 331L, 
332L, 332L, 333L, 334L, 334L, 335L, 335L, 336L, 336L, 337L, 337L, 
338L, 338L, 339L, 339L, 340L, 342L, 343L, 343L, 344L, 344L, 345L, 
345L, 346L, 346L, 347L, 347L, 348L, 348L, 349L, 349L, 350L, 350L, 
351L, 352L, 353L, 353L, 354L, 354L, 355L, 355L, 356L, 356L, 357L, 
357L, 358L, 358L, 359L, 359L, 360L, 360L, 361L, 361L, 362L, 362L, 
363L, 363L, 364L, 364L, 365L, 365L, 366L, 366L, 367L, 367L, 368L, 
368L, 369L, 369L, 370L, 370L, 371L, 372L, 372L, 373L, 374L, 374L, 
375L, 375L, 376L, 376L, 377L, 377L, 378L, 378L, 379L, 379L, 380L, 
380L, 381L, 381L, 382L, 382L, 383L, 383L, 384L, 384L, 385L, 385L, 
386L, 386L, 387L, 387L, 388L, 388L, 389L, 389L, 390L, 391L, 392L, 
393L, 394L, 395L, 395L, 396L, 396L, 397L, 397L, 398L, 398L, 399L, 
399L, 400L, 400L, 401L, 401L, 402L, 402L, 403L, 404L, 405L, 406L, 
407L, 408L, 409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 
418L, 419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 431L, 
451L, 472L, 474L, 519L, 530L, 548L, 551L, 552L, 554L, 559L, 568L, 
575L, 582L, 600L, 621L, 625L, 637L, 638L, 639L, 640L, 641L, 642L, 
643L, 644L, 645L, 646L, 647L, 648L, 649L, 650L, 651L, 652L, 652L, 
653L, 654L, 655L, 656L, 657L, 658L, 659L, 660L, 661L, 662L, 663L, 
663L, 664L, 664L, 666L, 667L, 667L, 668L, 668L, 669L, 669L, 670L, 
670L, 671L, 671L, 672L, 673L, 673L, 674L, 674L, 675L, 675L, 676L, 
676L, 677L, 677L, 678L, 678L, 679L, 679L, 680L, 680L, 681L, 682L, 
683L, 684L, 685L, 686L, 687L, 687L, 688L, 688L, 689L, 689L, 690L, 
690L, 691L, 691L, 692L, 692L, 693L, 694L, 694L, 695L, 695L, 696L, 
696L, 697L, 697L, 698L, 698L, 699L, 699L, 700L, 700L, 701L, 701L, 
702L, 702L, 703L, 703L, 704L, 704L, 705L, 705L, 706L, 706L, 707L, 
707L, 708L, 708L, 709L, 709L, 710L, 710L, 711L, 711L, 712L, 712L, 
713L, 713L, 714L, 714L, 715L, 715L, 716L, 716L, 717L, 717L, 718L, 
718L, 719L, 719L, 720L, 720L, 721L, 721L, 722L, 722L, 723L, 723L, 
724L, 724L, 725L, 726L, 726L, 727L, 727L, 728L, 728L, 729L, 729L, 
730L, 730L, 731L, 731L, 732L, 732L, 733L, 733L, 734L, 734L, 735L, 
735L, 736L, 736L, 737L, 737L, 738L, 738L, 739L, 739L, 740L, 740L, 
741L, 741L, 742L, 742L, 743L, 743L, 744L, 744L, 745L, 745L, 746L, 
746L, 747L, 747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 
756L, 756L, 757L, 757L, 758L, 758L, 759L, 759L, 760L, 760L, 761L, 
761L, 762L, 762L, 763L, 763L, 764L, 764L, 765L, 765L, 766L, 766L, 
767L, 767L, 768L, 768L, 769L, 770L, 770L, 771L, 772L, 773L, 774L, 
775L, 776L, 777L, 778L, 779L, 780L, 781L, 782L, 783L, 784L, 785L, 
786L, 787L, 788L, 789L, 790L, 791L, 792L, 793L, 794L, 799L, 924L, 
979L, 981L, 999L, 1000L, 1007L, 1008L, 1008L, 1009L, 1011L, 1015L, 
1027L, 1029L, 1029L, 1030L, 1035L, 1038L, 1044L, 1048L, 1049L, 
1049L, 1050L, 1050L, 1051L, 1052L, 1055L), replacements = c(0, 
0, 0, 0, 5.5, 12.8333333333333, 14.6666666666667, 16.5, 18.3333333333333, 
20.1666666666667, 22.3333333333333, 22.6666666666667, 23, 23.3333333333333, 
23.6666666666667, 24, 24.3333333333333, 24.6666666666667, 24.6666666666667, 
26.6666666666667, 28.3333333333333, 30, 31.6666666666667, 33.3333333333333, 
35, 36.6666666666667, 38.3333333333333, 40, 41.6666666666667, 
41.6666666666667, 43.3333333333333, 43.3333333333333, 45, 45, 
46.6666666666667, 46.6666666666667, 48.3333333333333, 48.3333333333333, 
50, 51.6666666666667, 51.6666666666667, 53.3333333333333, 53.3333333333333, 
55, 55, 56.6666666666667, 56.6666666666667, 58.3333333333333, 
58.3333333333333, 60, 61.6666666666667, 63.3333333333333, 63.3333333333333, 
65, 65, 66.6666666666667, 68.3333333333333, 68.3333333333333, 
70, 70, 71.6666666666667, 71.6666666666667, 73.3333333333333, 
73.3333333333333, 75, 75, 76.6666666666667, 76.6666666666667, 
78.3333333333333, 79.0804597701149, 78.1609195402299, 78.1609195402299, 
77.2413793103448, 77.2413793103448, 76.3218390804598, 76.3218390804598, 
75.4022988505747, 75.4022988505747, 74.4827586206897, 74.4827586206897, 
73.5632183908046, 73.5632183908046, 72.6436781609195, 72.6436781609195, 
71.7241379310345, 71.7241379310345, 70.8045977011494, 69.8850574712644, 
68.9655172413793, 68.9655172413793, 68.0459770114942, 68.0459770114942, 
67.1264367816092, 67.1264367816092, 66.2068965517241, 66.2068965517241, 
65.2873563218391, 65.2873563218391, 64.367816091954, 64.367816091954, 
63.448275862069, 63.448275862069, 62.5287356321839, 62.5287356321839, 
61.6091954022989, 61.6091954022989, 60.6896551724138, 60.6896551724138, 
59.7701149425287, 59.7701149425287, 58.8505747126437, 58.8505747126437, 
57.9310344827586, 57.9310344827586, 57.0114942528736, 57.0114942528736, 
56.0919540229885, 56.0919540229885, 55.1724137931034, 55.1724137931034, 
54.2528735632184, 54.2528735632184, 53.3333333333333, 53.3333333333333, 
52.4137931034483, 51.4942528735632, 51.4942528735632, 50.5747126436782, 
49.6551724137931, 49.6551724137931, 48.735632183908, 48.735632183908, 
47.816091954023, 47.816091954023, 46.8965517241379, 46.8965517241379, 
45.9770114942529, 45.9770114942529, 45.0574712643678, 45.0574712643678, 
44.1379310344828, 44.1379310344828, 43.2183908045977, 43.2183908045977, 
42.2988505747126, 42.2988505747126, 41.3793103448276, 41.3793103448276, 
40.4597701149425, 40.4597701149425, 39.5402298850575, 39.5402298850575, 
38.6206896551724, 38.6206896551724, 37.7011494252874, 37.7011494252874, 
36.7816091954023, 36.7816091954023, 35.8620689655172, 35.8620689655172, 
34.9425287356322, 34.0229885057471, 33.1034482758621, 32.183908045977, 
31.2643678160919, 30.3448275862069, 30.3448275862069, 29.4252873563218, 
29.4252873563218, 28.5057471264368, 28.5057471264368, 27.5862068965517, 
27.5862068965517, 26.6666666666667, 26.6666666666667, 25.7471264367816, 
25.7471264367816, 24.8275862068965, 24.8275862068965, 23.9080459770115, 
23.9080459770115, 22.9885057471264, 22.0689655172414, 21.1494252873563, 
20.2298850574713, 19.3103448275862, 18.3908045977012, 17.4712643678161, 
16.551724137931, 15.632183908046, 14.7126436781609, 13.7931034482759, 
12.8735632183908, 11.9540229885058, 11.0344827586207, 10.1149425287356, 
9.19540229885057, 8.27586206896552, 7.35632183908046, 6.43678160919541, 
5.51724137931035, 4.59770114942529, 3.67816091954023, 2.75862068965517, 
1.83908045977012, 0.919540229885058, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 1.89655172413793, 3.79310344827586, 
5.68965517241379, 7.58620689655172, 9.48275862068966, 11.3793103448276, 
13.2758620689655, 15.1724137931034, 17.0689655172414, 18.9655172413793, 
20.8620689655172, 22.7586206896552, 24.6551724137931, 26.551724137931, 
28.448275862069, 30.3448275862069, 30.3448275862069, 32.2413793103448, 
34.1379310344828, 36.0344827586207, 37.9310344827586, 39.8275862068966, 
41.7241379310345, 43.6206896551724, 45.5172413793103, 47.4137931034483, 
49.3103448275862, 51.2068965517241, 51.2068965517241, 53.1034482758621, 
53.1034482758621, 54.5769230769231, 54.1538461538462, 54.1538461538462, 
53.7307692307692, 53.7307692307692, 53.3076923076923, 53.3076923076923, 
52.8846153846154, 52.8846153846154, 52.4615384615385, 52.4615384615385, 
52.0384615384615, 51.6153846153846, 51.6153846153846, 51.1923076923077, 
51.1923076923077, 50.7692307692308, 50.7692307692308, 50.3461538461538, 
50.3461538461538, 49.9230769230769, 49.9230769230769, 49.5, 49.5, 
49.0769230769231, 49.0769230769231, 48.6538461538462, 48.6538461538462, 
48.2307692307692, 47.8076923076923, 47.3846153846154, 46.9615384615385, 
46.5384615384615, 46.1153846153846, 45.6923076923077, 45.6923076923077, 
45.2692307692308, 45.2692307692308, 44.8461538461538, 44.8461538461538, 
44.4230769230769, 44.4230769230769, 44, 44, 43.5769230769231, 
43.5769230769231, 43.1538461538462, 42.7307692307692, 42.7307692307692, 
42.3076923076923, 42.3076923076923, 41.8846153846154, 41.8846153846154, 
41.4615384615385, 41.4615384615385, 41.0384615384615, 41.0384615384615, 
40.6153846153846, 40.6153846153846, 40.1923076923077, 40.1923076923077, 
39.7692307692308, 39.7692307692308, 39.3461538461538, 39.3461538461538, 
38.9230769230769, 38.9230769230769, 38.5, 38.5, 38.0769230769231, 
38.0769230769231, 37.6538461538462, 37.6538461538462, 37.2307692307692, 
37.2307692307692, 36.8076923076923, 36.8076923076923, 36.3846153846154, 
36.3846153846154, 35.9615384615385, 35.9615384615385, 35.5384615384615, 
35.5384615384615, 35.1153846153846, 35.1153846153846, 34.6923076923077, 
34.6923076923077, 34.2692307692308, 34.2692307692308, 33.8461538461538, 
33.8461538461538, 33.4230769230769, 33.4230769230769, 33, 33, 
32.5769230769231, 32.5769230769231, 32.1538461538462, 32.1538461538462, 
31.7307692307692, 31.7307692307692, 31.3076923076923, 31.3076923076923, 
30.8846153846154, 30.8846153846154, 30.4615384615385, 30.4615384615385, 
30.0384615384615, 30.0384615384615, 29.6153846153846, 29.1923076923077, 
29.1923076923077, 28.7692307692308, 28.7692307692308, 28.3461538461538, 
28.3461538461538, 27.9230769230769, 27.9230769230769, 27.5, 27.5, 
27.0769230769231, 27.0769230769231, 26.6538461538462, 26.6538461538462, 
26.2307692307692, 26.2307692307692, 25.8076923076923, 25.8076923076923, 
25.3846153846154, 25.3846153846154, 24.9615384615385, 24.9615384615385, 
24.5384615384615, 24.5384615384615, 24.1153846153846, 24.1153846153846, 
23.6923076923077, 23.6923076923077, 23.2692307692308, 23.2692307692308, 
22.8461538461538, 22.8461538461538, 22.4230769230769, 22.4230769230769, 
22, 22, 21.5769230769231, 21.5769230769231, 21.1538461538462, 
21.1538461538462, 20.7307692307692, 20.7307692307692, 20.3076923076923, 
20.3076923076923, 19.8846153846154, 19.4615384615385, 19.0384615384615, 
18.6153846153846, 18.1923076923077, 17.7692307692308, 17.3461538461538, 
16.9230769230769, 16.5, 16.5, 16.0769230769231, 16.0769230769231, 
15.6538461538462, 15.6538461538462, 15.2307692307692, 15.2307692307692, 
14.8076923076923, 14.8076923076923, 14.3846153846154, 14.3846153846154, 
13.9615384615385, 13.9615384615385, 13.5384615384615, 13.5384615384615, 
13.1153846153846, 13.1153846153846, 12.6923076923077, 12.6923076923077, 
12.2692307692308, 12.2692307692308, 11.8461538461538, 11.8461538461538, 
11.4230769230769, 11.4230769230769, 11, 10.5769230769231, 10.5769230769231, 
10.1538461538462, 9.73076923076923, 9.30769230769231, 8.88461538461539, 
8.46153846153846, 8.03846153846154, 7.61538461538461, 7.19230769230769, 
6.76923076923077, 6.34615384615385, 5.92307692307692, 5.5, 5.07692307692308, 
4.65384615384615, 4.23076923076923, 3.80769230769231, 3.38461538461539, 
2.96153846153846, 2.53846153846153, 2.11538461538461, 1.69230769230769, 
1.26923076923077, 0.84615384615384, 0.42307692307692, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0))
robjhyndman commented 4 years ago

Thanks. Fixed in https://github.com/robjhyndman/forecast/commit/d914c9e20575acc8255995646e17c7f87ebdb47d

jmablans commented 4 years ago

Thanks to you for the package and the fix!