%% Adjust Distribution Summary Displays
% Consider the 3-D VAR(4) model of docid:econ_ug.mw_b9853539-6c31-41a7-a04d-46082d151896. Assume that the prior distribution is diffuse.
% 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 = bayesvarm(numseries,numlags,'SeriesNames',seriesnames);

% Estimate the posterior distribution.

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

% Summarize the posterior distribution; compare each estimation display type.

summarize(PosteriorMdl); % The default is 'table'.

% The default is the same default tabular display that estimate prints.

summarize(PosteriorMdl,'equation');

% In the 'equation' display, rows correspond to response equations in the VAR system, and columns correspond to lagged response variables within equations.  Elements in the table correspond to the posterior means of the corresponding coefficient; under each mean in parentheses is the standard deviation of the posterior.

summarize(PosteriorMdl,'matrix');

% In the 'matrix' display, each table contains the posterior mean of the corresponding coefficient matrix.  Under each mean in parentheses the posterior standard deviation.
% Copyright 2019 The MathWorks, Inc.
%
%