3

I am pretty sure I am missing something which is very simple but still not able to figure out why this error is showing up . The data I have is of every month end data from 2013 Apr to 2014 Mar. Now I want to understand the trend over the 12 months period .

xx <- structure(c(41.52, 41.52, 41.52, 41.68, 41.68, 41.68, 41.84, 
41.84, 41.84, 42.05, 42.05, 42.05), .Tsp = c(2013.25, 2014.16666666667, 
12), class = "ts");

is my time series data . Now when I use

 stl(xx,s.window ="periodic")

I get error :

Error in stl(xx, s.window = "periodic") : 
  series is not periodic or has less than two periods

i am not sure what is wrong as I understand the series has 12 periods .Please assist

Bg1850
  • 3,032
  • 2
  • 16
  • 30
  • 1
    Your time series is too short. You need two years (= two periods in your case) of data, at least. –  Dec 10 '15 at 01:49

1 Answers1

6

The terminology is a little misleading. In R, the frequency is the number of observations in one "period". For monthly data, frequency=12 and you have just one period. You need two periods, or 24 observations, to use stl().

Rob Hyndman
  • 30,301
  • 7
  • 73
  • 85
  • Ok Rob Now I understood what I was missing . Thanks .+`1 – Bg1850 Dec 10 '15 at 01:51
  • @Pascal yes but until you edited I did not understand what exactly you meant "Your time series is too short." – Bg1850 Dec 10 '15 at 01:55
  • @Bg1850 Anyway, you could have search first: http://stackoverflow.com/questions/18615254/analyzing-a-time-series-with-r, for example –  Dec 10 '15 at 01:58
  • I have a time series with frequency = 288 (sampling each 5 min) and 29 days(so the number of observation is 8352), but I still got this error, why? – LittleLittleQ Jul 08 '17 at 12:17