0
I’m trying to create a time series forecast in the test data, but when I try to make the prediction it gives an error that I can’t understand and I can’t find anything like it on the internet that could help me
the code is this
data from the regression model:
Coefficients:
Week A B C
(Intercept) 1577059200.0000016689 13307.1406976744 421.9365116279 11764.1041860465
Trend 604799.9999421 -49.6406976744 3.3934883721 132.4958139535
season2 -0.0000024300 -1623.2493023256 -60.2734883721 470.3541860465
season3 -0.0000023707 -604.0286046512 -179.6569767442 2591.2983720930
season4 -0.0000023117 -1379.5779069767 -71.5704651163 6243.1025581395
season5 -0.0000022545 105.0627906977 284.0460465116 5645.9267441860
season6 -0.0000021965 803.5434883721 281.5725581395 6478.3109302326
season7 -0.0000021393 1737.4641860465 131.2590697674 3960.7951162791
season8 -0.0000020813 30.2548837209 -5.4344186047 3176.7893023256
season9 -0.0000020232 315.1155813953 73.0420930233 507.0134883721
season10 -0.0000019661 -781.9337209302 -112.1913953488 3645.3976744186
season11 -0.0000019080 -1231.4530232558 -0.8148837209 7179.2918604651
season12 -0.0000018508 -3027.0323255814 -38.7483720930 5806.9260465116
season13 -0.0000017928 -1588.9116279070 -13.0818604651 3730.9402325581
season14 -0.0000017347 1877.0090697674 42.1546511628 4102.3644186046
season15 -0.0000016766 -274.2702325581 209.0811627907 4020.0586046512
season16 -0.0000016190 -1090.6695348837 524.4476744186 4888.0827906977
season17 -0.0000015614 315.9711627907 318.2541860465 6092.6869767442
season18 -0.0000015035 -1140.1881395349 130.1006976744 3948.4811627907
season19 -0.0000014456 -1184.5874418605 -52.6427906977 4073.0553488372
season20 -0.0000013878 -369.5467441860 -32.0062790698 9121.6195348837
season21 -0.0000013298 250.0139534884 -63.1997674419 6973.1537209302
season22 -0.0000012720 5.4646511628 42.7867441860 3997.8279069767
season23 -0.0000012141 25.2053488372 91.1332558140 5013.4020930233
season24 -0.0000011563 -406.6939534884 6.8397674419 3984.1962790698
season25 -0.0000010982 -3148.6532558140 162.1362790698 3399.8304651163
season26 -0.0000010406 -3424.1425581395 219.2927906977 2694.0746511628
season27 -0.0000009826 -113.8518604651 262.5693023256 1899.1488372093
season28 -0.0000009254 2670.3188372093 223.5458139535 3381.9730232558
season29 -0.0000008673 3248.1395348837 239.8223255814 3981.8772093023
season30 -0.0000008093 3307.4502325581 124.7188372093 4761.7113953488
season31 -0.0000007521 346.1609302326 123.1253488372 4663.9155813953
season32 -0.0000006941 -349.7383720930 17.2918604651 2963.4197674419
season33 -0.0000006360 -412.4876744186 -36.9816279070 2769.7739534884
season34 -0.0000005789 975.1930232558 134.8448837209 3458.8481395349
season35 -0.0000005217 66.4437209302 158.1513953488 1863.2823255814
season36 -0.0000004627 -421.4255813953 279.3679069767 1236.9665116279
season37 -0.0000004037 666.7451162791 467.8744186047 3097.1906976744
season38 -0.0000003466 528.0558139535 573.3609302326 6293.6748837209
season39 -0.0000002894 -2108.7134883721 113.5574418605 3380.1890697674
season40 -0.0000002304 532.4272093023 -74.7060465116 1339.8432558140
season41 -0.0000001751 431.9679069767 -82.3495348837 871.3774418605
season42 -0.0000001161 727.4286046512 13.9569767442 2422.8916279070
season43 -0.0000000590 1000.1093023256 57.6234883721 2077.4158139535
season44 NA NA NA NA
Recipe
(Intercept) 506702.1467441845
Trend 557.6532558140
season2 96953.5367441874
season3 89019.2534883733
season4 47162.2302325593
season5 91814.4669767455
season6 6789.0937209311
season7 30525.2204651173
season8 -38702.4727906966
season9 54888.2739534896
season10 32269.0506976755
season11 31287.9174418615
season12 -143281.2658139527
season13 33281.0509302334
season14 103265.5076744194
season15 143273.5444186057
season16 179779.0511627916
season17 312225.7179069777
season18 245839.3846511634
season19 162875.6413953498
season20 652951.7581395357
season21 425870.0848837215
season22 259596.6316279077
season23 206232.1083720934
season24 316585.4351162799
season25 220887.0918604656
season26 260269.0786046516
season27 164424.3453488378
season28 219162.4720930237
season29 195462.0188372096
season30 204473.8455813959
season31 177113.7523255819
season32 90318.7890697678
season33 -278827.3241860461
season34 264292.8225581399
season35 42682.7093023259
season36 8912.2860465119
season37 71726.5427906979
season38 206990.4695348841
season39 -47733.4337209300
season40 17143.0330232559
season41 -86539.1302325579
season42 -13619.8634883721
season43 -11515.5967441860
season44 NA
applied code:
test <- window(dados_ts, start = 2020, drop.unused.levels = FALSE)
preditores <- tslm(test ~ trend + season)
fcast <- forecast(preditores)
autoplot(fcast) +
ggtitle("Forecasts of beer production using regression") +
xlab("Year") + ylab("megalitres")
Error presented:
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) :
factor season has new levels 45, 46, 47, 48, 49, 50, 51, 52
Hi Nívea, the error you’re looking for is the top one? Or the bottom one?? Got a little confused
– Rodrigo Almeida Bezerra
the error is the bottom, the Cod I applied was the top
– Nívea Dantas