******** Technical Tip 1 ******** ** Example –Daily format clear input str12 date "1/01/2008" "1/02/2008" "1/03/2008" "1/04/2008" "1/05/2008" end generate mydate1=date(date,"DMY") format mydate1 %td generate mydate2=date(date,"DMY") format mydate2 %tdmon-DD,_CCYY list tsset mydate1 list mydate1 if tin(01feb2008,01apr2008) ** Example –Clock format clear input str20 etime y "06feb2010 12:40:00" 2 "06feb2010 12:42:00" 5 "06feb2010 12:44:00" 7 "06feb2010 12:46:00" 6 "06feb2010 12:48:00" 9 end generate double mytime = clock(etime, "DMY hms") format mytime %tc DMYHH:MM:SS tsset mytime,delta(2 minute) generate my_ly=l.y list mytime y my_ly ******* Technical Tip 2 ******** ** Example 1 ** use http://www.stata-press.com/data/r11/lutkepohl,clear arima dlinvestment, ma(1) predict double yhat scalar b0 = _b[_cons] scalar t1 = [ARMA]_b[L1.ma] gen double my_yhat = b0 gen double myehat = dlinvestment -b0 in 2 forvalues i = 3/91 { qui replace my_yhat = my_yhat /// + t1*L.myehat in `i' qui replace myehat = dlinvestment -my_yhat in `i' } list qtr yhat my_yhat in 1/13,sep(11) ** Example 2 ** use http://www.stata-press.com/data/r11/lutkepohl,clear arima dlinvestment, ma(1) predict double yhat ** Coefficient estimates and sigma^2 from ereturn list ** scalar b0 = _b[_cons] scalar t1 = [ARMA]_b[L1.ma] scalar sigma2 = e(sigma)^2 ** pt and shrinking factor for the first two observations** gen double pt=sigma2 in 1/2 gen double myratio=(sigma2)/(sigma2+t1^2*pt) in 2 ** Predicted series and errors for the first two observations ** gen double my_yhat = b0 generate double myehat = myratio*(dlinvestment - my_yhat) in 2 ** Predictions with the Kalman filter recursions ** quietly { forvalues i = 3/91 { replace my_yhat = my_yhat + t1*l.myehat in `i' replace pt= (sigma2)*(t1^2)*(L.pt)/(sigma2+t1^2*L.pt) in `i' replace myratio=(sigma2)/(sigma2+t1^2*pt) in `i' replace myehat=myratio*(dlinvestment - my_yhat) in `i' } } list qtr yhat my_yhat pt myratio in 1/10 ******* Technical Tip 3 ******** use http://www.stata-press.com/data/r11/lutkepohl,clear var dlinvestment dlincome, lags(1/2) dfk irf create order1, step(10) set(myirf1,replace) irf graph oirf, impulse(dlinvestment) /// response(dlinvestment dlincome) irf table oirf, irf(order1) impulse(dlinvestment) /// response(dlincome dlinvestment) irf table irf, irf(order1) impulse(dlinvestment) /// response(dlincome dlinvestment) ******* Technical Tip 4 ******** ** Example 1 (Linear regression) ** use http://www.stata-press.com/data/r11/lutkepohl,clear constraint 1 [z]L.z = 0 constraint 2 [dlinvestment]z = 1 sspace (z L.z, state noconstant) /// (dlinvestment dlincome z,noerror ), /// constraints(1/2) nolog ** Example 2 (Random Walk) ** use http://www.stata-press.com/data/r11/lutkepohl,clear constraint 1 [z]L.z = 1 constraint 2 [dlinvestment]z = 1 sspace (z L.z, state noconstant) /// (dlinvestment z,noerror noconstant), /// constraints(1/2) nolog ******* Technical Tip 5 ******** ** Example 1 (Unrestricted VEC) use http://www.stata-press.com/data/r11/lutkepohl,clear vec linvestment lincome lconsumption, /// rank(2) lags(2) noetable trend(none) ** Example 1 (Restricted VEC) use http://www.stata-press.com/data/r11/lutkepohl,clear constraint define 1 [_ce1]linvestment=1 constraint define 2 [_ce1]lincome=-.75 constraint define 3 [_ce2]lconsumption=1 constraint define 4 [_ce2]lincome=-.85 vec linvestment lincome lconsumption, /// rank(2) lags(2) noetable trend(none) /// bconstraints(1/4)