Reputation:
I have a weekly data ts
object.
> bvg1TS
Time Series:
Start = c(2013, 4)
End = c(2015, 3)
Frequency = 52
[1] 2.966812 2.939399 2.872005 2.950616 2.967781 2.965619 2.970308 2.942091 2.863181 2.980295 2.947549 2.942091
[13] 2.875945 2.978333 2.966935 2.980904 3.023234 2.991919 3.041026 2.994267 2.916576 2.946435 3.046428 2.966970
[25] 2.991558 3.011992 3.002000 3.059313 3.042949 2.876813 2.898701 2.870776 2.948676 2.919896 2.935181 2.882285
[37] 2.923060 2.932156 2.845724 2.752336 2.813689 2.839735 2.769321 2.788457 3.006690 3.043881 3.016572 3.046467
[49] 3.139696 3.174412 3.099379 3.103872 3.053300 3.055752 3.135360 3.102986 3.092577 3.118464 3.145579 3.216891
[61] 3.114963 3.022140 3.126573 3.226314 3.215919 3.228102 3.176195 3.133876 3.172260 3.179221 3.137750 3.214817
[73] 3.205800 3.210800 3.283134 3.240072 3.258800 3.345034 3.226608 3.203244 3.277908 3.242800 3.184734 3.234800
[85] 3.243738 3.170665 3.164850 3.187008 3.161083 3.236417 3.276416 3.261774 3.108953 2.946660 2.998852 3.008005
[97] 3.043996 3.127296 3.253415 3.263998 3.148936 2.966812 2.939399 2.872005
I want to do STL
but getting the following error:
> fit <- stl(bvg1TS, s.window="period")
Error in stl(bvg1TS, s.window = "period") :
series is not periodic or has less than two periods
Can't seem to find the solution...any ideas?
Thanks & Regards,
Shery
Upvotes: 1
Views: 856
Reputation: 31820
The help message says:
series is not periodic or has less than two periods
Your data are clearly periodic (in the sense that you have specified a frequency greater than 1) and have exactly two periods.
But if you check the first few lines of the stl
function to find where the error is being generated you will see this:
if (period < 2 || n <= 2 * period)
stop("series is not periodic or has less than two periods")
Your series has n=104
and period=52
. Add one more observation and the problem will go away.
Either the help message should say "less than or equal to two periods" or the test should say n < 2 * period
.
Upvotes: 4