I have an hourly time series of temperature:
(can be downloaded here: http://workupload.com/file/eFFPWvL)
plot(my_data$time, my_data$temperature, type = "l")
for which I would like to calculate a sine cosine function of the form:
As I understand the sine cosine are able to capture any complex form of seasonality/cyclicality. In my data, there is yearly seasonaly as well as hourly which I would like to capture.
I tried (in R) what I thought might be appropriate using the model estimation formula like:
fit <- lm(temperature~ time + sin(2*pi/365*time)+cos(2*pi/365*time) +
sin(2*pi/(365*24)*time)+cos(2*pi/(365*24)*time),data=df)
lines(fit$fitted.values, col = 2)
But the result does not look promising.
Fist of all, the high frequency pattern does not seem to capture the within day fluctuations as there should be much more "waves" (for each day). Secondly, the magnitude of my fitted line is much lower than that of the data.
Can someone pelase tell me what am I doing wrong?