# How to remove seasonality from daily electricity demand

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:

I tried to remove seasonality with the following:

demand.xts.diff<-diff(demand.xts,lag=1,difference=1)
demand.xts.diff<-diff(demand.xts,lag=7,difference=1)


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:

• 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! – whuber Oct 9 '13 at 4:14
• 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. – George Gao Oct 9 '13 at 19:02
• can you please post the data ? – forecaster Nov 9 '13 at 2:01
• 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'. – Jiac Dec 19 '13 at 17:04
• 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. – IrishStat Dec 19 '13 at 18:46

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:

http://revgr.com/2012/11/06/all-forecasts-are-wrong-but-some-generate-fewer-complaints/

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.

http://www.tandfonline.com/doi/abs/10.1198/jasa.2011.tm09771#.UrNTUtJDuyw

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

http://robjhyndman.com/software/forecast/

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)

• 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 – IrishStat Oct 15 '13 at 13:58
• 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. – Learnerbeaver Oct 15 '13 at 14:13
• 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.) – Nick Cox Oct 15 '13 at 14:28
• Yes. it is SAS. Sorry, didn't know the conventions. But, I've bumped into presentations of stata which has implemented ucm as well. – Learnerbeaver Oct 15 '13 at 14:44
• Indeed; Stata has a ucm command too. There will be other implementations too. – Nick Cox Oct 15 '13 at 15:29