%% Create Markov Chain with Unknown Transition Matrix Entries
% Consider a Markov-switching autoregression (msVAR) model for the US GDP containing four economic regimes: depression, recession, stagnation, and expansion. To estimate the transition probabilities of the switching mechanism, you must supply a dtmc model with an unknown transition matrix entries to the msVAR framework.
% Create a 4-regime Markov chain with an unknown transition matrix (all NaN entries). Specify the regime names.

P = nan(4);
statenames = ["Depression" "Recession" ...
    "Stagnation" "Expansion"];

mcUnknown = dtmc(P,'StateNames',statenames)
mcUnknown.P

% Suppose economic theory states that the US economy never transitions to an expansion from a recession or depression.  Create a 4-regime Markov chain with a partially known transition matrix representing the situation.

P(1,4) = 0;
P(2,4) = 0;

mcPartial = dtmc(P,'StateNames',statenames)
mcPartial.P

% The estimate function of msVAR treats the known elements of mcPartial.P as equality constraints during optimization.
% For more details on Markov-switching dynamic regression models, see msVAR.
% Copyright 2019 The MathWorks, Inc.