%% Normal-Inverse-Gamma Semiconjugate Prior Model
% Consider the linear regression model in Default Diffuse Prior Model. Assume these prior distributions:
% \beta\vert\sigma^2 \sim N_4\left({\rm M},V\right). {\rm M} is a 4-by-1 vector of means, and V is a scaled 4-by-4 positive definite covariance matrix.
% \sigma^2 \sim IG(A,B). A and B are the shape and scale, respectively, of an inverse gamma distribution.
% These assumptions and the data likelihood imply a normal-inverse-gamma semiconjugate model. The conditional posteriors are conjugate to the prior with respect to the data likelihood, but the marginal posterior is analytically intractable.
% Create a normal-inverse-gamma semiconjugate prior model for the linear regression parameters. Specify the number of predictors p.

p = 3;
Mdl = bayeslm(p,'ModelType','semiconjugate') 

% Mdl is a semiconjugateblm Bayesian linear regression model object representing the prior distribution of the regression coefficients and disturbance variance. bayeslm displays a summary of the prior distributions at the command line. For example, the elements of Positive represent the prior probability that the corresponding parameter is positive.
% If you have data, then you can estimate characteristics of the marginal or conditional posterior distribution by passing the prior model Mdl and data to estimate.
% Copyright 2012 The MathWorks, Inc.