%% Specify Model Regression Component for Estimation
% Consider including regression components for exogenous variables in the submodels of the Markov-switching dynamic regression model in Create Partially Specified Multivariate Model for Estimation. Assume  that the VAR(0) model includes the regressor x_{1t}, the VAR(1) model includes the regressors x_{1t} and x_{2t}, and the VAR(2) model includes the regressors x_{1t}, x_{2t}, and x_{3t}.
% Create the discrete-time Markov chain.

P = nan(3);
mc = dtmc(P);

%
% Create 2-D VARX(0), VARX(1), and VARX(2) models by using the shorthand syntax of varm. For each model, set the Beta property to a numSeries-by-numRegressors matrix of NaN values by using dot notation. Store all models in a vector.

numSeries = 2;

mdl1 = varm(numSeries,0);
mdl1.Beta = NaN(numSeries,1);

mdl2 = varm(numSeries,1);
mdl2.Beta = NaN(numSeries,2);

mdl3 = varm(numSeries,2);
mdl3.Beta = nan(numSeries,3);

mdl = [mdl1; mdl2; mdl3];

% Create a Markov-switching dynamic regression model from the switching mechanism mc and the state-specific submodels mdl.

Mdl = msVAR(mc,mdl); 
Mdl.Submodels(2)

% Copyright 2019 The MathWorks, Inc.