%% Select Exogenous Variables for Response Equations
% This example shows how to choose which exogenous variables occur in the regression component of a VARX(4) model.
% Create a VAR(4) model template that represents three response variables. Use the shorthand syntax.

numseries = 3;
p = 4;
Mdl = varm(numseries,p)

%
% The Beta property contains the model regression coefficient matrix, a 3-by-0 matrix. Because it has 0 columns, Mdl does not have a regression component.
% Assume the following:
% You plan to include two exogenous variables in the regression component of Mdl to make it a VARX(4) model.
% Your exogenous data is in the matrix X, which is not loaded in memory.
% You want to include exogenous variable 1 (stored in X(:,1)) in all response equations, and exclude exogenous variable 2 (stored in X(:,2)) from the response variable equations 2 and 3.
% You plan to fit Mdl to data.
% Set the regression coefficient to a matrix of NaNs. Then, set the elements corresponding to excluded exogenous variables to zero.

numpreds = 2;
Mdl.Beta = nan(numseries,numpreds);
Mdl.Beta(2:3,2) = 0;

Mdl.Beta

% During estimation, estimate fits all estimable parameters (NaN-valued elements) to the data while applying these equality constraints during optimization:
% \beta_{22} =0\ldotp
% \beta_{32} =0\ldotp
% Copyright 2019 The MathWorks, Inc.