%% Return Estimation Summary Table
% Consider the model for the US GDP growth rate in docid:econ_ug#mw_39c3e26b-d11a-473f-87d8-5ba3e6a36185.
% Create a Markov-switching dynamic regression model for the naive estimator.

P = NaN(2);
mc = dtmc(P,'StateNames',["Expansion" "Recession"]);
mdl = arima(0,0,0);
Mdl = msVAR(mc,[mdl; mdl]);

% Create a fully specified Markov-switching dynamic regression model that has the same structure as Mdl, but set all estimable parameters to initial values.

P0 = 0.5*ones(2);
mc0 = dtmc(P0,'StateNames',Mdl.StateNames);
mdl01 = arima('Constant',1,'Variance',1);
mdl02 = arima('Constant',-1,'Variance',1);
Mdl0 = msVAR(mc0,[mdl01; mdl02]);

% Load the US GDP data set. Preprocess the data.

load Data_GDP
qrate = diff(Data(2:230))./Data(2:229); % Quarterly rate
arate = 100*((1 + qrate).^4 - 1);       % Annualized rate

% Fit the model Mdl to the annualized rate series arate. Specify Mdl0 as the model containing the initial estimable parameter values.

EstMdl = estimate(Mdl,Mdl0,arate);

% Return an estimation summary table.

results = summarize(EstMdl)

% results is a table containing estimates and inferences for all submodel coefficients.
% Identify significant coefficient estimates.

results.Properties.RowNames(results.PValue < 0.05)

% Copyright 2021 The MathWorks, Inc.
%