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

Cấu trúc

  • Introduction to VAR

  • Importing data into Stata

  • Unit root tests

  • First differencing

  • Var estimation

    • Introduction

    • Optimal lag length

    • VAR estimation continued

    • Stability

    • Forecasting

  • Exercises

Nội dung

VAR-models in Stata Anton Parlow Lab session Econ710 UWM Econ Department 03/12/2010 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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 + φ11 yt−1 + φ12 yt−2 + φ13 dst−1 + φ14 dst−2 + 1t dt = c2 + φ21 dst−1 + φ22 dst−2 + φ23 yt−1 + φ24 yt−2 + 2t where yt = log of real GDP and dst = log of defense spending In general a VAR(p)-process would be: yt = c + φ1 yt−1 + φ2 yt−2 φp yt−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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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: File → Import → Ascii Data created by a spreadsheet → browse for the csv-file on your computer Ignore the options and let Stata determine which format (automatically determine delimiter, works most of the time) and click okay You should see new variables and have a data-set in the data-browser Save it as var.dta start a log-file: File → Log → Begin → save it as log Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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 the same 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!) Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 First differencing a time series To generate a first differenced version of defense spending and real GDP, 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 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 or lags The stars tell us what lag-length is picked by the criteria If we the same test for lags varsoc, lags(5) Most of the stars point at lags for our VAR-model Note: Information criteria have to be minimized, that’s the reason why you see the stars at certain values Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 / 13 Var-estimation continued We will estimate the bivariate VAR for lags (suggested by lag-length criteria) var flrgdp flds, lag(1 5) or var flrgdp flds, lag(1/5) A very nice table including 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 10 / 13 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 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 11 / 13 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 12 / 13 Exercises 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 Anton Parlow Lab session Econ710 UWM Econ Department VAR-models () in Stata 03/12/2010 13 / 13 ... session Econ710 UWM Econ Department VAR- models () in Stata 03/12/2010 / 13 Introduction to VAR models A vector-autoregressive (VAR) model is a multi-variate way of modeling time series Imagine you... 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... Anton Parlow Lab session Econ710 UWM Econ Department VAR- models () in Stata 03/12/2010 / 13 Introduction to VAR models continued To estimate a VAR- model properly, we need stationary data Taking a

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

TỪ KHÓA LIÊN QUAN