log: d:\courses\ps552\stata do files\Timeseries.log log type: text opened on: 21 Apr 2004, 12:22:47 . . ********************************************************* . * . * Time series example using Presidential Support in . * Congress by own party senators, and unemployment . * . * Bert Kritzer . * April 21, 2004 . * . ********************************************************* . . drop _all . use "D:\COURSES\PS552\EXAMPLES\time series (pressupp).dta",clear . . * set up own and opposing variables . gen ownhouse=houser if prespart==1 (14 missing values generated) . replace ownhouse=housed if prespart==0 (14 real changes made) . gen opphouse=housed if prespart==1 (14 missing values generated) . replace opphouse=houser if prespart==0 (14 real changes made) . gen ownsenat=senater if prespart==1 (14 missing values generated) . replace ownsenat=senated if prespart==0 (14 real changes made) . gen oppsenat=senated if prespart==1 (14 missing values generated) . replace oppsenat=senater if prespart==0 (14 real changes made) . . * tell Stata that this is time series data . tsset year, yearly time variable: year, 1953 to 1994 . . * do OLS and get Durbin-Watson . regress ownsenat avgunemp Source | SS df MS Number of obs = 42 -------------+------------------------------ F( 1, 40) = 10.00 Model | 532.878612 1 532.878612 Prob > F = 0.0030 Residual | 2130.95472 40 53.273868 R-squared = 0.2000 -------------+------------------------------ Adj R-squared = 0.1800 Total | 2663.83333 41 64.9715447 Root MSE = 7.2989 ------------------------------------------------------------------------------ ownsenat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- avgunemp | 2.32951 .736559 3.16 0.003 .8408687 3.818151 _cons | 54.00834 4.514028 11.96 0.000 44.88515 63.13153 ------------------------------------------------------------------------------ . dwstat Durbin-Watson d-statistic( 2, 42) = 1.081183 . . * do Cochran-Orcutt . prais ownsenat avgunemp, rhotype(regress) corc Iteration 0: rho = 0.0000 Iteration 1: rho = 0.4485 Iteration 2: rho = 0.4746 Iteration 3: rho = 0.4783 Iteration 4: rho = 0.4789 Iteration 5: rho = 0.4789 Iteration 6: rho = 0.4790 Iteration 7: rho = 0.4790 Iteration 8: rho = 0.4790 Cochrane-Orcutt AR(1) regression -- iterated estimates Source | SS df MS Number of obs = 41 -------------+------------------------------ F( 1, 39) = 3.24 Model | 141.409309 1 141.409309 Prob > F = 0.0794 Residual | 1700.21246 39 43.5951912 R-squared = 0.0768 -------------+------------------------------ Adj R-squared = 0.0531 Total | 1841.62177 40 46.0405442 Root MSE = 6.6027 ------------------------------------------------------------------------------ ownsenat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- avgunemp | 1.754534 .9741863 1.80 0.079 -.215944 3.725011 _cons | 57.57041 6.244292 9.22 0.000 44.94014 70.20068 -------------+---------------------------------------------------------------- rho | .4789546 ------------------------------------------------------------------------------ Durbin-Watson statistic (original) 1.081183 Durbin-Watson statistic (transformed) 2.375654 . . * do Hildreth-Lu . prais ownsenat avgunemp, rhotype(regress) ssesearch Iteration 1: rho = 0.8944 , criterion = -2007.7804 Iteration 2: rho = 0.4842 , criterion = -1706.802 Iteration 3: rho = 0.4855 , criterion = -1706.7682 Iteration 4: rho = 0.4915 , criterion = -1706.6974 Iteration 5: rho = 0.4915 , criterion = -1706.6974 Iteration 6: rho = 0.4915 , criterion = -1706.6974 Iteration 7: rho = 0.4915 , criterion = -1706.6974 Iteration 8: rho = 0.4919 , criterion = -1706.6972 Iteration 9: rho = 0.4919 , criterion = -1706.6972 Iteration 10: rho = 0.4919 , criterion = -1706.6972 Iteration 11: rho = 0.4919 , criterion = -1706.6972 Iteration 12: rho = 0.4919 , criterion = -1706.6972 Iteration 13: rho = 0.4919 , criterion = -1706.6972 Iteration 14: rho = 0.4919 , criterion = -1706.6972 Prais-Winsten AR(1) regression -- SSE search estimates Source | SS df MS Number of obs = 42 -------------+------------------------------ F( 1, 40) = 14.89 Model | 635.131803 1 635.131803 Prob > F = 0.0004 Residual | 1706.69717 40 42.6674294 R-squared = 0.2712 -------------+------------------------------ Adj R-squared = 0.2530 Total | 2341.82898 41 57.1177799 Root MSE = 6.532 ------------------------------------------------------------------------------ ownsenat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- avgunemp | 1.586595 .9019016 1.76 0.086 -.2362159 3.409407 _cons | 58.78855 5.63999 10.42 0.000 47.38971 70.1874 -------------+---------------------------------------------------------------- rho | .4919125 ------------------------------------------------------------------------------ Durbin-Watson statistic (original) 1.081183 Durbin-Watson statistic (transformed) 2.391118 . . * create congress number . gen congress=int((year-1900+1)/2)+56 . . * add for clustering by congress . prais ownsenat avgunemp, rhotype(regress) corc cluster(congress) Iteration 0: rho = 0.0000 Iteration 1: rho = 0.4485 Iteration 2: rho = 0.4746 Iteration 3: rho = 0.4783 Iteration 4: rho = 0.4789 Iteration 5: rho = 0.4789 Iteration 6: rho = 0.4790 Iteration 7: rho = 0.4790 Iteration 8: rho = 0.4790 Cochrane-Orcutt AR(1) regression -- iterated estimates Regression with robust standard errors Number of obs = 41 F( 2, 20) = 722.09 Prob > F = 0.0000 R-squared = 0.0768 Number of clusters (congress) = 21 Root MSE = 6.6027 ------------------------------------------------------------------------------ | Semi-robust ownsenat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- avgunemp | 1.754534 .8751101 2.00 0.059 -.070914 3.579981 _cons | 57.57041 6.210519 9.27 0.000 44.61549 70.52532 -------------+---------------------------------------------------------------- rho | .4789546 ------------------------------------------------------------------------------ Durbin-Watson statistic (original) 1.081183 Durbin-Watson statistic (transformed) 2.375654 . . * do regression using time series variable name . regress ownsenat avgunemp l.ownsenat Source | SS df MS Number of obs = 41 -------------+------------------------------ F( 2, 38) = 12.03 Model | 1031.27272 2 515.636358 Prob > F = 0.0001 Residual | 1629.11753 38 42.8715139 R-squared = 0.3876 -------------+------------------------------ Adj R-squared = 0.3554 Total | 2660.39024 40 66.5097561 Root MSE = 6.5476 ------------------------------------------------------------------------------ ownsenat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- avgunemp | 1.555694 .751523 2.07 0.045 .034315 3.077073 ownsenat | L1 | .4740062 .1429303 3.32 0.002 .1846589 .7633534 _cons | 26.5416 9.00882 2.95 0.005 8.304198 44.779 ------------------------------------------------------------------------------ . . end of do-file . exit, clear