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

enter image description here

enter image description here

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: enter image description here

enter image description here

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!


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:

enter image description here

enter image description here

enter image description here

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.

  • $\begingroup$ 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 $\endgroup$ – DJohnson Apr 25 '16 at 19:15
  • $\begingroup$ More precisely, Hodrick-Prescott (HP) filter. @DJohnson, could HP filter be useful for forecasting (which is the goal of the OP)? Just wondering... $\endgroup$ – Richard Hardy Apr 25 '16 at 19:26
  • $\begingroup$ @RichardHardy I'm agnostic on that question. You're the time series expert, what do you think? $\endgroup$ – DJohnson Apr 25 '16 at 19:44
  • $\begingroup$ 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. $\endgroup$ – Richard Hardy Apr 25 '16 at 19:47
  • $\begingroup$ @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). $\endgroup$ – user3623888 Apr 25 '16 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.