+1(505)531-9093

HOW TO STATA COMMAND FOR TIME SERIES ANALYSIS

STATA COMMAND FOR TIME SERIES ANALYSIS

How to set time series data:

tsset  year, yearly

How to fill missing data for Time Series analysis:

ipolate x time, gen(xi) epolate

How to check unit root using Augmented Dikker Fuller test (ADF):

ADF unit root test using constant

dfuller  x

ADF test for constant and trend:

dfuller x, trend

When a variable has unit root, we take difference as follows:

dfuller d.x

ADF test after differencing for constant and trend:

dfuller d.x, trend

If you want to have summary statistics:

sum y x1 x2 x3 x4

How to run correlation matrix for your data:

correlate  y x1 x2 x3 x4

Stuck with Your Project? Let us Help You Right Now - Quality is a Guarantee Data Analysis & Results Interpratation for your Thesis or Dissertation

We are Experts in SPSS, EVIEWS, AMOS, STATA, R, and Python

STATA COMMAND FOR TIME SERIES ANALYSIS

Command for running regression model:

regress y x1 x2 x3 x4

If you want to check normality after running regression model, run two commands consecutively:

predict myResiduals, r

sktest myResiduals

After regression, you can check for serial correlation using either of the following:

dwstat    or     estat bgodfrey

Use the following command for heteroskedasticity test :

Prob value below 10% means there is heteroskedasticity problem in the model

estat hottest

STATA COMMAND FOR TIME SERIES ANALYSIS

If you want to see whether the model is mis-specified or if some variables are omitted:

estat ovtest

Command for selecting optimum lags for your model is given below:

varsoc y x1 x2 x3 x4, maxlag(4)

the asterisk (*) indicates the appropriate lag selected

Command for testing co-integration:

vecrank y x1 x2 x3 x4, trend(constant)

When co-integration is established, run VECM otherwise unrestricted VAR model is appropriate.

Assuming variables are co-integrated, we run VECM using the following command:

vec y x1 x2 x3 x4, trend(contant)

The long-run causality must be negative, significant and in between 0 to 1, representing error correction term or speed of adjustment.

Command to run impulse response function (you must estimate VECM or VAR model before running it) as follows:

First you use the following command to create file:

irf create order1, step(10) set(myirf1)

Command for impulse response of all independent variables on dependent variable:

irf graph irf, irf(order1) impulse(y x1 x2 x3 x4) response(smd)

Assuming there is no co-integration, you run VAR model as a replacement for VECM as follows: (Note VAR model is for short run effect only)

var y x1 x2 x3 x4, lags(1/4)

If you want to check how variables jointly affect the dependent variables, use Granger causality test as follows:

vargranger

Diagnostic checking for VAR model: Run the following tests:

Lagrange multiplier test to check if residuals are auto-correlated or not (whether model is well-specified):

varlmar

Jarque-Bera test to check whether residuals are normally distributed or not:

varnorm, jbera

jbera stands for Jarque-Bera

Prob value below 10% shows residuals are not normally distributed

Time Series Autoregressive Distributed Lag (ARDL) Model:

ardl y x1 x2 x3 x4, lag(2 1 1 1 1) ec

The value must be negative, significant and in between 0 to 1, representing error correction term or speed of adjustment

To confirm existence of long-run relationship, we run bound test as follows:

estat btest

btest stand for bound test

The long-run cointegration is possible if the F statistics value is above the critical value.

Command for Zivot-Andrews unit root test (structural break):

zandrews  x

zandrews  d.x

Gregory-Hansen Cointegration test

Command for g-hansen test with change in level:

ghansen y x1 x2 x3 x4, break(level) lagmethod(aic) maxlags(4)

Command for g-hansen test under regime change;

ghansen y x1 x2 x3 x4, break(regime) lagmethod(fixed) maxlags(4)

Command for g-hansen test with change in regime and trend:

ghansen y x1 x2 x3 x4, break(regimetrend) lagmethod(downt) level(0.99) trim(0.1)

Command for Non-linear Autoregressive Distributed Lag (NARDL) for frequency data

nardl y x1 x2 x3 x4, p(2) q(4) constraints (1/2) plot bootstrapt (500) level (95)

p(2) stands for lags of dependent variable, q(4) lags for explanatory variables

Command for non-linear Autoregressive Distributed Lag (NARDL) for fewer observations

nardl y x1 x2 x3 x4

The results include positive and negative coefficients otherwise asymmetric effect

Steps for running Toda and Yamamoto Granger-non causality test

After testing for unitroot

Estimate var model to select appropriate lag as follows

var y x1 x2 x3 x4, lags(1/4)

varsoc

Assuming lag 3 is selected for the model, then run var model to include exogenous variables:

var y x1 x2 x3 x4, lags(1/2) exog(13.y 13.x1 13.x2 13.x3 13.x4)

Then run Toda Yamamoto causality test as follows:

vargranger

 

STATA COMMAND FOR TIME SERIES ANALYSIS

Data Analytics Services
Need Our Services?
Econometrics & Statistics Modelling Services
Need Help, Whatsapp Us Now