* * Example 19.6 from page 585 * open data tablef5-1[1].txt calendar(q) 1950 data(format=prn,org=columns) 1950:1 2000:4 year qtr realgdp realcons realinvs realgovt realdpi $ cpi_u m1 tbilrate unemp pop infl realint * set logc = log(realcons) set logy = log(realgdp) set delc = logc-logc{1} set dely = logy-logy{1} * linreg logc # constant logc{1 2} logy{0 1 2} compute rss0=%rss,ndf0=%ndf * * This model tends to have multiple local minima for the sum of squared * residuals, so getting good guess values is important. This takes the roots of * the unrestricted own lags to start the lambda's. (If the roots are complex, * we act as if the lag 2 coefficient is zero and use the remaining root). * nonlin mu b0 tau1 lambda2 tau2 compute mu=%beta(1),b0=%beta(4) compute discrim=%beta(2)**2-4*%beta(3) compute roots=%polyroots(%eqnlagpoly(0,logc)) if %rows(roots)==2 compute lambda1=roots(1),lambda2=roots(2) else compute lambda1=-%beta(2),lambda2=0.0 endif compute tau1=lambda1,tau2=lambda2 frml comfac logc = mu+(tau1+lambda2)*logc{1}-(tau1*lambda2)*logc{2}+b0*logy-b0*(tau1+tau2)*logy{1}+b0*tau1*tau2*logy{2} nlls(frml=comfac) compute rss1=%rss nonlin mu b0 tau1 tau2 lambda2=tau2 nlls(frml=comfac) compute rss2=%rss * * Do the tests of the restrictions. The second test statistic in the text (1st * printing) is missing the /2 * cdf(title="Test of One Common Factor vs Zero") ftest (rss1-rss0)/(rss0/ndf0) 1 ndf0 cdf(title="Test of Two Common Factors vs Zero") ftest (rss2-rss0)/2/(rss0/ndf0) 2 ndf0