{smcl} {* 24feb2001}{...} {hline} help for {hi:vecar}{right:(StataList distribution 04 March 2001)} {hline} {title:Vector autoregression} {p 8 14}{cmd:vecar} {it:depvarlist} {cmd:=} {it:varlist} [{cmd:if} {it:exp}] [{cmd:in} {it:range}] {cmd:,maxlag({it:#})} [ {cmdab:noc:onstant} {cmdab:e:xog}({it:varlist}) {cmdab:cov:} {cmdab:dfk:} {cmdab:noh:eader} {cmdab:t:able} {cmdab:l:evel}{cmd:(}{it:#}{cmd:)} ] {p}{cmd:vecar} is for use with time-series data. You must {cmd:tsset} your data before using {cmd:vecar}; see help {help tsset}. {p}{cmd:by} {it:...} {cmd::} may be used with {cmd:vecar}; see help {help by}. {p}{cmd:vecar} shares the features of all estimation commands; see help {help est}. {p}The syntax of {help predict} after {cmd:vecar} is {p 8 16}{cmd:predict} [{it:type}] {it:newvarname} [{cmd:if} {it:exp}] [{cmd:in} {it:range}] [{cmd:,} {cmdab:eq:uation}{cmd:(}{it:eqno}[{cmd:,}{it:eqno}]{cmd:)} {c -(} {cmd:xb} | {cmd:stdp} | {cmdab:r:esiduals} | {cmdab:d:ifference} | {cmdab:stdd:p} {c )-}] {p}These statistics are available both in and out of sample; type "{cmd:predict} {it:...} {cmd:if e(sample)} {it:...}" if wanted only for the estimation sample. {title:Description} {p}{cmd:vecar} estimates vector autoregression (VAR) models. Each of the variables in {it:depvarlist} is regressed on {it:maxlag} lags of {it:depvarlist}, a constant (unless suppressed) and the exogenous variables provided in {it:varlist} (if any). {it:varlist} may contain time-series operators. {p}A set of "block F" tests evaluates the joint significance of each variable's lagged values in each equation. The log determinant of the residual covariance matrix is calculated for use with {cmd:lrtest}, most commonly to test the appropriateness of a model with a smaller {it:maxlag}. {p} {title:Options} {p 0 4}{cmd:noconstant} omits the constant term from estimation. {p 0 4}{cmd:exog(}{it:varlist}{cmd:)} specifies the exogenous variables to be included in each equation. {p 0 4}{cmd:cov} displays the covariance matrix of the residuals between equations. The divisor of the covariance terms is T, the number of sample observations, unless the dfk option is invoked. The cov option also causes three tests on the residuals to be performed: the multivariate portmanteau test of Ljung and Box, implemented in {cmd:wntstmvq} (STB-60), the test for independence of the errors of Breusch and Pagan, implemented in {cmd:mvreg}, and the Doornik-Hansen omnibus test for multivariate normality, implemented in {cmd:omninorm}. {p 0 4}{cmd:dfk} specifies the use of an alternate divisor in computing the covariance matrix for the equation errors. As an asymptotically justified estimator, {cmd:vecar} by default uses the number of sample observations (T) as a divisor. When the dfk option is set, a small-sample adjustment is made and the divisor is taken to be sqrt(T - k). {p 0 4}{cmd:noheader} suppresses display of the table reporting F statistics, R-squared, and root mean square error above the coefficient table. {p 0}{cmd:table} displays the full coefficient table. {p 0 4}{cmd:dfk} specifies the use of an alternate divisor in computing the covariance matrix for the equation errors. As an asymptotically justified estimator, vecar by default uses the number of sample observations (T) as a divisor. When the dfk option is set, a small-sample adjustment is made and the divisor is taken to be sqrt(T - k). {p 0 4}{cmd:level(}{it:#}{cmd:)} specifies the confidence level, in percent, for confidence intervals; see help {help level}. {title:Options for {help predict}} {p 0 4}{cmd:equation(}{it:eqno}[{cmd:,}{it:eqno}]{cmd:)} specifies to which equation you are referring. {p 4 4}{cmd:equation()} is filled in with one {it:eqno} for options {cmd:xb}, {cmd:stdp}, and {cmd:residuals}. {cmd:equation(#1)} would mean the calculation is to be made for the first equation, {cmd:equation(#2)} would mean the second, and so on. Alternatively, you could refer to the equations by their names. {cmd:equation(income)} would refer to the equation named income and {cmd:equation(hours)} to the equation named hours. {p 4 4}If you do not specify {cmd:equation()}, results are as if you specified {cmd:equation(#1)}. {p 4 4}{cmd:stddp} and {cmd:difference} refer to between-equation concepts. To use these options, you must specify {cmd:equation(#1,#2)} or {cmd:equation(income,hours)}. When two equations must be specified, {cmd:equation()} is not optional. {p 0 4}{cmd:xb}, the default, calculates the linear prediction from the estimated model. {p 0 4}{cmd:stdp} calculates the standard error of the linear prediction. {p 0 4}{cmd:residuals} calculates the residuals. {p 0 4}{cmd:difference} calculates the difference between the linear predictions of two equations in the system. {p 0 4}{cmd:stddp} calculates the standard error of the difference in linear predictions between two equations. {title:Example} {p 8 12}{inp:.} {stata "use http://fmwww.bc.edu/ec-p/data/Greene2000/TBL15-1,clear":use http://fmwww.bc.edu/ec-p/data/Greene2000/TBL15-1,clear} {p 8 12}{inp:. reshape wide i f c,i(year) j(firm)} {p 8 12}{inp:. tsset year,yearly} {p 8 12}{inp:. vecar i1 i2 i3 , maxlag(2)} {p 8 12}{inp:. vecar i1 i2 i3 , maxlag(2) table exog(year) cov} {p 8 12}{inp:. vecar i1 i2 i3 , maxlag(3) exog(L.c5 D.c4)} {p 8 12}{inp:. vecar i1 i2 i3 if year>1938, maxlag(3) exog(year) } {p}To then test that a VAR model with 2 lags is adequate : {p 8 12}{inp:. lrtest, saving(0)} {p 8 12}{inp:. vecar i1 i2 i3 if year>1938, maxlag(2) exog(year) } {p 8 12}{inp:. lrtest} {p 8 12}{inp:. vecar i1 i3 i5 , maxlag(2) exog(c1 c3 c5) } {p 8 12}{inp:. predict i2hat,eq(i2)} {p 8 12}{inp:. predict i2eps,resid eq(i2)} {p 8 12}{inp:. mat list e(Sigma)} {p}To estimate a VAR for each unit of a panel : {p 8 12}{inp:.} {stata "use http://fmwww.bc.edu/ec-p/data/Greene2000/TBL15-1,clear":use http://fmwww.bc.edu/ec-p/data/Greene2000/TBL15-1,clear} {p 8 12}{inp:. tsset firm year,yearly} {p 8 12}{inp:. by firm: vecar i f c, maxlag(2) exog(year) } {title:Acknowledgements} Thanks to Vince Wiggins for assistance modifying this code to interact properly with predict. Remaining errors are my own. {title:Author} Christopher F Baum, Boston College, USA, baum@bc.edu {title:Also see} {p 0 19}On-line: help for {help est}, {help reg3}, {help mvreg}, {help wntstmvq} (if installed), {help lrtest}, {help regress}, {help predict} {p_end}