12

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!!!!!

Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
user1656633
  • 177
  • 1
  • 1
  • 3
  • 4
    Welcome to Stack Overflow! If you made a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that demonstrates your question / problem, we would find it easier to answer. – Andrie Sep 08 '12 at 12:11

1 Answers1

36

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.

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453