%% Specify All Parameter Values of VAR Model
% Create a VAR model for three arbitrary response series. Specify the parameter values in this system of equations.
% \begin{array}{l}
% {y_{1,t}} = 1 + 0.2{y_{1,t - 1}} - 0.1{y_{2,t - 1}} + 0.5{y_{3,t - 1}} + 1.5t + {\varepsilon _{1,t}}\\
% {y_{2,t}} = 1 - 0.4{y_{1,t - 1}} + 0.5{y_{2,t - 1}} + 2t + {\varepsilon _{2,t}}\\
% {y_{3,t}} =  - 0.1{y_{1,t - 1}} + 0.2{y_{2,t - 1}} + 0.3{y_{3,t - 1}} + {\varepsilon _{3,t}}
% .\end{array}
% Assume the innovations are multivariate Gaussian with a mean of 0 and the covariance matrix
% \Sigma  = \left[ {\begin{array}{*{20}{c}}
% {0.1}&{0.01}&{0.3}\\
% {0.01}&{0.5}&0\\
% {0.3}&0&1
% \end{array}} \right].
% Create variables for the parameter values.

c = [1; 1; 0];
Phi1 = {[0.2 -0.1 0.5; -0.4 0.2 0; -0.1 0.2 0.3]}; 
delta = [1.5; 2; 0];
Sigma = [0.1 0.01 0.3; 0.01 0.5 0; 0.3 0 1];

%
% Create a VAR(1) model object representing the system of dynamic equations using the appropriate name-value pair arguments.

Mdl = varm('Constant',c,'AR',Phi1,'Trend',delta,'Covariance',Sigma)

% Mdl is a fully specified varm model object. By default, varm attributes the autoregressive coefficient to the first lag.
%
% You can adjust model properties using dot notation. For example, consider another VAR model that attributes the autoregressive coefficient matrix Phi1 to the second lag term, specifies a matrix of zeros for the first lag coefficient, and treats all else as being equal to Mdl. Create this VAR(2) model.

Mdl2 = Mdl;
Phi = [zeros(3,3) Phi1];
Mdl2.AR = Phi

% Alternatively, you can create another model object using varm and the same syntax as for Mdl, but additionally specify 'Lags',2.
% Copyright 2012 The MathWorks, Inc.