%% Return and Inspect Estimation Summary Information
% Consider the 3-D VAR(4) model of docid:econ_ug.mw_b9853539-6c31-41a7-a04d-46082d151896. Assume that the parameters follow a semiconjugate prior model.
% Load the US macroeconomic data set.  Compute the inflation rate, stabilize the unemployment and federal funds rates, and remove missing values.

load Data_USEconModel
seriesnames = ["INFL" "UNRATE" "FEDFUNDS"];
DataTable.INFL = 100*[NaN; price2ret(DataTable.CPIAUCSL)];

DataTable.DUNRATE = [NaN; diff(DataTable.UNRATE)];
DataTable.DFEDFUNDS = [NaN; diff(DataTable.FEDFUNDS)];
seriesnames(2:3) = "D" + seriesnames(2:3);
rmDataTable = rmmissing(DataTable);

% Create a semiconjugate Bayesian VAR(4) prior model for the three response series. Specify the response variable names, and suppress the estimation display.

numseries = numel(seriesnames);
numlags = 4;

PriorMdl = bayesvarm(numseries,numlags,'Model','semiconjugate',...
    'SeriesNames',seriesnames);

% Estimate the posterior distribution. Suppress the estimation display.

PosteriorMdl = estimate(PriorMdl,rmDataTable{:,seriesnames},'Display','off');

% Because the posterior of a semiconjugate model is analytically intractable, PosteriorMdl is an empiricalbvarm model object storing the draws from the Gibbs sampler.
% Summarize the posterior distribution; return the estimation summary.

Summary = summarize(PosteriorMdl);
Summary

% Summary is a structure array of fields containing posterior estimation information. For example, the CoeffMap field contains a list of the coefficient names.  The order of the names corresponds to the order the all coefficient vector inputs and outputs. Display CoeffMap.

Summary.CoeffMap

% Copyright 2019 The MathWorks, Inc.
%
%