Transcription of Time Series Forecasting Methods
1 IntroductionUnivariate ForecastingConclusionsTime Series Forecasting MethodsNate DerbyStatis Pro Data AnalyticsSeattle, WA, USAC algary SAS Users Group, 11/12/09 Nate DerbyTime Series Forecasting Methods1 / 43 IntroductionUnivariate ForecastingConclusionsOutline1 IntroductionObjectivesStrategies2 Univariate ForecastingSeasonal Moving AverageExponential SmoothingARIMA3 ConclusionsWhich Method?Are Our Results Better?What s Next?Nate DerbyTime Series Forecasting Methods2 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esObjectivesWhat is time Series data?
2 What do we want out of a forecast?Long-term or short-term?Broken down into different categories/ time units?Do we wantprediction intervals?Do we want to measure effect ofXonY? (scenarioforecasting)What Methods are out there to forecast/analyze them?How do we decide which method is best?How can we use SAS for all this?Nate DerbyTime Series Forecasting Methods3 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esWhat is time Series Data? time Series data = Data with a pattern ( trend ) over time trend = Get wrong myPROC DerbyTime Series Forecasting Methods4 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi es !
3 " " # $ % # & " '( )* + , " ! $ - " ./00/10200210300310400410100110500510600 0/7480/7100/71/0/7120/7130/7140/7110/715 0/7160/7190/7180/7500/75/0/752!"#$"%&'() **&%+&#*',)%-' ./.'0'1&2-' .3456789*)%:*'8;'<)**&%+&#*=Nate DerbyTime Series Forecasting Methods5 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esBase Data SetNate DerbyTime Series Forecasting Methods6 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esWhat do we want out of a Forecast?Long-term:Involvesmanyassumptio ns! ( , global warming)Involves tons of : In the long run we are all dead.
4 We ll focus on the short categories?Two strategies for Forecasting A, B and C:1 Forecast their combined total, then break it down them : Do (1) unless percentages are DerbyTime Series Forecasting Methods7 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esWhat do we want out of a Forecast?Different time units?Two strategies for Forecasting at two different time units ( ,daily and weekly):1 Forecast weekly, then break down into days by daily, then aggregate into : Idea: Do (1) unless percentages are we want prediction intervals?Prediction interval = Interval where data point will be with90/95/99% , we want them!
5 Nate DerbyTime Series Forecasting Methods8 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esWhat do we want out of a Forecast?Do we want to measure effect ofXonY?Ex: Marketing campaign calls to call to do, butAllows for scenario Forecasting !Idea: Do it, but only with most Questions: Basis of this talk:What Methods are out there to forecast/analyze them?How do we decide which method is best?How can we use SAS for all this? Methods will DerbyTime Series Forecasting Methods9 / 43 IntroductionUnivariate ForecastingConclusionsObjectivesStrategi esStrategiesTwo stages:Univariate(one variable) Forecasting :ForecastsYfrom trend us a basic (many variables) Forecasting :ForecastsYfrom trend and other variablesX1,X2.
6 Allows for what if scenario or may not make more accurate DerbyTime Series Forecasting Methods10 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMAU nivariate Forecasting - IntroGives us a benchmark for comparing multivariate give better forecasts than Methods can be extended to three Methods :Seasonal moving average(verysimple)Exponential smoothing(simple)ARIMA(complex)More complex Methods , for later on (for me):State space(promising)Bayesian(maybe .. )Wavelets?(forget it!)Nate DerbyTime Series Forecasting Methods11 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMAOnce Again.
7 Q: Why not usePROC REG?Yt= 0+ 1Xt+ZtA: We can get misleading results (see myPROC REGpaper).Nate DerbyTime Series Forecasting Methods12 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMAS easonal Moving AverageSimple but sometimes effective!Moving Average:Forecast=Average of Moving Average:Forecast=Average of a certain point, forecast the same for each of t allow for a based on amodel No prediction DerbyTime Series Forecasting Methods13 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMASAS CodeMaking lags in aDATA step (to make the averages) is not fun:Making 4 lags(Brocklebank and Dickey, p.)
8 45)DATA movingaverage;..RETAIN date pass1-pass4;OUTPUT;pass4=pass3;pass3=pas s2;pass2=pass1;pass1=pass;RUN;Nate DerbyTime Series Forecasting Methods14 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMASAS CodeMuch easier with a trick withPROC = averaging over past 5 years on that same month:Yt=15(Yt 12+Yt 24+Yt 36+Yt 48+Yt 60) Forecasting 3 weeks ahead, seasonal moving averagePROC ARIMA data=airline;IDENTIFY var=pass noprint;ESTIMATE p=( 12, 24, 36, 48, 60 ) q=0 ar= noconstant noprint;FORECAST lead=12 out=foremave id=date interval=month noprint;RUN;QUIT;Nate DerbyTime Series Forecasting Methods15 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMA !
9 " " # $ % # & " '( )* + , " ! $ - " ./00/10200210300310400410100110500510600 0/7480/7100/71/0/7120/7130/7140/7110/715 0/7160/7190/7180/7500/75/0/752!"#$"%&'() **&%+&#*',)%-' ./.'0'1&2-' .3456789*)%:*'8;'<)**&%+&#*=Nate DerbyTime Series Forecasting Methods16 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMA ! " " # $ % # & " '( )* + , " ! $ - " ./00/10200210300310400410100110500510600 0/7480/7100/71/0/7120/7130/7140/7110/715 0/7160/7190/7180/7500/75/0/752!"#$"%&'() **&%+&#*',)%-' ./.'0'1&2-' .345 67"%+'!7&#)+&'86#&2)*9*Nate DerbyTime Series Forecasting Methods17 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMAE xponential Smoothing INotation: yt(h)= forecast ofYat horizonh, given at 1: PredictYt+hby taking weighted sum of pastobservations: yt(h) = 0yt+ 1yt 1+ Assumes yt(h)is constant for all 2: Weight recent observations heavier than older ones.
10 I=c i,0< <1 yt(h) =c(yt+ yt 1+ 2yt 2+ )wherecis a constant so that weights sum to DerbyTime Series Forecasting Methods18 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMAE xponential Smoothing II yt(h) =c(yt+ yt 1+ 2yt 2+ )Weights areexponentially decaying(hence the name).Choose by minimizing squared one-step prediction :Just a weighted moving be extended to include trend and intervals? Sort of ..Nate DerbyTime Series Forecasting Methods19 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMASAS CodeAll done withPROC FORECAST:method=expo trend=1for trend=2for seasons=( 12 )for 3 weeks ahead, exponential smoothingPROC FORECAST data=airline method=xx interval=month lead=12out=foreexsm outactual out1step;VAR pass;ID date;RUN;Nate DerbyTime Series Forecasting Methods20 / 43 IntroductionUnivariate ForecastingConclusionsSeasonal Moving AverageExponential SmoothingARIMA !