ECO 341: Autoregression Stata Code

/*Typing Between Stars makes it a Comment*/

/*Delimit Command Tells Stata that Each Command ends with a Semicolon*/

# delimit ;

/*Set more off tells Stata to Print All Output at Once*/

set more off;
clear;

/*Referencing Dataset*/

use C:\Users\pshea\dailystocks.dta ;

/*Telling Stata to Overwrite log file*/

log using C:\Users\pshea\dailystocks.log,replace;

/*Telling Stata which is the time series indicator*/

tsset time;

/*Unit root tests for S&P 500 and Federal Funds Rate*/

dfgls lnstock;

dfuller lnstock, lag(2) trend;

gen d1stock=lnstock-lnstock[_n-1];

dfgls d1stock;

dfuller d1stock, lag(1) trend;

dfgls ffr;

dfuller ffr, lag(30) trend;

gen d1ffr=ffr-ffr[_n-1];

dfgls d1ffr;

dfuller d1ffr, lag(30) trend;

/*Running an AR(1) for stock prices*/

var d1stock, lag(1);

fcast compute for, step(20) bs;

fcast graph ford1stock;

/*Running an AR(p)*/

varsoc d1stock;

var d1stock, lag(1,2);

fcast compute for2, step(20) bs;

fcast graph for2d1stock;

/*Running an ADL model*/

gen d1stock_lag1=d1stock[_n-1];

gen d1stock_lag2=d1stock[_n-2];

gen d1ffr_lag1=d1ffr[_n-1];

reg d1stock d1stock_lag1 d1stock_lag2 d1ffr_lag1, robust;

estat ic;

reg d1stock d1stock_lag1 d1stock_lag2, robust;

estat ic;