Consider the multiple linear regression model that predicts the US real gross national product (GNPR
) using a linear combination of industrial production index (IPI
), total employment (E
), and real wages (WR
).
For all time points, is a series of independent Gaussian disturbances with a mean of 0 and variance .
Assume these prior distributions:
. is a 4-by-1 vector of means, and is a scaled 4-by-4 positive definite covariance matrix.
. and are the shape and scale, respectively, of an inverse gamma distribution.
These assumptions and the data likelihood imply a normal-inverse-gamma conjugate model.
Create a normal-inverse-gamma conjugate prior model for the linear regression parameters. Specify the number of predictors p
and the variable names.
PriorMdl
is a conjugateblm
Bayesian linear regression model object representing the prior distribution of the regression coefficients and disturbance variance.
Summarize the prior distribution.
| Mean Std CI95 Positive Distribution
-----------------------------------------------------------------------------------
Intercept | 0 70.7107 [-141.273, 141.273] 0.500 t (0.00, 57.74^2, 6)
IPI | 0 70.7107 [-141.273, 141.273] 0.500 t (0.00, 57.74^2, 6)
E | 0 70.7107 [-141.273, 141.273] 0.500 t (0.00, 57.74^2, 6)
WR | 0 70.7107 [-141.273, 141.273] 0.500 t (0.00, 57.74^2, 6)
Sigma2 | 0.5000 0.5000 [ 0.138, 1.616] 1.000 IG(3.00, 1)
The function displays a table of summary statistics and other information about the prior distribution at the command line.
Load the Nelson-Plosser data set and create variables for the predictor and response data.
Estimate the posterior distributions. Suppress the estimation display.
PosteriorMdl
is a conjugateblm
model object that contains the posterior distributions of and .
Obtain summary statistics from the posterior distribution.
summary
is a structure array containing three fields: MarginalDistributions
, Covariances
, and JointDistribution
.
Display the marginal distribution summary and covariances by using dot notation.
ans=5×5 table
Mean Std CI95 Positive Distribution
_________ __________ ________________________ _________ __________________________
Intercept -24.249 8.7821 -41.514 -6.9847 0.0032977 {'t (-24.25, 8.65^2, 68)'}
IPI 4.3913 0.1414 4.1134 4.6693 1 {'t (4.39, 0.14^2, 68)' }
E 0.0011202 0.00032931 0.00047284 0.0017676 0.99952 {'t (0.00, 0.00^2, 68)' }
WR 2.4683 0.34895 1.7822 3.1543 1 {'t (2.47, 0.34^2, 68)' }
Sigma2 44.135 7.802 31.427 61.855 1 {'IG(34.00, 0.00069)' }
ans=5×5 table
Intercept IPI E WR Sigma2
__________ ___________ ___________ ___________ ______
Intercept 77.125 0.77133 -0.0023655 0.5311 0
IPI 0.77133 0.019994 -6.5001e-06 -0.02948 0
E -0.0023655 -6.5001e-06 1.0844e-07 -8.0013e-05 0
WR 0.5311 -0.02948 -8.0013e-05 0.12177 0
Sigma2 0 0 0 0 60.871
The MarginalDistributions
field is a table of summary statistics and other information about the posterior distribution. Covariances
is a table containing the covariance matrix of the parameters.