(R) / / / / / / / / / / / / Statistics/Data Analysis

Size: px
Start display at page:

Download "(R) / / / / / / / / / / / / Statistics/Data Analysis"

Transcription

1 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 1 (R) / / / / / / / / / / / / Statistics/Data Analysis User: Prof. Juan Francisco Islas{space -4} Project: UNIDAD II name: <unnamed> log: C:\data\poe4stata\chap09.log log type: text opened on: 20 Sep 2012, 14:30:17 1. * file chap09.do for Using Stata for Principles of Econometrics, 4e ** cd c:\data\poe4stata * Stata Do-file 6. * copyright C 2011 by Lee C. Adkins and R. Carter Hill 7. * used for "Using Stata for Principles of Econometrics, 4e" 8. * by Lee C. Adkins and R. Carter Hill (2011) 9. * John Wiley and Sons, Inc * setup 12. * version * capture log close 14. set more off * dates 17. clear 18. set obs 100 obs was 0, now generate date = tq(1961q1) + _n list date in 1/ date format %tq date 22. list date in 1/ date q q q q q

2 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page tsset date time variable: date, 1961q1 to 1985q4 delta: 1 quarter 24. save new.dta, replace file new.dta saved use "C:\data\poe4stata\okun.dta", clear 27. generate date = tq(1985q2) + _n list date in date format %tq date 31. list date in date q tsset date time variable: date, 1985q2 to 2009q3 delta: 1 quarter label var u "% Unemployed" 36. label var g "% GDP growth" 37. tsline u g, lpattern(solid dash) list date u L.u D.u g L1.g L2.g L3.g in 1/ L. D. L. L2. L3. date u u u g g g g q q q q q

3 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page list date u L.u D.u g L1.g L2.g L3.g in 96/ L. D. L. L2. L3. date u u u g g g g q q q regress D.u L(0/3).g Source SS df MS Number of obs = F( 4, 90) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = D.u Coef. Std. Err. t P>t [95% Conf. Interval] g L L L _cons regress D.u L(0/2).g Source SS df MS Number of obs = F( 3, 92) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE =.1726 D.u Coef. Std. Err. t P>t [95% Conf. Interval] g L L _cons summarize g Variable Obs Mean Std. Dev. Min Max g

4 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page return list scalars: r(n) = 98 r(sum_w) = 98 r(mean) = r(var) = r(sd) = r(min) = -1.4 r(max) = 2.5 r(sum) = scatter g L.g, xline(`r(mean)') yline(`r(mean)') 49. ac g, lags(12) generate(ac_g) * approximate z scores 52. gen z=sqrt(e(n))*ac_g (86 missing values generated) 53. list ac_g z in 1/ ac_g z use "C:\data\poe4stata\phillips_aus.dta", clear 56. generate date = tq(1987q1) + _n format %tq date 58. tsset date time variable: date, 1987q1 to 2009q3 delta: 1 quarter 59.

5 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page tsline inf 61. tsline D.u reg inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons predict ehat, res (1 missing value generated) ac ehat, lags(12) generate(rk) 67. list rk in 1/ rk * * Corrgram 71. * corrgram ehat, lags(5) LAG AC PAC Q Prob>Q [Autocorrelation] [Partial Autocor]

6 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page di "rho1 = " r(ac1) " rho2 = " r(ac2) " rho3 = " r(ac3) rho1 = rho2 = rho3 = drop rk ehat * LM tests for AR(1) and AR(4) alternatives 77. reg inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons predict ehat, res (1 missing value generated) 79. regress inf D.u L.ehat Source SS df MS Number of obs = F( 2, 86) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D ehat L _cons test L.ehat ( 1) L.ehat = 0 F( 1, 86) = Prob > F =

7 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page * LM test for AR(1) 82. quietly regress ehat D.u L.ehat 83. di "Observations = " e(n) " and TR2 = " e(n)*e(r2) Observations = 89 and TR2 = * LM test for AR(4) 85. quietly regress ehat D.u L(1/4).ehat 86. di "Observations = " e(n) " and TR2 = " e(n)*e(r2) Observations = 86 and TR2 = drop ehat * Using the built-in bgodfrey command to test the 90. * AR(1) and AR(4) alternatives 91. regress inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons predict ehat, res (1 missing value generated) 93. estat bgodfrey, lags(1) Breusch-Godfrey LM test for autocorrelation lags(p) chi2 df Prob > chi H0: no serial correlation 94. estat bgodfrey, lags(4) Breusch-Godfrey LM test for autocorrelation lags(p) chi2 df Prob > chi H0: no serial correlation

8 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page * Replacing ehat(1) with zero and computing LM 97. replace ehat = 0 in 1 (1 real change made) 98. regress inf D.u L.ehat Source SS df MS Number of obs = F( 2, 87) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D ehat L _cons test L.ehat ( 1) L.ehat = 0 F( 1, 87) = Prob > F = quietly regress ehat D.u L.ehat 101. di "Observations = " e(n) " and TR2 = " e(n)*e(r2) Observations = 90 and TR2 = drop ehat * Getting Stata to use 90 observations for the LM test 105. reg inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons

9 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page predict ehat, res (1 missing value generated) * Using all observations for bgodfrey test 109. set obs 94 // add 3 observations to data obs was 91, now gsort -date // moves missing observations to end 111. replace date = date[_n-1] - 1 if missing(date) // creates dates for missing obs (3 real changes made) 112. replace ehat = 0 if missing(ehat) // puts zeros in for missing ehats (4 real changes made) 113. sort date // re-sort data into ascending order 114. regress ehat D.u L(1/4).ehat Source SS df MS Number of obs = F( 5, 84) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = ehat Coef. Std. Err. t P>t [95% Conf. Interval] u D ehat L L L L _cons di "Observations = " e(n) " and TR2 = " e(n)*e(r2) Observations = 90 and TR2 = use "C:\data\poe4stata\phillips_aus.dta", clear 118. generate date = tq(1987q1) + _n format %tq date 120. tsset date time variable: date, 1987q1 to 2009q3 delta: 1 quarter

10 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page scalar B = round(4*(e(n)/100)^(2/9)) 123. scalar list B B = regress inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons estimates store Wrong_SE 127. newey inf D.u, lag(4) Regression with Newey-West standard errors Number of obs = 90 maximum lag: 4 F( 1, 88) = 2.76 Prob > F = Newey-West inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons estimates store HAC_ esttab Wrong_SE HAC_4, compress se(%12.3f) b(%12.5f) gaps /// > scalars(r2_a rss aic) title("dependent Variable: inf") /// > mtitles("ls" "HAC(4)") Dependent Variable: inf (1) (2) LS HAC(4) D.u * (0.229) (0.318)

11 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 11 _cons *** *** (0.066) (0.112) N r2_a rss aic Standard errors in parentheses * p<0.05, ** p<0.01, *** p< * * Nonlinear least squares of AR(1) regression model 134. * nl (inf = {b1}*(1-{rho}) + {b2}*d.u + {rho}*l.inf - {rho}*{b2}*(l.d.u)), /// > variables(inf D.u L.inf L.D.u) (obs = 89) Iteration 0: residual SS = Iteration 1: residual SS = Iteration 2: residual SS = Iteration 3: residual SS = Iteration 4: residual SS = Iteration 5: residual SS = Source SS df MS Number of obs = 89 Model R-squared = Residual Adj R-squared = Root MSE = Total Res. dev. = inf Coef. Std. Err. t P>t [95% Conf. Interval] /b /rho /b Parameter b1 taken as constant term in model & ANOVA table 137. * To see the coefficient legend use coeflegend option 138. nl (inf = {b1}*(1-{rho}) + {b2}*d.u + {rho}*l.inf - {rho}*{b2}*(l.d.u)), /// > variables(inf D.u L.inf L.D.u) coeflegend (obs = 89) Iteration 0: residual SS = Iteration 1: residual SS = Iteration 2: residual SS = Iteration 3: residual SS = Iteration 4: residual SS = Iteration 5: residual SS = Source SS df MS Number of obs = 89 Model R-squared = Residual Adj R-squared = Root MSE = Total Res. dev. =

12 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 12 inf Coef. Legend /b _b[b1:_cons] /rho _b[rho:_cons] /b _b[b2:_cons] Parameter b1 taken as constant term in model & ANOVA table 139. scalar delta = _b[b1:_cons]*(1-_b[rho:_cons]) 140. scalar delta1 = - _b[rho:_cons]*_b[b2:_cons] * * More general model 144. * regress inf L.inf D.u L.D.u Source SS df MS Number of obs = F( 3, 85) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] inf L u D LD _cons estimates store General 148. scalar list delta delta1 delta = delta1 = testnl _b[l.d.u]=-_b[l.inf]*_b[d.u] 151. (1) _b[l.d.u] = -_b[l.inf]*_b[d.u] F(1, 85) = 0.11 Prob > F =

13 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page regress inf L.inf D.u Source SS df MS Number of obs = F( 2, 87) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] inf L u D _cons estimates store No_LDu regress inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons estimates store Original 157. esttab General No_LDu Original, compress se(%12.3f) b(%12.5f) /// > gaps scalars(r2_a rss aic) (1) (2) (3) inf inf inf L.inf *** *** (0.091) (0.085) D.u ** * * (0.250) (0.192) (0.229) LD.u (0.258)

14 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 14 _cons *** *** *** (0.090) (0.088) (0.066) N r2_a rss aic Standard errors in parentheses * p<0.05, ** p<0.01, *** p< * ARDL 160. regress inf L.inf L(0/1).D.u Source SS df MS Number of obs = F( 3, 85) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] inf L u D LD _cons estimates store AR1_DL regress inf L.inf D.u Source SS df MS Number of obs = F( 2, 87) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] inf L u D _cons

15 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page estimates store AR1_DL esttab AR1_DL1 AR1_DL0, compress se(%12.3f) b(%12.5f) /// > gaps scalars(r2_a rss aic) (1) (2) inf inf L.inf *** *** (0.091) (0.085) D.u ** * (0.250) (0.192) LD.u (0.258) _cons *** *** (0.090) (0.088) N r2_a rss aic Standard errors in parentheses * p<0.05, ** p<0.01, *** p< * Model selection program computes aic and sc 167. * To remove it from memory use: 168. * program drop modelsel 169. capture program drop modelsel program modelsel 1. scalar aic = ln(e(rss)/e(n))+2*e(rank)/e(n) 2. scalar sc = ln(e(rss)/e(n))+e(rank)*ln(e(n))/e(n) 3. scalar obs = e(n) 4. scalar list aic sc obs 5. end quietly regress inf L.inf L(0/1).D.u 174. modelsel aic = sc = obs = quietly regress inf L.inf L.D.u 176. modelsel aic = sc = obs = 89

16 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page * * Residual correlogram and graph 180. * quietly regress inf L.inf D.u 183. predict ehat, res (1 missing value generated) 184. corrgram ehat, lags(12) LAG AC PAC Q Prob>Q [Autocorrelation] [Partial Autocor] ac ehat, lags(12) 186. estat bgodfrey, lags( ) Breusch-Godfrey LM test for autocorrelation lags(p) chi2 df Prob > chi H0: no serial correlation 187. drop ehat * Table 9.4 AIC and SC Values for Phillips Curve ARDL model 190. * Note that regress can be abreviated to reg and quietly to qui quietly reg L(0/1).inf D.u if date>= tq(1988q3) 193. di "p=1 q=0" p=1 q=0

17 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page modelsel aic = sc = quietly regress L(0/2).inf D.u if date>= tq(1988q3) 196. di "p=2 q=0" p=2 q= modelsel aic = sc = quietly regress L(0/3).inf D.u if date>= tq(1988q3) 199. di "p=3 q=0" p=3 q= modelsel aic = sc = quietly regress L(0/4).inf D.u if date>= tq(1988q3) 202. di "p=4 q=0" p=4 q= modelsel aic = sc = quietly regress L(0/5).inf D.u if date>= tq(1988q3) 205. di "p=5 q=0" p=5 q= modelsel aic = sc = quietly regress L(0/6).inf D.u if date>= tq(1988q3) 208. di "p=6 q=0" p=6 q= modelsel aic = sc =

18 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page qui reg L(0/1).inf L(0/1).D.u if date>= tq(1988q3) 212. di "p=1 q=1" p=1 q= modelsel aic = sc = qui reg L(0/2).inf L(0/1).D.u if date>= tq(1988q3) 215. di "p=2 q=1" p=2 q= modelsel aic = sc = qui reg L(0/3).inf L(0/1).D.u if date>= tq(1988q3) 218. di "p=3 q=1" p=3 q= modelsel aic = sc = qui reg L(0/4).inf L(0/1).D.u if date>= tq(1988q3) 221. di "p=4 q=1" p=4 q= modelsel aic = sc = qui reg L(0/5).inf L(0/1).D.u if date>= tq(1988q3) 224. di "p=5 q=1" p=5 q= modelsel aic = sc = qui reg L(0/6).inf L(0/1).D.u if date>= tq(1988q3) 227. di "p=6 q=1" p=6 q=1

19 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page modelsel aic = sc = * Table 9.4 AIC and SC Values for Phillips Curve ARDL model 231. * Here is the entire thing again, using nested loops 232. forvalues q=0/1 { 2. forvalues p=1/6 { 3. quietly regress L(0/`p').inf L(0/`q').D.u if date >= tq(1988q3) 4. display "p=`p' q=`q'" 5. modelsel 6. } 7. } p=1 q=0 aic = sc = p=2 q=0 aic = sc = p=3 q=0 aic = sc = p=4 q=0 aic = sc = p=5 q=0 aic = sc = p=6 q=0 aic = sc = p=1 q=1 aic = sc = p=2 q=1 aic = sc = p=3 q=1 aic = sc = p=4 q=1 aic = sc = p=5 q=1 aic = sc = p=6 q=1 aic = sc =

20 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page * Using var to estimate ARDL 235. * Disadvantage: No estat after the procedure var inf in 7/91, lags(1/3) exog(l(0/1).d.u) Vector autoregression Sample: 1988q3-2009q3 No. of Log likelihood = AIC = FPE = HQIC = Det(Sigma_ml) = SBIC = Equation Parms RMSE R-sq chi2 P>chi inf inf Coef. Std. Err. z P>z [95% Conf. Interval] inf inf L L L u D LD _cons * ARDL models 240. use "C:\data\poe4stata\okun.dta", clear 241. generate date = tq(1985q2) + _n format %tq date 243. tsset date time variable: date, 1985q2 to 2009q3 delta: 1 quarter * Estimate the ARDL(0,2) 246. * Generate the correlogram and test for autocorrelation 247. reg D.u L(0/2).g Source SS df MS Number of obs = F( 3, 92) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE =.1726

21 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 21 D.u Coef. Std. Err. t P>t [95% Conf. Interval] g L L _cons predict ehat, res (2 missing values generated) 249. ac ehat, lags(12) 250. drop ehat 251. estat bgodfrey, lags( ) Breusch-Godfrey LM test for autocorrelation lags(p) chi2 df Prob > chi H0: no serial correlation * Model Selection for Okun's Law model 254. forvalues q=1/3 { 2. forvalues p=0/2 { 3. quietly regress L(0/`p').D.u L(0/`q').g if date >= tq(1986q1) 4. display "p=`p' q=`q'" 5. modelsel 6. } 7. } p=0 q=1 aic = sc = obs = 95 p=1 q=1 aic = sc = obs = 95 p=2 q=1 aic = sc = obs = 95 p=0 q=2 aic = sc = obs = 95 p=1 q=2 aic = sc = obs = 95 p=2 q=2 aic = sc = obs = 95 p=0 q=3 aic =

22 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 22 sc = obs = 95 p=1 q=3 aic = sc = obs = 95 p=2 q=3 aic = sc = obs = reg D.u L.D.u L(0/1).g Source SS df MS Number of obs = F( 3, 92) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = D.u Coef. Std. Err. t P>t [95% Conf. Interval] u LD g L _cons estat bgodfrey Breusch-Godfrey LM test for autocorrelation lags(p) chi2 df Prob > chi H0: no serial correlation * Figure reg g L(1/2).g Source SS df MS Number of obs = F( 2, 93) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = g Coef. Std. Err. t P>t [95% Conf. Interval] g L L _cons

23 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page predict ehat, res (2 missing values generated) 262. ac ehat, lags(12) * Table forvalues p=1/5 { 2. qui reg L(0/`p').g if date> tq(1986q2) 3. display "p=`p'" 4. modelsel 5. } p=1 aic = sc = obs = 93 p=2 aic = sc = obs = 93 p=3 aic = sc = obs = 93 p=4 aic = sc = obs = 93 p=5 aic = sc = obs = * Forecasting using -arima- instead of -regress * which, of course, yields different predictions 270. arima g, ar(1/2) (setting optimization to BHHH) Iteration 0: log likelihood = Iteration 1: log likelihood = Iteration 2: log likelihood = Iteration 3: log likelihood = Iteration 4: log likelihood = (switching optimization to BFGS) Iteration 5: log likelihood = Iteration 6: log likelihood = ARIMA regression Sample: 1985q2-2009q3 Number of obs = 98 Wald chi2(2) = Log likelihood = Prob > chi2 = OPG g Coef. Std. Err. z P>z [95% Conf. Interval] g _cons ARMA ar L L

24 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page 24 /sigma Note: The test of the variance against zero is one sided, and the two-sided confidence interval is truncated at zero tsappend, add(3) 272. predict ghat, y // for the point estimates 273. predict ghatse, mse // for the standard error of prediction * Forecasting with an AR model reg g L(1/2).g Source SS df MS Number of obs = F( 2, 93) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = g Coef. Std. Err. t P>t [95% Conf. Interval] g L L _cons scalar ghat1 = _b[_cons]+_b[l1.g]*g[98]+ _b[l2.g]*g[97] 279. scalar ghat2 = _b[_cons]+_b[l1.g]*ghat1+ _b[l2.g]*g[98] 280. scalar ghat3 = _b[_cons]+_b[l1.g]*ghat2+ _b[l2.g]*ghat scalar list ghat1 ghat2 ghat3 ghat1 = ghat2 = ghat3 = scalar var = e(rmse)^ scalar se1 = sqrt(var) 285. scalar se2 = sqrt(var*(1+(_b[l1.g])^2)) 286. scalar se3 = sqrt(var*((_b[l1.g]^2+_b[l2.g])^2+1+_b[l1.g]^2)) 287. scalar list se1 se2 se3 se1 = se2 = se3 =

25 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page scalar f1l = ghat1 - invttail(e(df_r),.025)*se scalar f1u = ghat1 + invttail(e(df_r),.025)*se scalar f2l = ghat2 - invttail(e(df_r),.025)*se scalar f2u = ghat2 + invttail(e(df_r),.025)*se scalar f3l = ghat3 - invttail(e(df_r),.025)*se scalar f3u = ghat3 + invttail(e(df_r),.025)*se scalar list f1l f1u f2l f2u f3l f3u f1l = f1u = f2l = f2u = f3l = f3u = * * Impact and Delay Multipliers from Okun's ARDL(1,1) model 302. * regress D.u L.D.u L(0/1).g Source SS df MS Number of obs = F( 3, 92) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = D.u Coef. Std. Err. t P>t [95% Conf. Interval] u LD g L _cons scalar b0 = _b[g] 307. scalar b1 = _b[l1.d.u]*b0+_b[l1.g]

26 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page scalar b2 = b1*_b[l1.d.u] 309. scalar list b0 b1 b2 b0 = b1 = b2 = * An alternative method: Exploiting variable creation 312. regress D.u L.D.u L(0/1).g Source SS df MS Number of obs = F( 3, 92) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = D.u Coef. Std. Err. t P>t [95% Conf. Interval] u LD g L _cons gen mult = _b[g] in 1 (100 missing values generated) 314. replace mult = L.mult*_b[L1.D.u]+_b[L1.g] in 2 (1 real change made) 315. replace mult = L.mult*_b[L1.D.u] in 3/8 (6 real changes made) 316. list mult in 1/ mult

27 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page gen lag = _n-1 in 1/8 (93 missing values generated) 318. line mult lag in 1/ * * Exponential Smoothing 322. * use "C:\data\poe4stata\okun.dta", clear 325. generate date = tq(1985q2) + _n format %tq date 327. tsset date time variable: date, 1985q2 to 2009q3 delta: 1 quarter tsappend, add(1) 330. tssmooth exponential sm1=g, parms(.38) exponential coefficient = sum-of-squared residuals = root mean squared error = tsline sm1 g, legend(lab (1 "G") lab(2 "Ghat")) title(alpha=0.38) lpattern(solid dash) 332. scalar f1 =.38*g[98]+(1-.38)*sm1[98] 333. scalar list f1 f1 = list sm1 in sm tssmooth exponential sm2=g, parms(.8) exponential coefficient = sum-of-squared residuals = root mean squared error = tsline sm2 g, legend(lab (1 "G") lab(2 "Ghat")) title(alpha=0.8) lpattern(solid dash) 338. scalar f2 =.8*g[98]+(1-.8)*sm2[98]

28 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page scalar list f2 f2 = tssmooth exponential sm3=g computing optimal exponential coefficient (0,1) optimal exponential coefficient = sum-of-squared residuals = root mean squared error = scalar f3 = r(alpha)*g[98]+(1-r(alpha))*sm3[98] 343. scalar list f3 f3 = list sm3 in sm program drop modelsel 347. drop sm1 sm2 sm * appendix 350. * Durbin Watson test 351. use "C:\data\poe4stata\phillips_aus.dta", clear 352. generate date = tq(1987q1) + _n format %tq date 354. tsset date time variable: date, 1987q1 to 2009q3 delta: 1 quarter regress inf D.u Source SS df MS Number of obs = F( 1, 88) = 5.29 Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons

29 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page estat dwatson Durbin-Watson d-statistic( 2, 90) = * Prais-Winsten FGLS estimator 360. prais inf D.u, twostep Iteration 0: rho = Iteration 1: rho = Prais-Winsten AR(1) regression -- twostep estimates Source SS df MS Number of obs = F( 1, 88) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons rho Durbin-Watson statistic (original) Durbin-Watson statistic (transformed) estimates store _2step 362. prais inf D.u Iteration 0: rho = Iteration 1: rho = Iteration 2: rho = Iteration 3: rho = Iteration 4: rho = Iteration 5: rho = Prais-Winsten AR(1) regression -- iterated estimates Source SS df MS Number of obs = F( 1, 88) = Model Prob > F = Residual R-squared = Adj R-squared = Total Root MSE = inf Coef. Std. Err. t P>t [95% Conf. Interval] u D _cons rho Durbin-Watson statistic (original) Durbin-Watson statistic (transformed)

30 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page estimates store Iterate 364. esttab _2step Iterate, compress se(%12.3f) b(%12.5f) gaps scalars(rss rho) /// > mtitle("2-step" "Iterated") title("dependent Variable: inf") Dependent Variable: inf (1) (2) 2-step Iterated D.u ** ** (0.243) (0.243) _cons *** *** (0.120) (0.122) N rss rho Standard errors in parentheses * p<0.05, ** p<0.01, *** p< * AR(1) using arima 367. arima inf D.u, ar(1) (setting optimization to BHHH) Iteration 0: log likelihood = Iteration 1: log likelihood = Iteration 2: log likelihood = Iteration 3: log likelihood = Iteration 4: log likelihood = (switching optimization to BFGS) Iteration 5: log likelihood = Iteration 6: log likelihood = Iteration 7: log likelihood = Iteration 8: log likelihood = Iteration 9: log likelihood = Iteration 10: log likelihood = ARIMA regression Sample: 1987q2-2009q3 Number of obs = 90 Wald chi2(2) = Log likelihood = Prob > chi2 = OPG inf Coef. Std. Err. z P>z [95% Conf. Interval] inf u D _cons ARMA ar L /sigma Note: The test of the variance against zero is one sided, and the two-sided confidence interval is truncated at zero.

31 Series de Tiempo FE-UNAM Thursday September 20 14:47: Page log close name: <unnamed> log: C:\data\poe4stata\chap09.log log type: text closed on: 20 Sep 2012, 14:30: