* open data use daily_mortality * open log file log using daily_mortality.log, replace * generate a stata date (linear date integer) gen date=mdy(month,day,year) * define the data as a time series data set tsset date * get log of counts gen lcounts=ln(counts) * construct month and weekday dummy variables xi i.month i.weekday * 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* * get durban watson estat dwatson * output residuals predict r, residual * get 14 lags of residuals gen r1=r[_n-1] gen r2=r[_n-2] gen r3=r[_n-3] gen r4=r[_n-4] gen r5=r[_n-5] gen r6=r[_n-6] gen r7=r[_n-7] gen r8=r[_n-8] gen r9=r[_n-9] gen r10=r[_n-10] gen r11=r[_n-11] gen r12=r[_n-12] gen r13=r[_n-13] gen r14=r[_n-14] * run regression of r on r1-r14 reg r r1-r14 log close