{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Res Ec 797A Lecture 9 - Fall 2011

Res Ec 797A Lecture 9 - Fall 2011 - Res Ec 797A Forecasting...

Info icon This preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Res Ec 797A: Forecasting Order Of Topics And Readings For Lecture 9 (October 4, 2011) Source Assignment 5 BM BM BM Enders Pagegs) Topic Three Pages Due October 12, 2011 (The majority of the three pages Numbered 1-3 relates to specific SAS instructions rather than to assignment tasks.) Four Pages SAS/ETS Time Series Forecasting System Notes: Fine-Tuning Numbered 1-4 And Additional Explanations (with specific reference to Assignment 5) A Clean Break: Difference Equations 42 Summary of BM pages 43-63: Background on Difference Equations 43-48 First installment of a set of notes on difference equations and their use in time series. Chapter 1 Difference equations: Pages 1-14; 14-17; 22-38 (Start reading this material. Expect it to be tough). University of Massachusetts Department of Resource Economics RESEC 797A Fall 2011 Assignment 5 HOLT-WINTERS EXPONENTIAL SMOOTHING In this exercise you will be estimating and forecasting with exponential smoothing for Variables 1 and 2. Split your data into within-sample and post-sample parts using the same time periods as you did for the previous exercises. 1. Use the appropriate two-parameter or three-parameter exponential smoothing algorithm in SAS for each series. Produce one-step-ahead within-sample and out-of—sample forecasts. Compute within-sample and out-of—sample RMSEs. Compare the accuracy of these with naive no-change forecasts; i.e., use Theil’s U. You need to get the data into a form that SAS can read. This can be a major obstacle. If it consists of a text file and the date is not in a form recognizable by SAS, the code shown below and the notes that follow will get you started. /* this program reads a text file of two columns, the variable is called series */ /* date is in the form yyyy.q for quarterly data *x’ /* SAS does not appear to read the date in this form *f /* the function intnx is used to calculate the date *! data templ (keep = date empl); infile 'd:\sas\table51.dat'; input num $ empl; date=intnx('qtr', '1jan85'd, _n_-1); format date ych. ; run; Notes: 1. SAS can read an Excel spreadsheet. You can import it into SAS. 2. The above code will read a single column of data also if the input line is changed to: input empl ; 3. The INTNX function assigns a SAS-readable date to each observation. My series started from January 1985. Insert your starting date in similar way. Use 'qtr', 'month' , or 'year' as appropriate. 4. If your data are monthly change the format command to: format date yymmc. ; Make sure you include the "dot" after yymmc If yearly, use: format date year. (with the "dot" also). 5. If you PROC PRINT the output, it should look like The SAS System 11:03 Thursday, September 29, 2011 OBS EMPL DATE 1 416.0 1985:1 2 446.8 198512 3 461.9 l985:3 4 465.7 198524 6. Go to the Tool Bar. Click on the commands: SolutionslAnalysis|Time Series Forecasting System. Click on the "Browse ..." box to the right of "Data Set". Highlight the library "WORK". Highlight the SAS data set "TEMPl ". - You should find that the "Time 1D" and "Interval" are correctly filled in, based on the information contained in the SAS code on the previous page. Click OK. Don't forget to do this! 7. You are now in the "Time Series Forecasting" dialog box. Click "Develop Models". 8. You are now in the "Series Selection" dialog box. You now need to select the variable with which you will be working. Click on "empl/", located in the white box under "Time Series Variables". Then, click "OK". 9. You are back in the "Develop Models" dialog box. You need to specify the ranges of your within- sample and post-sample data sets. Click on the "Set Ranges..." box located to the right of "Evaluation Range:". 10. You are now in the "Time Ranges Specification" dialog box. You will notice that the starting and ending points of your data are displayed next to "Period of Fit". You will want to change this range so that you exclude the last 8 or 12 observations (the reserved data). Change the ”Period of Evaluation" range to the same limits for your post-sample. (Click on the horizontal pointers to make changes.) You can set the periods for the "Forecast Horizon", if you desire. (The Forecast Horizon is beyond the post-sample period, and we have not been using this for anything). Also, specify the correct number of periods in your "Hold-out Sample". (This is the post-sample.) Finally, click "OK". 11. You are back in the "Develop Models" dialog box. Click "No Models" located in the big, white box. Click on "Fit Smoothing Model". Choose an appropriate exponential smoothing model. This will most likely be either Holt's or Winters' multiplicative depending on your data (annual would only need Holt's). Click "OK". 12. Go to "View" on the Tool Bar and check out what you've done! Play with it! For example, click on "Forecast Table" to get your series of one-step ahead forecasts, or click on "Parameter Estimates" or beta hat. You will see the estimates of the smoothing parameters and the level, trend, and seasonal factors. Click on sigma-squared and get summary statistics including RMSE. University of Massachusetts Department of Resource Economics RESEC 797A SAS/ETS Time Series Forecasting System Notes Fine-Tuning and Additional Explanations Return to the SAS program presented at the beginning of Assignment 5. It was a program that read in quarterly data for use in the SAS Econometric Time-Series (ETS) environment. Recall that we did nothing with this program or with the data set used in the program except to illustrate how to get the data into a form that SAS ETS could use immediately. We now use the program presented at the beginning of Assignment 5 and its data set to show how to derive relevant within-sample and post-sample information. Reading in data by way of the original SAS program: The data in Table 51 are employment data. So, I will refer to them as “empl” . - data temp1 (keep = date empl); infile 'a:\tab1e51.dat‘; input num $ empl; date=intnx(’qtr',‘1jan85'd,_n_-1); format date ych.; ' proo print data=temp1 ; run; Output: The SAS System 083 DATE EMPL - 1 1985.1 416.0 2 1985.2 446.8 3 1985.3 461.9 4 1985.4 465.7 5 1986.1 445.9 6 1986.2 471.3 7 1986.3 486.6 8 1986.4 484.2 9 1987.1 449.2 10 1987.2 483.2 11 1987.3 489.6 12 1987.4 484.3 13 1988.1 476.5 14 1988.2 507.0 15 1988.3 516.3 16 1988.4 510.8 The steps presented in Assignment 5 provide a very detailed explanation pertaining to estimating an exponential smoothing model. After going through these steps several times. reinforcement begins to take hold and things begin to be automatic. It's time to fine-tune things. That is, think of the information We need to generate so that we can put Assignment 5 in the same format as all other assignments. Specifically, our plan is to obtain oue-step—ahead forecasts for the within-sample and post-sample periods for Variable l and Variable 2. Implied here is obtaining the RMSE for both the within-sample and post-sample periods. To get within-sample RMSE Complete everything through Step 8 on page 2 of the Assignment 5 handout. After clicking “OK”, you are in the “Develop Models" dialog box. The very first statistic you desire to generate is the within-sample RMSE. Click on the “Set Ranges. . ." box. You are now in the “Time Ranges Specification” dialog box. Let the end points of both the “Period of Fit" range and the “Period of Evaluation" range be those that define your within-sample period. In my simple example, this is 198511 to 1986z4. Click “OK". You are back in the “Develop Models" dialog box. Click “No Models” located in the big, white box. Click on “Fit Smoothing Model”. Choose an appropriate exponential smoothing model. Try Winters‘ multiplicative on these quarterly data. Click “OK”. Notice that I am back to the “Develop Models” dialog box, “Winters Method — Multiplicative” is highlighted in black, and the Root Mean Square Error value 3.11602 is reported. Looking at output from estimation Go to the Tool Bar and click “View". Then, click “Parameter Estimates". You will see the estimates of the smoothing parameters and the level, trend, and seasonal factors. My results are shown below. Paramet er Estimates EMPL Winters Method -- Multiplicative PARM VALUE STDERR T P LEVEL Smoothing Weight 0.00100 0.2098 0.004766 0.9964 TREND Smoothing Weight 0.00100 35.1800 0.0000284 1.0000 SEASONAL Smoothing Weight 0.54940 0.6589 0.8338 0.4424 Residual Variance (sigma squared) 15.53528 . . . Smoothed Level 480.54870 . . . Smoothed Trend 6.13097 . . . Smoothed Seasonal Factor 1 0.95875 . . Smoothed Seasonal Factor 2 1.00621 . . Smoothed Seasonal Factor 3 1.02571 . . . Smoothed Seasonal Factor 4 1.01312 . . . The values for the level and trend smoothed series apply to the last within-sample value. The seasonal factors are the last four calculated. If your within-sample series had ended on 1987.1, the seasonal factors would be listed in the order 1987.], 1986.2, 1986.3, 1986.4. (The values would be different from the ones shOWn here since the additional observation will cause the optimal smoothing parameters to change as well as the values of the level, trend and seasonal factors series.) The denominator of the residual variance is the number of observations within-sample (here, 8) minus the number of smoothing parameters (here, 3). Go back to the Tool Bar, click “View” and then “Statistics of Fit”. You will see something similar to the table below. Notice that the denominator of MSE (presented below) is the number of observations within—sample. The RMSE is the same value as the one shown previously with the blackened model title. Note that this is the within- sample RMSE. Statistics of Fit EMPL Winters Method -- Multiplicative Statistic Description Value MSE Mean Square Error 9.70955 RMSE Root Mean Square Error 3.11602 MAPE Mean Absolute Percent Error 0.44325 MAE Mean Absolute Error 2.04143 RSQUARE R-Square 0.979 To get ex-post RMSE and one-step-ahead ex post forecasts Click “Options" on the Tool Bar. Then, click “Time Ranges Specification". Change the Period of Evaluation to accommodate the post—sample observations. These include 1987:] - 19884. Click “OK”. You will get new “Statistics of Fit" output. This is post-sample information. It appears below. Statistics of Fit EMPL Winters Method -- Multiplicative Statistic Description Value MSE Mean Square Error 238.77133 RMSE Root Mean Square Error 15.45223 MAPE Mean Absolute Percent Error 2.75793 MAE Mean Absolute Error 13.36496 RSQUARE R-Square 0.428 To the right of the “Statistics of Fit" table in the Model Viewer dialog box is a column of icons. Click the bottom one. This is the “Forecast Table" that provides within- sample and post-sample forecasts. I highlighted the post-sample results and “printed” that output to my output log. Date Actual Predict Upper Lower Error _Leve|_ _Trend_ _Sfactor 1985:1 416.0 416.759 424.484 409.033 -0.759 437.628 6.131 0.951 19852 446.8 445.922 453.647 438.197 0.878 443.760 6.131 1.006 1985:3 461.9 460.969 468.694 453.243 0.932 449.892 6.131 1.026 1985:4 465.7 464.318 472.044 456.593 1.382 456.024 6.131 1.020 198621 445.9 439.676 447.401 431.950 6.225 462.161 6.131 0.959 19862 471.3 471.084 478.809 463.358 0.217 468.293 6.131 1.006 198623 486.6 486.645 494.370 478.919 -0.045 474.424 6.131 1.026 198614 484.2 490.096 497.821 482.371 -5.896 480.549 6.131 1.013 1987:1 449.2 466.605 474.330 458.880 -17.405 486.662 6.131 0.939 1987:2 483.2 495.855 503.580 488.130 -12.655 492.780 6.131 0.992 1987:3 489.6 511.737 519.462 504.012 -22.137 498.889 6.131 1.001 1987:4 484.3 511 .647 519.372 503.921 -27.347 504.993 6.131 0.983 1988:1 476.5 480.008 487.733 472.283 -3.508 511.120 6.131 0.935 1988:2 507.0 513.175 520.900 505.450 -6.175 517.245 6.131 0.986 198823 516.3 524.085 531.810 516.360 -7.785 523.368 6.131 0.993 1988:4 510.8 520.709 528.434 512.984 -9.909 529.489 6.131 0.973 1989:1 500.995 508.720 493.270 6.131 0.935 535.620 Again, the within-sample data, used for estimation, are from 1985:1 to l986:4. The bold figures are for the ex post period plus the one ex ante forecast. The prediction intervals (called, regretably, confidence intervals) are titled U95 and L95 in the model viewer, being the predicted value 1 square root of residual variance x 1.96. When you “print” the output, you lose the information that they are 95% intervals. Unfortunately you do not get RMSE for naive no change nor do you get Theil’s U. Summary of BM pages 43-63: Background on Difference Equations Start with a difference equation —> This is supposed to characterize the relationship among observations over time. Find the time path. Solve for the general solution, which is the time path. Find the homogeneous solution and then the particular solution. Use the homogeneous solution to find the characteristic equation and the characteristic roots. Determine whether the difference equation leads to stability by comparing the characteristic roots to the value 1. Show a simpler set of rules (using the coefficients of the difference equation) to look at the necessary and sufficient conditions for stability. Resort to looking at the magnitude of the characteristic roots if the sufficient conditions for stability using the coefficients fail. Introduce a stochastic structure to the difference equation as the way to begin addressing stationarity. 42 Background On Difference Equations Focus of a time series model: - To decompose a series into its trend, seasonal, cyclical, and irregular components. 0 Each of these components is subject to stochastic behavior. 0 The trick is to discover the process that generates each component. 0 Discovery begins with an expression that shows the relationship among observations through time. This is a difference equation. We manipulate (or solve) the difference equation to discover the DGP. The solution expresses the value of a variable in terms of its own lagged values, time, and other variables. 0 By definition, this final expression is a time path. 0 Conclusion: Start with a difference equation; solve it; end up with a time path. Linear difference equations and their solutions play an important role in practically all areas of time series analysis. If time is regarded as a continuous variable and the equations involve unknown functions and their derivatives, we find ourselves considering differential equations. If time is taken to be a discrete (or integer) valued variable and the equations relate the values of such variables at different points in time, then we are confronted with difference equations or recurrence relations. Characteristics (regarding both difference equations and differential equations) Example: ym - yt = 2 (1) 0 linear or nonlinear: The example above is linear since no y term (for any period) is raised to a power higher than 1. ‘ - homogeneous or nonhomogeneous: The example above is nonhomogeneous since the right-hand side (where there is no y term) is nonzero. 0 first or second (or higher) order: The example above is first order since there exists only a first difference, involving a one- period time lag only. Thus, the equation above is a linear, nonhomogeneous, first order difference equation. What does it mean to solve a difference equation? 43 To solve a difference equation (for example, (1) above) means to find the time path of y. Call this time path y(t). This time path is: - a function of time; - totally free from any differential expressions; 0 consistent with the original difference equation and its initial conditions. (The counterpart--solving a differential equation--is a matter of integration). Perhaps the crudest way to solve a difference equation: method of iteration - The original equation gives the pattern of change of y between two consecutive periods 0 Once this pattern is specified and once we are given an initial value of y (call it yo), we can find y], then y;, and then y3, ..., then yn through repeated application of the pattern specified in the difference equation. Example 1: Solve (1) using the method of iteration. Assume an initial value of yo = 15. Repeat (1): ym - y, = 2 Application through time: y] - yo = 2 3’1 = Yo +2 y2 = y] +2 = (y0+2) + 2 = yo +2(2) Y3 = Y2 +2 = [Yo+2(2)l + 2 = Yo +3 (2) In general, for any period: yt = yo + t(2) = 15+2t Note: This last expression is consistent with " finding the time path of y " or " solving the difference equation. " Example 2: Find the solution to y, = ayH + b. (2) Notice here that a is constant, b is not. Start with a given yo. Solve, as in the previous example, using the method of iteration. Y: = aYt-l + bt 3’1 = ayO +b1 y2 = ay1 +b2 = a(ayo+b1) + b2 = azyo + ab] + b2 y3 = ayz +b3 = a(a2yo+ab1+b2) + b3 = a3yo + a2b1+ abz + b3 If we carried out the substitutions for y4 and y5, we would get: 44 Y4 = a4yo + a3b1 + azbz + ab3 + b4 y5 = asyo + a4b1 + 33b; + a2b3 + ab4 + b5 A pattern emerges! In general, we have I yt = a‘yo + Z a"kbk (3) k=l This last line represents the general solution to the difference equation. You can check that the last expression above is the solution to y = ayH + b by substituting the last expression (for y“) into the right-hand side of y = ayH + b. Example 3: Consider the special case of the previous example where bk = b. In terms of (2), a and now b are constants. Thus, the summation expression in (3) becomes I a“kb = b22a"k = b(a"l+a"2+...+a+1) k=l t—k M- The quantity that is being summed in the last expression is a finite geometric series. It abides by the summation formula for a finite geometric series: _ ( 1+a+...+a"2+a"‘ =1a forage 1. 1—a So, the general solution for y = ayH + b is: 1_ t Y.=a‘yo+b|:—a] l-a The last term can be manipulated to rewrite this equation as: b-bat bal b = I + = l _— + .— y! ayo l-a a 0 l-a l-a =a'(y0-i) + —b—,fora¢1. l—a l-a 45 Example 4: Now, let's change gears and consider manipulating a rather than b. Specifically, consider the situation where a = 1. Is this cause for alarm regarding the previous equation, which again is: y = t[ _i] + _b_ t a yo 1-a 1-a b because -1— now appears to be undefined? - a To see that there is no cause for alarm, retrace the origin of the solution presented above. It is: _ I Yr = atyo + b|:1—a:| l-a = a‘yo + b[a“‘ +81"2 + + a +1] 7 Noticethat,ifa=l, [21"] + at" + + a + l] = t. This means that: yt = atyO + bt' Q: What do you notice about the time path of y: when a=1? A: It takes off in the direction and pitch dictated by b. Furthermore, this direction and pitch are the same, i.e., deterministic, for all values of t. Let ' s summarize on the basis of what we have thus far: 0 An almost trivial issue: For each choice of yo, there is a different corresponding unique solution to the difference equation. - How do changes in the parameters entering into the difference equation affect the solution of the difference equation? That is, what is the time path of the variable in question? - Does it settle down and reach some equilibrium state? - Does it take off? 46 Example 5: Let ' s manipulate "a" further and refresh our memory regarding the original difference being used in Examples 2-4: Y. = aym + b Recall its solution: a‘(yo-i) + —b— fora¢1 1-a l-a yr Q: Now, if a ¢ 1, what happens to the time path of y if y0 = 1—b— ? - a b . . . . . A: y1 = — ; y has ach1eved a statlonary state. That 15, 1t 18 the same value for any y. We also 1 - a refer to this stationary state as an equilibrium state. Putting everything together and starting at the top of Example 5, this value of yr, which is L , 1 - a (and call it y*), is an equilibrium or stationary state for the difference equation y1 = Ely“l + bwhena¢1. We've defined what...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern