# More effective seasonal adjustment to time series data?

I am trying to predict surface temperature using solar energy. I have 3650 daily averages for both variables. The plots of both are below:

I attempt to seasonally adjust with a periodic regression in R for both:

stmp.model.sa <- lm(stmp ~ sin((2*pi/365)*t) + cos((2*pi/365)*t))
slrd.model.sa <- lm(slrd ~ sin((2*pi/365)*t) + cos((2*pi/365)*t))


Here are the plots of the residuals from these models:

As you can see, the temperature data responded well to the treatment. The solar energy data did not, as the yearly humps are still somewhat present.

A few questions:

• Is there a more effective way to remove seasonality for the solar data?
• Is further treatment of the temperature trend recommended? Would a polynomial regression be sufficient to remove this trend?
• What model might be recommended to predict the temperature? Linear model, ARIMA/ARIMAX models, linear regression with ARIMA errors, etc?

Thanks in advance for any responses!

EDIT:

I attempted to apply a Hodrick Prescott filter (lambda = 100*365^2) with poor results. I then attempted to fit a cycle to the solar data using a 20 period moving maximum. This was done using the following code:

seq <- 11:(n-11)
ns <- length(seq)
slrd.seasonal <- slrd[seq]
for(i in seq){
slrd.seasonal[i-10] <- max(slrd[(i-10):(i+10)])
}


The moving maximum, the solar cycle, and the cycle subtracted from the original series is presented below:

This did not remove the yearly cycle entirely either. Any advice? EDIT 2:

I have successfully removed seasonality by fitting a 20 order polynomial to the first three years (using more years proves computationally difficult). If anyone can think of a better or more elegant way to achieve this, let me know.

• I'm not sure this is more "effective," but it is different. Try using a Prescott filter which smooths cyclicality in data but with a bias towards longer term trends. en.wikipedia.org/wiki/Hodrick%E2%80%93Prescott_filter – Mike Hunter Apr 25 '16 at 19:15
• More precisely, Hodrick-Prescott (HP) filter. @DJohnson, could HP filter be useful for forecasting (which is the goal of the OP)? Just wondering... – Richard Hardy Apr 25 '16 at 19:26
• @RichardHardy I'm agnostic on that question. You're the time series expert, what do you think? – Mike Hunter Apr 25 '16 at 19:44
• I am not an expert :) But I am interested in time series, yes. If HP filter is double sided (as I remember it), it should not be applicable to prediction. – Richard Hardy Apr 25 '16 at 19:47
• @DJohnson I attempted to apply an HP filter with a lambda of 100*365^2 (recommended lambda for daily data), but the yearly trend is still present, although reduced. I'm now going to attempt to fit a curve to just the maximum daylight curve (get rid of any data points that were not full sunlight). – user3623888 Apr 25 '16 at 21:35