1. Trang chủ
  2. » Thể loại khác

VAR MODEL WITH STATA

13 30 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 13
Dung lượng 211,16 KB
File đính kèm 125. VAR M.rar (121 KB)

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Taking a look at quarterly defense spending and real GDP from 1947 to 2008 shows us a non-stationary time series having a trend already.. This implies following testing strategy and imag

Trang 1

VAR-models in Stata

Anton Parlow Lab session Econ710 UWM Econ Department

03/12/2010

Trang 2

Our plan

Introduction to VAR

How to import data into Stata

Unit root tests

First differencing a time series

VAR-estimation

VAR and optimal lag length

VAR again

VAR stability

VAR forecasting

Exercises

Trang 3

Introduction to VAR models

A vector-autoregressive (VAR) model is a multi-variate way of modeling time series Imagine you have two series and want to explain these two with own past realizations and past

realizations of the other series

e.g GDP and defense spending help explaining each others current values

Let a simple bivariate VAR(2)-process be the following (meaning two series and two lags of the regressive terms)

yt= c1+ φ11yt−1+ φ12yt−2+ φ13dst−1+ φ14dst−2+ 1t

dt = c2+ φ21dst−1+ φ22dst−2+ φ23yt−1+ φ24yt−2+ 2t

where yt = log of real GDP and dst = log of defense spending

In general a VAR(p)-process would be:

yt= c + φ1yt−1+ φ2yt−2 φpyt−p+ t where t∼ iid N(0, Σ)

where p is the lag length, c a vector of constants, Σ the variance-covariance matrix of the error term and yt a vector containing the different time series

Trang 4

Introduction to VAR models continued

To estimate a VAR-model properly, we need stationary data Taking a look at quarterly defense spending and real GDP from 1947 to 2008 shows us a non-stationary time series having a trend already

As usual a series of unit-root test will help us confirming it but first let us import some data

Trang 5

Importing data into Stata

Imagine someone gives you a txt-file containing defense spending and another txt-file containing real GDP

The easiest way is copying both files to Excel to have it in one file Use the first row for the names of the variables

Then save it as csv and let it be comma-separated

Go to Stata:

1 File → Import → Ascii Data created by a spreadsheet → browse for the csv-file on your computer

2 Ignore the options and let Stata determine which format (automatically determine delimiter, works most of the time) and click okay

3 You should see 2 new variables and have a data-set in the data-browser

4 Save it as var.dta

5 start a log-file: File → Log → Begin → save it as log

Trang 6

Unit root tests

We know the Dickey Fuller test is sensible to different options, as well the Philips Perron test and of course the proper lag length has to be chosen!

Furthermore for a VAR-model both series have to be stationary.

This implies following testing strategy and imagine Schwert’s rule of thumb tells you 15 lags have to be included:

dfuller lds, lags(15)

dfuller lds, lags(15) noconstant

dfuller lds, lags(15) trend

for defense spendings and for real GDP

dfuller lrgdp, lags(15)

dfuller lrgdp, lags(15) noconstant

dfuller lrgdp, lags(15) trend

and similarly you can do the same 6 tests for the Philips Perron test

pperron lrgdp, lags(15)

and so on

If we are lucky most of them tell us, these two series are non-stationary And we get a very nice table for a term paper Now imagine you split the sample e.g Cold war vs entire period because then you have to the tests again (and another table!)

Trang 7

First differencing a time series

To generate a first differenced version of defense spending and real GDP, do the following: gen flds=D.lds

gen flrgp=D.lrgdp

and save the data-set

Now it’s time for a VAR-estimation We will use the standard command without any options and determine the lag-length after the estimation

Trang 8

Var estimation

The command is

var variable1 variable2

in our example it will be

var flrgdp flds

and Stata assume two lags without any option Now we can determine the optimal lag-length using information criteria like AIC, BIC and SIC Stata will do it for us

You can find the output attached! You should care about the significance of the lags explaining your dependent variables Remember Stata use L for lag e.g flrgdpL1 is the first lag of real GDP

We will use varsoc for determining the lag-length

Trang 9

Var and optimal lag-length

After estimating the bivariate VAR(2) we can use following command for figuring out the optimal lag-length Let us include 10 lags for testing it

varsoc, lags(10)

See output Maybe 2 or 5 lags The stars tell us what lag-length is picked by the criteria

If we do the same test for 5 lags

varsoc, lags(5)

Most of the stars point at 5 lags for our VAR-model Note: Information criteria have to be minimized, that’s the reason why you see the stars at certain values

Trang 10

Var-estimation continued

We will estimate the bivariate VAR for 5 lags (suggested by lag-length criteria)

var flrgdp flds, lag(1 2 3 4 5)

or

var flrgdp flds, lag(1/5)

A very nice table including 5 lags for each variable e.g defense spending are explained by past realizations of defense spendings and real GDP and real GDP is explained by past realizations of real GDP and defense spendings

Look at the significance and the sign of the lags It’s more important than the actual magnitude (doesn’t tell too much in a VAR) Because the story is more about the lag and the sign but not the magnitude Or we just describe these two series The magnitudes would get more meaning

in a structural VAR

Trang 11

VAR stability

For a stable VAR-model we want to eigenvalues to be less than one This can be tested after the estimation using following command:

varstable

gives you a table with the eigenvalues for the estimated VAR All lie inside the unit circle and that’s good

If you use the option varstable, graph you get graph of the unit circle additional to the output table

What else could be done We could test for remaining autocorrelation in the error-terms (there should be none) but most of the time nobody is really doing this anymore I guess it’s not too big of a problem So let us do a simple dynamic out of sample forecast (apparently the only one built in in Stata 10 ) Eviews is still more flexible and powerful in forecasting than Stata

Trang 12

VAR forecasting

Stata uses two commands for forecasting after a VAR, SVAR and ECM estimation

First you need to compute the forecast:

fcast compute m1_, step(24)

fcast compute is the command, m1_ gives a suffix to the auxiliary estimations for defense spending and real GDP You will find the forecast for defense spending as a new variable m1_flds for example step(24) is an option telling Stata to forecast 24 quarters out of sample Second you can graph the dynamic forecast for defense spending and real GDP using

fcast graph

e.g

fcast graph m1_flrgdp m1_flds

and you get kind of nice forecast graphs

Trang 13

Do the same as above but for different sub samples We did it for the entire period 1947 to

2008 Try the Cold war period from 1947 to 1991

Just use the command for specifying the time span:

var flrgdp flds tin(1947q1,1991q4)

for the VAR-system without any lags

And one example of a unit-root test:

dfuller lrgdp if tin(1947q1,1991q4)

Very nice command tin

Ngày đăng: 02/09/2021, 21:15

TỪ KHÓA LIÊN QUAN