The error is pretty clear. Your time series, however you created it, has no seasonal cycles or less than 2 seasonal cycles. (This may not indicate that the data is not seasonal, you may have created samplets .) For example, I can reproduce the error by having time series with 7 quarterly observations that are clearly not two complete full seasonal cycles: / p>
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
Similarly, if I do not specify any sub-frequency (i.e. frequency = 1 in the ts() call, creating your samplets time series samplets [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
In any case, this indicates that you incorrectly created your "ts" object without specifying the correct frequency or deltat , or that you have a time series of insufficient length (number of years) to cover two full seasonal cycles.
Read ?ts in more detail to make sure that you are creating samplets . If you need more help, post a reproducible example.
source share