------------------------------------------------------------------------------- log: d:\bill\fall2008\econ30331\daily_mortality.log log type: text opened on: 31 Oct 2008, 13:44:10 . . * generate a stata date (linear date integer) . gen date=mdy(month,day,year) . . * define the data as a time series data set . tsset date time variable: date, 4749 to 16801 delta: 1 unit . . . * get log of counts . gen lcounts=ln(counts) . . * construct month and weekday dummy variables . xi i.month i.weekday i.month _Imonth_1-12 (naturally coded; _Imonth_1 omitted) i.weekday _Iweekday_1-7 (naturally coded; _Iweekday_1 omitted) . . . * construct variable for the 1st week of the month . gen firstweek=(day>=1&day<=7) . gen sept911=(month==9&day==11&year==2001) . . . * construct a monthly trend that equals . * 1 in jan of 1973, 2 in feb, etc . gen trend=month+12*(year-1973) . . * run a regression, controll for . * time trend, month and weekday . * effects and first of the week . * the phrase _I* will include . * all variables with an _I prefix to . * the variable name . reg lcounts trend sept911 firstweek _I* Source | SS df MS Number of obs = 12053 -------------+------------------------------ F( 20, 12032) = 4084.99 Model | 127.396712 20 6.36983559 Prob > F = 0.0000 Residual | 18.7618363 12032 .001559328 R-squared = 0.8716 -------------+------------------------------ Adj R-squared = 0.8714 Total | 146.158548 12052 .012127327 Root MSE = .03949 ------------------------------------------------------------------------------ lcounts | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- trend | .0007336 3.15e-06 233.04 0.000 .0007275 .0007398 sept911 | .3857986 .0395213 9.76 0.000 .3083306 .4632667 firstweek | .0052759 .0008548 6.17 0.000 .0036003 .0069515 _Imonth_2 | -.0260462 .0017882 -14.57 0.000 -.0295514 -.022541 _Imonth_3 | -.0638372 .001746 -36.56 0.000 -.0672597 -.0604147 _Imonth_4 | -.1095693 .0017605 -62.24 0.000 -.1130203 -.1061184 _Imonth_5 | -.1436982 .0017461 -82.30 0.000 -.1471208 -.1402757 _Imonth_6 | -.1614265 .0017606 -91.69 0.000 -.1648776 -.1579755 _Imonth_7 | -.1696161 .0017461 -97.14 0.000 -.1730388 -.1661935 _Imonth_8 | -.1853686 .0017461 -106.16 0.000 -.1887913 -.1819459 _Imonth_9 | -.175732 .0017611 -99.78 0.000 -.1791841 -.1722799 _Imonth_10 | -.1354203 .0017462 -77.55 0.000 -.1388432 -.1319974 _Imonth_11 | -.11388 .0017608 -64.68 0.000 -.1173314 -.1104286 _Imonth_12 | -.0493627 .0017464 -28.27 0.000 -.0527859 -.0459396 _Iweekday_2 | .0113788 .001346 8.45 0.000 .0087405 .0140171 _Iweekday_3 | .0003784 .0013462 0.28 0.779 -.0022602 .0030171 _Iweekday_4 | -.0038243 .001346 -2.84 0.005 -.0064625 -.001186 _Iweekday_5 | -.0034567 .001346 -2.57 0.010 -.0060949 -.0008184 _Iweekday_6 | .010537 .001346 7.83 0.000 .0078987 .0131753 _Iweekday_7 | .0225822 .001346 16.78 0.000 .0199439 .0252205 _cons | 8.641988 .001646 5250.26 0.000 8.638761 8.645214 ------------------------------------------------------------------------------ . . * get durban watson . estat dwatson Durbin-Watson d-statistic( 21, 12053) = .3482972 . . * output residuals . predict r, residual . . * get 14 lags of residuals . gen r1=r[_n-1] (1 missing value generated) . gen r2=r[_n-2] (2 missing values generated) . gen r3=r[_n-3] (3 missing values generated) . gen r4=r[_n-4] (4 missing values generated) . gen r5=r[_n-5] (5 missing values generated) . gen r6=r[_n-6] (6 missing values generated) . gen r7=r[_n-7] (7 missing values generated) . gen r8=r[_n-8] (8 missing values generated) . gen r9=r[_n-9] (9 missing values generated) . gen r10=r[_n-10] (10 missing values generated) . gen r11=r[_n-11] (11 missing values generated) . gen r12=r[_n-12] (12 missing values generated) . gen r13=r[_n-13] (13 missing values generated) . gen r14=r[_n-14] (14 missing values generated) . . * run regression of r on r1-r14 . reg r r1-r14 Source | SS df MS Number of obs = 12039 -------------+------------------------------ F( 14, 12024) = 2148.53 Model | 13.3417719 14 .952983704 Prob > F = 0.0000 Residual | 5.33326243 12024 .000443551 R-squared = 0.7144 -------------+------------------------------ Adj R-squared = 0.7141 Total | 18.6750343 12038 .00155134 Root MSE = .02106 ------------------------------------------------------------------------------ r | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- r1 | .5558818 .0091176 60.97 0.000 .5380098 .5737537 r2 | .122347 .0104304 11.73 0.000 .1019017 .1427924 r3 | .0574915 .0104899 5.48 0.000 .0369295 .0780534 r4 | .0494838 .0105002 4.71 0.000 .0289018 .0700658 r5 | .0364724 .0105087 3.47 0.001 .0158736 .0570712 r6 | .0343425 .0105134 3.27 0.001 .0137345 .0549506 r7 | .0614028 .0105165 5.84 0.000 .0407888 .0820168 r8 | -.0119662 .0105145 -1.14 0.255 -.0325764 .008644 r9 | -.0058983 .0105105 -0.56 0.575 -.0265005 .014704 r10 | .0154364 .0105056 1.47 0.142 -.0051563 .0360291 r11 | -.0269658 .0104969 -2.57 0.010 -.0475414 -.0063903 r12 | -.0009346 .0104865 -0.09 0.929 -.02149 .0196207 r13 | .0207079 .0104269 1.99 0.047 .0002694 .0411464 r14 | .0150039 .0091134 1.65 0.100 -.0028598 .0328675 _cons | -.0000257 .0001919 -0.13 0.894 -.0004019 .0003506 ------------------------------------------------------------------------------ . . . . end of do-file . log close log: d:\bill\fall2008\econ30331\daily_mortality.log log type: text closed on: 31 Oct 2008, 13:48:09 -------------------------------------------------------------------------------