To create a model of multiple time series data, decide on a VAR model form, and fit parameters to the data. When you have a fitted model, check if the model fits the data adequately.
To fit a model to data, you must have:
Time series data, as described in Multivariate Time Series Data
At least one time series model specification structure, as described in Vector Autoregression (VAR) Model Creation
There are several Econometrics Toolbox™ functions that aid these tasks, including:
estimate
, which fits VARX models.
summarize
, which displays and returns parameter estimates and other summary statistics from fitting the model.
lratiotest
and aicbic
, which can help determine the number of lags to include in a model.
infer
, which infers model residuals for diagnostic checking.
forecast
, which creates forecasts that can be used to check the adequacy of the fit, as described in VAR Model Forecasting, Simulation, and Analysis
estimate
performs parameter estimation for VAR and VARX models only. For definitions of these terms and other model definitions, see Types of Stationary Multivariate Time Series Models. For an example of fitting a VAR model to data, see Fit VAR Model of CPI and Unemployment Rate.
Before fitting the model to data, estimate
requires at least
presample observations to initialize the model, where Mdl
.PMdl
is a varm
model object and P
is the property storing the model degree. You can specify your own presample observations using the 'Y0'
name-value pair argument. Or, by default, estimate
takes the first
observations from the estimation sample Mdl
.PY
that do not contain any missing values. Therefore, if you let estimate
take requisite presample observations from the input response data Y
, then the effective sample size decreases.
estimate
finds maximum likelihood estimates of the parameters present in the model. Specifically, estimate
estimates the parameters corresponding to these varm
model properties: Constant
, AR
, Trend
, Beta
, and Covariance
. For VAR models, estimate
uses a direct solution algorithm that requires no iterations. For VARX models, estimate
optimizes the likelihood using the expectation-conditional-maximization (ECM) algorithm. The iterations usually converge quickly, unless two or more exogenous data streams are proportional to each other. In that case, there is no unique maximum likelihood estimator, and the iterations might not converge. You can set the maximum number of iterations with the MaxIterations
name-value pair argument of estimate
, which has a default value of 1000
.
estimate
removes entire observations from the data containing at least one missing value (NaN
). For more details, see estimate
.
estimate
calculates the loglikelihood of the data, giving it as an output of the fitted model. Use this output in testing the quality of the model. For example, see Select Appropriate Lag Order and Examining the Stability of a Fitted Model.
When you enter the name of a fitted model at the command line, you obtain a object summary. In the Description
row of the summary, varm
indicates whether the VAR model is stable or stationary.
Another way to determine stationarity of the VAR model is to create a lag operator polynomial object using the estimated autoregression coefficients (see LagOP
), and then passing the lag operator to isStable
. For example, suppose EstMdl
is an estimated VAR model. The following shows how to determine the model stability using lag operator polynomial objects. Observe that LagOp
requires the coefficient of lag 0
.
ar = [{eye(3)} ar]; % Include the lag 0 coefficient. Mdl = LagOp(ar); Mdl = reflect(Mdl); % Negate all lags > 0 isStable(Mdl)
If the VAR model is stable, then isStable
returns a Boolean value of 1
, and 0
otherwise. Regression components can destabilize an otherwise stable VAR model. However, you can use the process to determine the stability of the VAR polynomial in the model.
Stable models yield reliable results, while unstable ones might not.
Stability and invertibility are equivalent to all eigenvalues of the associated lag operators having modulus less than 1. In fact, isStable
evaluates these quantities by calculating eigenvalues. For more information, see isStable
or Hamilton [90].