Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too few periods for decompose() [closed]

Tags:

r

the error looks like this

decompose(samplets)
Error in decompose(samplets) : time series has no or less than 2 periods

i want to know whats the problem? I am basically writing a code forecasting using ARIMA and i want to knoe if there is any seasonality or trend in my data.

Hoping for a quick resonse!!!!!

like image 488
user1656633 Avatar asked Sep 08 '12 12:09

user1656633


1 Answers

The error is pretty self explanatory. Your time series, however you created it, has no seasonal cycles or less than 2 seasonal cycles. (This may not indicate that the data are not seasonal; possibly you created samplets incorrectly.) For example, I can reproduce the error by having a time series with 7 quarterly observations, which is clearly not two full complete seasonal cycles:

R> TS <- ts(1:7, frequency = 4)
R> decompose(TS)
Error in decompose(TS) : time series has no or less than 2 periods
R> TS
  Qtr1 Qtr2 Qtr3 Qtr4
1    1    2    3    4
2    5    6    7     

Likewise, if I don't specify any sub-annual frequency (i.e. frequency = 1 in the ts() call creating your time series object samplets [which is the default]) I get the same error:

R> TS <- ts(1:7)
R> decompose(TS)
Error in decompose(TS) : time series has no or less than 2 periods

Either way, this points to you having created your "ts" object incorrectly by not specifying the correct frequency or deltat arguments, or you have a time series of insufficient length (number of years) to cover two full seasonal cycles.

Please read ?ts in more detail to check you are creating samplets correctly. If you need further help, post a reproducible exmaple.

like image 97
Gavin Simpson Avatar answered Nov 15 '22 14:11

Gavin Simpson