%% Access Estimates in Estimation Display
% Consider the regression model in docid:econ_ug.bvmabyl-1. This example uses the same data and context, but assumes a semiconjugate prior model instead.
% Create a semiconjugate prior model for the linear regression parameters. Specify the number of predictors p and the names of the regression coefficients.

p = 3;
PriorMdl = bayeslm(p,'ModelType','semiconjugate',...
    'VarNames',["IPI" "E" "WR"]);

% PriorMdl is a semiconjugateblm model object.
%
% Load the Nelson-Plosser data set. Create variables for the response and predictor series.

load Data_NelsonPlosser
X = DataTable{:,PriorMdl.VarNames(2:end)};
y = DataTable{:,'GNPR'};

%
% Estimate the marginal posterior distributions of \beta and \sigma^2.

rng(1); % For reproducibility
[PosteriorMdl,Summary] = estimate(PriorMdl,X,y);

% PosteriorMdl is an empiricalblm model object because marginal posterior distributions of semiconjugate models are analytically intractable, so estimate must implement a Gibbs sampler. Summary is a table containing the estimates and inferences that estimate displays at the command line.
%
% Display the summary table.

Summary

%
% Access the 95% equitailed credible interval of the regression coefficient of IPI.

Summary.CI95(2,:)

% Copyright 2018 The MathWorks, Inc.