%% Display and Return Estimation Summaries
% Consider the 3-D VAR(4) model of docid:econ_ug.mw_1f230922-b87b-4b6a-a9d5-1cc611d85f95.
% 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 diffuse Bayesian VAR(4) prior model for the three response series. Specify the response variable names.

numseries = numel(seriesnames);
numlags = 4;

PriorMdl = diffusebvarm(numseries,numlags,'SeriesNames',seriesnames);

% You can display estimation output in three ways, or turn off the display. Compare the display types.

estimate(PriorMdl,rmDataTable{:,seriesnames}); % 'table', the default
estimate(PriorMdl,rmDataTable{:,seriesnames},...
    'Display','equation');
estimate(PriorMdl,rmDataTable{:,seriesnames},...
    'Display','matrix');

% Return the estimation summary, which is a structure that contains the same information regardless of display type.

[PosteriorMdl,Summary] = estimate(PriorMdl,rmDataTable{:,seriesnames});
Summary

% The CoeffMap field contains a list of the coefficient names.  The order of the names corresponds to the order of all coefficient vector inputs and outputs. Display CoeffMap.

Summary.CoeffMap

% Copyright 2019 The MathWorks, Inc.
%