I want to remove seasonality from daily electricity demand (a time series). My understanding is there is weekly (high demand on Tue, Wed, and low demand on Sat, Sun) and annual seasonality (high demand on Winter and lower on Summer). I tried to build a model to forecast daily electricity demand in R, and plot my data as shown below: Daily electricity demand

I tried to remove seasonality with the following:


I also tried to use lag=365 and lag=366 (I am not sure what lag to use, due to the leap year issue), but none of them successfully removed seasonality. The ACF and PACF are shown below:


Any advice is appreciated.

  • 5
    $\begingroup$ What units are your dates measured in? The lags in the plots are enormous--they look like seconds. Taking first differences at lags of seven seconds won't fix a weekly cycle! $\endgroup$
    – whuber
    Oct 9, 2013 at 4:14
  • $\begingroup$ my data is daily data measured in MWs, I tried first (and second) differences at lags of 7, 14, 365,364,366, but there is still seasonality. $\endgroup$
    – George Gao
    Oct 9, 2013 at 19:02
  • $\begingroup$ can you please post the data ? $\endgroup$
    – forecaster
    Nov 9, 2013 at 2:01
  • $\begingroup$ Have you solved you question yet? I have the same question as well. It seems that the trend could be removed by differencing, but what about the seasonal variation? I've used the package 'deseasonalize' in R, but I'm wondering how to choose the arguments 'Fm' and 'Fs'. $\endgroup$
    – Jiac
    Dec 19, 2013 at 17:04
  • $\begingroup$ If you provide your actual data, I will run a version of AUTOBOX (autobox.com) which seasonally adjusts the data by incorporating day-of-the-week, month-of-the year, Seasonal ARMA structure and Holiday effects. It produces a seasonally adjusted series that may have level shifts, local time trends, ARIMA structure (non-seasonal) along with anomalies (pulses). I am one of the developers of this piece of forecasting/time series analysis software. $\endgroup$
    – IrishStat
    Dec 19, 2013 at 18:46

2 Answers 2


Modeling daily electricity demand is a data intensive effort. To simplify this, it's easier to start "zoomed out", estimating monthly loads. Here's an article (with a Youtube video) that describes a monthly model that is simple and easy to understand. The article includes R code:


As you "zoom in" to shorter time frames the problem gets more and more complicated. For example, the monthly model includes an integer 12 months/year and starts at the beginning of month 1, while a weekly model includes a non-integer 52.18 weeks/year and might begin at the start of a week, middle of the week, end of the week, etc (i.e. you can't directly compare "week 1" of one year to "week 1" of the next year, they start on different days). It gets more complicated when you drop down to daily or hourly time frames.

The hierarchy in time frames, starting with the longest time frame, is typically:

1) Population growth and economic activity.

2) Long term seasonal temperature terms (summer, winter, etc).

3) Day of the week (Tuesday, Wednesday and Thursday are typically similar workdays; the remaining days have their own individual "day-of-the-week" values).

4) Holidays, the day before and the day after a holiday (many holidays have a similar value as a typical Sunday "day-of-the-week" value).

5) Temperature due to time of day, cooler nights, warmer days, is the sun shining, is it raining, etc. (this is a refinement of item 2 above).

6) Work load during the day. People are typically at home during the night and at work during the day, so lot of electricity consuming workplaces shut down at night.

7) Other terms such as humidity, daylight savings time, etc.

The bottom line is, at the daily and hourly time frames, a lot of data (and complexity) is required.

You can Google "daily electrical load models" (or hourly models) and various papers will show up. Some are based on neural nets, support vector machines, etc. Here's a link to a paper by Rob Hyndman that explains another technique.


The methods used in that paper are in the "forecast" package:



i'm having a fabulous run with ucm. You could model this as daily seasonality & with an annual cycle. You also have a very evident trend.

Post back here if you succeeded with ucm (proc ucm)

  • $\begingroup$ Does Proc Ucm deal with multiple level shifts , multiple time trends , changes in seasonality, lead and lag effects around known events while detecting parameter transience and variance heterogeneity ? or does it have embedded assumptions about the non-existence of these characteristics ? It might be interesting for us to share some results offline. If you are interested please contact me. Alternatively if we can get the OP to post his actual data we could have a public bakeoff/comparison $\endgroup$
    – IrishStat
    Oct 15, 2013 at 13:58
  • $\begingroup$ The trend, seasonality components are estimated using Kalman filter (random walk, EM approach). So, while I've not encountered the problems you're raising, i'm guessing it should. Yes, running it on OP's data-set will help determine. To answer your question in another way, I've read that any ARIMA model can be expressed as a state space equation and thus be modeled using UCM. $\endgroup$ Oct 15, 2013 at 14:13
  • 1
    $\begingroup$ What language or package is this please? The mention of proc (?PROC) leads me to guess SAS, but please spell it out. See meta.stats.stackexchange.com/questions/1479/… for the advice "Say what programming language you're using". (It applies to answers as well as questions.) $\endgroup$
    – Nick Cox
    Oct 15, 2013 at 14:28
  • $\begingroup$ Yes. it is SAS. Sorry, didn't know the conventions. But, I've bumped into presentations of stata which has implemented ucm as well. $\endgroup$ Oct 15, 2013 at 14:44
  • $\begingroup$ Indeed; Stata has a ucm command too. There will be other implementations too. $\endgroup$
    – Nick Cox
    Oct 15, 2013 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.