0
votes

I am trying to decompose a time series which is the monthly multi-year average of hourly ozone data. There are 288 data points (24 hours * 12 months). STL needs ts object to extract the components of time series. And ts has the parameter "frequency". As far as I know, it is the number of observations in one period. For example, it is 12 for monthly averaged temperature data. What is the frequency for my case since If I use 288

data_ts=stl(ts(data,frequency = 288),s.window = "per"))

As expected, it throws the error "series is not periodic or has less than two periods". BTW, I am aware of other methods to extract seasonality, but I also need to check the results with STL.

Best

2
Thanks for letting me know. It is corrected now.Seyed Omid Nabavi

2 Answers

1
votes

Assuming you have hourly data, there are 24 periods per day, and 24*365.25 periods per year on average. Months would appear to be irrelevant for a natural phenomenon such as ozone. Similarly, weeks are irrelevant. So you just need seasonal periods of 24 and 24*265.35.

The mstl() function from the forecast package can handle multiple seasonal periods.

library(forecast)
data_ts <- mstl(msts(data, seasonal.periods = c(24, 24*365.25)))

However, if you actually have monthly data, then the frequency is 12.

data_ts <- mstl(ts(data, frequency = 12))
0
votes

As you can see in the picture ACF, the ACF of your data clearly shows an annual seasonal trend. it peaks at yearly lag at about 12, 24, etc.

If I am behalf on you, I will use freq=12 to decompose my time series data.