I have a data set with hourly values over two years. The first year has 366 days the second has 365 days. There is a clear monthly pattern of the data, as the values are higher in the winter as in the summer. There is a clear weekly pattern, as the values are higher during the week than at weekends. And there is a clear hourly pattern, as the values are higher during the day compared to the night. Assuming I have the variable y and all the data for y. This variable has a stochastic part z and a seasonal part s. So y = z + s, where s = a0 + a1*h + a2*d + a3*m. In this case a1 is the coefficient for the hourly data, which means a1 comprises 24 subcoefficients. For instance a1(10) = 0.25 and a1(5) = -0.1. Which means that the hour 10 has an impact of 0.25 on the data and the hour 5 (in the night) has a slightly negativ effect on the data. a2 is the coefficient for the weekdays and should have 7 subcoefficients. a3 stands for the particular month and should have 12 subcoefficients. The idea is to take the first element as a reference. For the hourly data it means I take the hour 1 as a reference and estimate the effects of the other 23 hours in an OLS regression. Do you have any clue how to estimate these coefficients? I read in the literature that a step function for s with dummy variables might be helpful. I don't know exactly what it means.
I checked out different functions to estimate or smooth seasonal effects (filter, ma.filter, decompose, bats). But I don't like them as they do not give me the clear estimates of the coefficients and somehow they do not give me the smoothing effects I expected (They did not capture the difference between summer and winter).
The detrended data looks like this:
time y 1 2016-01-01 00:00:00 -2.907587 2 2016-01-01 01:00:00 -4.378144 3 2016-01-01 02:00:00 -6.178701 4 2016-01-01 03:00:00 -9.959259 5 2016-01-01 04:00:00 -9.359816 6 2016-01-01 05:00:00 -9.750373 7 2016-01-01 06:00:00 -10.910930 8 2016-01-01 07:00:00 -8.611487 9 2016-01-01 08:00:00 -9.042045 10 2016-01-01 09:00:00 -7.002602 str(df[,1:2]) 'data.frame': 17544 obs. of 2 variables: $ time : POSIXct, format: "2016-01-01 00:00:00" "2016-01-01 01:00:00" "2016-01-01 02:00:00" ... $ y: num -2.91 -4.38 -6.18 -9.96 -9.36 ...
I have got the idea from this paper (Formula (1)): https://ac.els-cdn.com/S0140988314000875/1-s2.0-S0140988314000875-main.pdf?_tid=5cd1edbe-2441-40db-8a1f-65bee19cd4d0&acdnat=1521371765_675fe9c00865a4882ed733e03b908618