Stat Corner:Stat Corner: Regression with ARMA...

31
Stat Corner: Stat Corner: Regression with ARMA Errors Dr. J. Stuart McMenamin Itron’s Forecasting Brown Bag Seminar December 8, 2009

Transcript of Stat Corner:Stat Corner: Regression with ARMA...

Page 1: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Stat Corner:Stat Corner:Regression with ARMA Errors

Dr. J. Stuart McMenamin

Itron’s Forecasting Brown Bag Seminar

December 8, 2009

Page 2: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Please RememberIn order to help this session run smoothly, your phones are muted.  

To make the presentation portion of the screen larger,press the expand button on the toolbar.  Press it again to return to regular window.g g

If you need to give other feedback to the presenter during the meeting, such as, slow down or need to get the presenters attention for some other reason use the pull down menu in the seating chart and we willother reason, use the pull down menu in the seating chart and we will address it right away.

If you have questions, please type your question in the Q&A box in the bottom, right corner.  We will try to answer as many questions as we can.

© 2009, Itron Inc. 2

Page 3: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

2009 Brown Bag SeminarsThe Economic Impact of the Financial Crisis on Utility Sales‐March 10, 2009 

Demand Response Forecasting ‐ June 9, 2009June 9, 2009 

Incorporating Energy Efficiency Impacts in your Forecast ‐ September 15, 2009 

Stat Corner: Regression with ARMA Errors‐ December 8, 2009 

All at noon, Pacific Time 

All are recorded and available for review after the session

© 2009, Itron Inc. 3

All are recorded and available for review after the session.

Page 4: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Regression Models with ARMA ErrorsModel Specification p

Model Diagnostics and Statistics

Using ARMA to Tune a Solid model

Diagnosing Specification Error

Diagnosing Data Errors

Diagnosing Structural Shifts

Conclusion and recommendations

© 2009, Itron Inc. 4

Page 5: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Estimation View

ttt uxy +β+α=

t1t1tt

eu

eequpu

+=

+×+×= −−

( )ttt xye

ββ−α−=

tttt euxy ++β+α=

tt eu += ( ) 1t1t1t eqxyp −−− ×−β−α−×−

1111111 uexyux,y =β−α−=S l f

112222222 equpuexyux,y ×−×−=β−α−=

equpuexyuxy ×−×−=β−α−=

Solve forα, β, p, q

to minimize50

223333333 equpuexyux,y ×−×−=β−α−=

494950505050505050 equpuexyux,y ×−×−=β−α−=

•••∑=

50

1t

2te

© 2009, Itron Inc. 5

494950505050505050

Page 6: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Forecast View

ˆˆ fff uxy +β+α=1f1ff equpu −− ×+×=0ef =

equpuexyuxy ××βα

5151515150505151 uxy0eequpux +β+α==×+×=

494950505050505050 equpuexyux,y ×−×−=β−α−=

5252525251515252 uxy0eequpux +β+α==×+×=

5252525251515252 uxy0eequpux +β+α==×+×=

••• Role of ARMA terms dies out in the forecast-- AR terms die out geometrically.

MA t di t dd l

5252525251515252 uxy0eequpux +β+α×+×

© 2009, Itron Inc. 6

-- MA terms die out suddenly.

Page 7: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Diagnostics ‐‐ Durbin Watson Statistic

( )

( ) ( )ρ−≈

×−+=

−=

∑ ∑∑

∑= =

==−

22e

ee2ee

e

eeDW N

2

N

2t

N

2t1tt

1N

1t

2t

2t

N2

N

2t

21tt

( ) ( )∑∑==

ee1t

t1t

t

1te − 1te −

te te

positi e ( >0) ti ( 0)ρ=0positive (ρ>0)DW <2

negative (ρ<0)DW >2

0 42

ρ 0DW <2

dLd dd

© 2009, Itron Inc. 7

0 42UdLd

LdUd

Page 8: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Diagnostics ‐‐ Ljung Box Statistic

∑N

( )∑

∑∑ =

=

×=ρ

ρ×+×= N

2t

2jjtt

j

J

1j

2j

e

eewhere

jn2nnQ

=1j

Autocorrelation Functions

© 2009, Itron Inc. 8

Page 9: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Tuning a Solid Model

The str ct ral model pro ides a good fitThe structural model provides a good fit and well defined parameter estimates.

© 2009, Itron Inc. 9

Page 10: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Autocorrelation Diagnostics

The residuals reveal a mild cyclical pattern

The diagnostic statistics are consistent with AR1

© 2009, Itron Inc. 10

Page 11: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Add in AR(1) Term

Introducing an AR1, the residual g ,pattern is more random

The diagnostic statistics do not suggest further autocorrelation

© 2009, Itron Inc. 11

problems. Life is good!

Page 12: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Model Results & AR(1) Impact

The AR1 correction does notThe AR1 correction does not cause significant coefficient

changes. Coefficient standard errors go up slightly.

The contribution of the AR1 processThe contribution of the AR1 process to the predicted value (as seen on

the BX tab) is minimal.

© 2009, Itron Inc. 12

Page 13: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Diagnosing Specification Error

To illustrate specification error, the trend terms are removed from the model. With this

change, there is nothing in the model to explain the growth in the data.

© 2009, Itron Inc. 13

Page 14: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Model Residuals Analysis

Model residuals have a very strong trended pattern, reflecting the exclusion of important explanatory variables.

Autocorrelations and statistics show strong evidence of first or higher order

autocorrelation.

© 2009, Itron Inc. 14

Page 15: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Add AR(1) TermAdding an AR1 term hides the problem. The in sample fit looks good The DWThe in sample fit looks good. The DW looks good. But the forecast is weak.

The BX tab shows the problem. In the forecast the strong AR1 term fades outforecast, the strong AR1 term fades out,

causing a declining forecast.

© 2009, Itron Inc. 15

Page 16: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Diagnosing Data Errors

To illustrate a data error a spike was introduced, followed by a dip.

© 2009, Itron Inc. 16

Page 17: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Data Errors

The data error hides the underlying y gpositive autocorrelation. The large positive

residual followed by the large negative residual drives the DW upward.

The ACF is also impacted, showing a negative first order correlation.

To fix this problem, edit the data, or include a trinary variable (0, 1, -1), or

mark the two points as Bad.

© 2009, Itron Inc. 17

mark the two points as Bad.

Page 18: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Diagnosing Structural Shifts

To illustrate a structural shift, a ,constant was added all data points

starting in January, 2004.

© 2009, Itron Inc. 18

Page 19: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Structural Data Shift Residuals

The data shift shows clearly in the residual plot.

Statistics indicate strong positive autocorrelation.

© 2009, Itron Inc. 19

Page 20: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Add AR(1) TermAdding an AR1 hides the problem.

The fit looks good, and the Stats look good. But the trend variable

coefficients are biased upward.

The contribution of the ARMA errors on the BX tab reflects the problemthe BX tab reflects the problem.

© 2009, Itron Inc. 20

Page 21: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Add Shift VariableRemoving the AR1 and adding a

binary shift variable improves the coefficient estimates.

The BX tab shows the estimated contribution of the shift variable. The model can now be finalized

by adding an AR1 term to account for moderate first order autocorrelation.

© 2009, Itron Inc. 21

Page 22: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

ConclusionEstimate structural models with ARMA turned off.  Work with the model until things look right.

Look at residual plots and outliers.  You may want to correct for outliers with binaries, trinaries (0, 1, ‐1), or bad spots.

Examine diagnostics (DW, LB, ACF) to see if autocorrelation is a problem.

If so, add appropriate ARMA terms (usually a short AR).> This should not change the structural coefficients much.g

Examine contribution of ARMA terms to predicted values and forecasts on the BX tab.  The contribution should be small.

Use end shifts to insure that the model starts in the right place and thatUse end shifts to insure that the model starts in the right place and that the ARMA process is not a major factor in the forecast.

© 2009, Itron Inc. 22

Page 23: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Issues with Lagged Dependent VariablesProblem:  Short term forecasting models were consistently g yoverforecasting loads in early 2009.  Backcasts looked fine.  Forecasts increased sharply.  What is wrong with the model?model?

The models contain:> Daily binariesDaily binaries

> Seasonal variables

> Holiday variables

> Weather variables

> Lagged Dependent variable

© 2009, Itron Inc. 23

Page 24: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

How Lagged Dependents WorkModel: t1ttt eYcXbaY +×+×+= −

Long Run Equilibrium: c1Xba

Y*

*

×+=

Adjustment Process:> X(t) up by 1  Y(t) up by b

> Y(t) up by b  Y(t+1) up by c × b

> Y(t+1) up by c × b  Y(t+2) up by c × c × b 

> Long run impact = b × (1 + c + c2 + c3 + ……) = b/(1‐c)

Note that with multiple X variables, the same lag structure applies to all variables.  Holiday variables have lagged effects.  Weather changes have lagged effects.  Week day variables have lagged effects.

© 2009, Itron Inc. 24

Page 25: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Spreadsheet Example (c=.8)

Long RunImpact = 50

© 2009, Itron Inc. 25

Page 26: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Spreadsheet Example (c=.5)

Long RunImpact = -20

© 2009, Itron Inc. 26

Page 27: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Daily Energy Example ‐‐ Regression

MAD = 3,651MAPE = 11.24%

Load DeclinesStart Here

© 2009, Itron Inc. 27

Page 28: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Daily Energy Example – Regression with LagDep

MAD = 894MAPE = 2.39%

Forecast valuesreturn to old levelreturn to old level

LagDep actual values hold predicted in line

© 2009, Itron Inc. 28

Page 29: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Daily Energy Example – Regression with End Shift

MAD = 1.058MAPE = 2.79%

Forecast valuest l lare at new levels

© 2009, Itron Inc. 29

Page 30: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Conclusion on Lagged Dependent VariablesLagged dependent variables are appropriate when there is a partial adjustment or adaptive expectations process in place.

Lagged dependent variables imply a geometric (Koyck) lag structure for the response to a change in any X variable.  It is the same lag structure for all variables (1 + c + c2 + c3 …).

If there is a shift in the data (such as a downturn in the economy), the lagged dependent variable can help “explain” the shift in the historical data.  It will be significant and it will improve the fit.  But in the forecast, the level will return toward the old level fairly quickly. 

It is better to have an economic activity varible or end shift variables to quantify the effects of the downturn, allowing the model to settle and forecast at the new levels.  For short‐term forecasting, the timing of the recovery is a moot point.  You are where you are when the forecast starts.

© 2009, Itron Inc. 30

Page 31: Stat Corner:Stat Corner: Regression with ARMA Errorscapabilities.itron.com/downloads/BrownBag_120809.pdf · Stat Corner:Stat Corner: Regression with ARMA Errors ... Stat Corner: Regression

Questions?Press *6 to ask a question or type in bottom, right corner.

FULL 2010 WORKSHOP SCHEDULE AND REGISTRATION COMING SOON.Energy Forecasting Workshop – Amsterdam, The Netherlands – February 24Energy Forecasting Workshop – Melbourne, Australia ‐ TBDFundamentals of Sales and Demand Forecasting – Orlando FL – March 15‐17Fundamentals of Sales and Demand Forecasting  Orlando, FL  March 15 17Forecasting 101 – Orlando, FL – April 5‐7Building End‐Use Models for Sales Forecasting – Las Vegas, NV – TBDFundamentals of MetrixND – Boston, MA – June 7‐8 Forecasting 101 – San Diego, CA – September 27‐29

d l f h d l bFundamentals of Short‐Term and Hourly Forecasting – San Diego, CA – October 27‐29

OTHER  FORECASTING MEETINGS4th Annual European Forecasting User Group Meeting – Hasselt, Belgium – February 25‐263rd A l A t li F ti U G M ti M lb A t li TBD3rd Annual Australian Forecasting User Group Meeting – Melbourne, Australia – TBDAnnual ISO/RTO Forecasting Summit – Las Vegas, NV – TBDLong‐Term Forecasting/EFG – Las Vegas, NV ‐ TBD2010 Itron Users’ Conference – Orlando, FL – October 17‐19

© 2009, Itron Inc. 31

For more information and registration:  www.itron.com/forecastingworkshopsContact us at:  1.800.755.9585, 1.858.724.2620 or [email protected]