%% Create Semiconjugate Bayesian AR(2) Model
% Consider a 1-D Bayesian AR(2) model for the daily NASDAQ returns from January 2, 1990 through December 31, 2001.
% y_t=c+\phi_1 y_{t-1} + \phi_2y_{t-1} + \varepsilon_t.
% The priors are:
% {[\begin{array}{*{20}{c}}
% \phi_1 &\phi_2 & c
% \end{array}]^\prime }|{\sigma ^2} \sim {{\rm{N}}_3}\left( {\mu ,V} \right), where \mu is a 3-by-1 vector of coefficient means and V is a 3-by-3 covariance matrix.
% \sigma^2 \sim \textrm{IG}\left(\alpha ,\beta \right), where \alpha =\frac{\nu }{2} is the degrees of freedom and \beta =\frac{\Omega }{2} is the scale.
% Create a semiconjugate prior model for the AR(2) model parameters.

numseries = 1;
numlags = 2;
PriorMdl = semiconjugatebvarm(numseries,numlags)

% semiconjugatebvarm interprets the innovations covariance as an inverse Wishart random variable.  Because the scales and degrees of freedom hyperparameters among the inverse Wishart and inverse gamma distributions are not equal, you can adjust them by using dot notation.  For example, to achieve 10 degrees of freedom for the inverse gamma interpretation, set the inverse Wishart degrees of freedom to 20.

PriorMdl.DoF = 20

% Copyright 2020 The MathWorks, Inc.
%