Reputation: 3
I have the below time series for weekly fish caught in a specific location (period=52 for weekly data) and only 55 datapoints
Time Series:
Start = c(1, 1)
End = c(2, 3)
Frequency = 52
[1] 773 1239 842 567 686 930 1165 952 1277 820 364 343 342 444
[15] 432 503 463 372 372 367 423 378 423 459 350 399 433 439
[29] 382 331 326 345 497 579 381 306 423 403 549 412 354 471
[43] 435 420 410 455 534 1064 816 485 744 2260 1542 1988 1233
I have been following Rob J Hyndman's method for using Fourier transformation for the seasonality https://robjhyndman.com/hyndsight/tslm-decomposition/ aspect of the TSLM code, and grid searched the correct K
between 1:26
and the minimum AIC
is at 26.
So, essentially, I have the below code for the TSLM:
decompose_df <- tslm(fish_ts ~ trend + fourier(fish_ts,26))
and then trying to use the forecast function to get forecasts for the next 10 periods:
fish_fcst <- forecast(decompose_df, newdata=data.frame(fourier(fish_ts,26,10)))
But I get this warning: Warning: 'newdata' had 10 rows but variables have 55 rows
and the forecast returns 55 values that are slightly different than the input ts object, but seem to follow a similar trend, instead of 10 forecasted periods. Can anyone tell me how to get forecasts or what I am doing wrong?
editing with the dput, sorry!
structure(c(773, 1239, 842, 567, 686, 930, 1165, 952, 1277, 820,
364, 343, 342, 444, 432, 503, 463, 372, 372, 367, 423, 378, 423,
459, 350, 399, 433, 439, 382, 331, 326, 345, 497, 579, 381, 306,
423, 403, 549, 412, 354, 471, 435, 420, 410, 455, 534, 1064,
816, 485, 744, 2260, 1542, 1988, 1233), .Tsp = c(1, 2.03846153846154,
52), class = "ts")
Thanks in advance!
Upvotes: 0
Views: 366
Reputation: 31800
Your code works for me using v8.15 of the forecast
package. So perhaps you are using an old version of package -- there were some issues with matching regression variable names a few versions ago.
In any case, the model makes no sense. You have 55 observations, yet your model has 53 degrees of freedom. Perhaps you are misunderstanding the AIC values. They are on a scale from -∞ to ∞, and you want the one closest to -∞, not the one closest to zero. I would expect a value of K less than 5 with so few observations.
Upvotes: 1