{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: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:)} {cmdab:s:aving}({it:name})} {cmdab:u:sing}({it:name}) {cmd:uncorr}  ]

{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. 

{p}

{title:Options}

{p 0 4}{cmd:maxlag} must be specified, and must be at least 1.

{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. A comparison of this model with the zero-lag model (as a likelihood ratio test) is computed. Three criteria often employed for lag length selection are 
produced: the AIC (Akaike Information Criterion), BIC (Bayes or Schwarz Information Criterion) 
and the HQ (Hannan-Quinn) criterion. 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}. These tests make use of Stata's matrix language; it may be necessary
to use {cmd:set matsize} to increase the default matrix size before reading in the data.

{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:level(}{it:#}{cmd:)} specifies the confidence level, in percent, for confidence intervals; 
see help {help level}.

{p 0 4}{cmd:saving({it:name})} specifies that the log determinant of the residual covariance matrix associated with this model
    is to be saved as {it:name}.  
    
{p 0 4}{cmd:using({it:name})} specifies the name of the model against which this model is to be tested. The saved model should have a greater lag length, so that the likelihood ratio test compares the more general saved model with the restricted model currently estimated. 

{p 0 4}{cmd:uncorr} specifies that the likelihood ratio tests for lag length implemented by {cmd:saving} and {cmd:using}, as well as the test against the zero-order model implemented by {cmd:cov}, are to be conducted without the adjustment for degrees of freedom advocated by Sims (1980). Without this option, the difference between log determinants of the respective covariance matrices is scaled by (T-c), where T is the number of observations and c is the number of regressors in each of the unrestricted model's equations. With the {cmd:uncorr} option, the multiplier is merely T.


{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:Examples}

{p 8 12}{inp:.} {stata "use http://fmwww.bc.edu/ec-p/data/macro/wgmacro.dta,clear":use http://fmwww.bc.edu/ec-p/data/macro/wgmacro.dta,clear}

{p 8 12}{inp:. vecar  dlinvestment dlincome dlconsumption , maxlag(2)}

{p 8 12}{inp:. vecar  dlinvestment dlincome dlconsumption , maxlag(2) table exog(qtr) cov}

{p 8 12}{inp:. predict ihat,eq(dlinvestment)}

{p 8 12}{inp:. predict ieps,resid eq(dlinvestment)}

{p 8 12}{inp:. mat list e(Sigma)}

{p 8 12}{inp:. dis "Log-likelihood with `e(maxlag)' lags: `e(ll)'"}

{p 8 12}{inp:. vecar dlinvestment dlincome dlconsumption if tin(1965q1,), maxlag(3) exog(qtr) }

{p}To reproduce Lutkepohl, 1993, Table 4.4:

{p 8 12}{inp:. vecar dlinvestment dlincome dlconsumption if tin(1961q2,1978q4), maxlag(4) saving(4) uncorr}

{p 8 12}{inp:. vecar dlinvestment dlincome dlconsumption if tin(1961q2,1978q4), maxlag(3) using(4) saving(3) uncorr }

{p 8 12}{inp:. vecar dlinvestment dlincome dlconsumption if tin(1961q2,1978q4), maxlag(2) using(3) saving(2) uncorr }

{p 8 12}{inp:. vecar dlinvestment dlincome dlconsumption if tin(1961q2,1978q4), maxlag(1) using(2) uncorr }

{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:References}

Lutkepohl, Helmut, 1993. Introduction to Multiple Time Series Analysis, 2d ed.
 Berlin: Springer-Verlag.

Sims, Christopher, 1980. Macroeconomics and Reality. Econometrica 48, 1-49.


{title:Acknowledgements}

Thanks to Vince Wiggins for assistance modifying this code to interact
properly with predict, and to Richard Sperling for developing the AIC, BIC,
HQ criteria code. 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 omninorm} (if installed),
 {help regress}, {help predict} {p_end}
