* * Example 17.11 from page 692 * cal(q) 1954 open data table17-6.prn data(format=prn,org=columns) 1954:1 1999:1 * * The data set doesn't provide the "Z" variables, so we have to create them. * * Method 1: Direct use of SET. This is very clumsy if the number * of lags is large. * set z1 = sales+sales{1}+sales{2}+sales{3} set z2 = sales{1}+2*sales{2}+3*sales{3} set z3 = sales{1}+4*sales{2}+9*sales{3} * linreg inventory # constant z1 z2 z3 * * Using ENCODE, which is specifically designed for these types of restrictions. * This requires creating a matrix with dimensions. * * # of Z's x # of lag coefficients * * then making its entries equal to the coefficients in the linear combinations * which create the Z's. We would recommend using j**(i-1) rather than * (j-1)**(i-1) as is used below (which gives the same coding as above), as the * (1,1) value with (j-1)**(i-1) is 0**0, which isn't well-defined, and so has to * be patched. See if you can figure out why it makes no difference to the final * beta coefficients which of these two forms you choose. * dec rect r(3,4) ewise r(i,j)=(j-1)**(i-1) compute r(1,1)=1.0 encode r / z1 z2 z3 # sales{0 to 3} linreg inventory # constant z1 z2 z3 * * Redoing the LINREG using the UNRAVEL option, which substitutes out the * coefficients * linreg(unravel) inventory # constant z1 z2 z3 * * Using the PDL procedure. The PDL is estimated by * @pdl dependent-variable * # x-variable start-lag end-lag PDL degree * * This has several options, including GRAPH, which graphs the lag distribution, * and CODEDREG, which prints the coded regression (The coefficients on this won't * match up with the ones above because it uses the j**(i-1) coding. Endpoint * restrictions (as described on page 695) are done using the option * CONSTRAIN=NEAR/FAR/BOTH to constrain the near end point (that is to force the * polynomial at the lag BEFORE the start-lag to zero), far (polynomial at the lag * after end-lag forced to be zero), or both. * @pdl(graph,codedreg) inventory # sales 0 3 2 * * Unrestricted distributed lag * linreg inventory # constant sales{0 to 3}