Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

summarize

Distribution summary statistics of Bayesian linear regression model

Syntax

summarize(Mdl)
SummaryStatistics = summarize(Mdl)

Description

example

summarize(Mdl) displays a tabular summary of the random regression coefficients and disturbance variance of the Bayesian linear regression model Mdl at the command line. For each parameter, the summary includes: standard deviation (square root of the variance), 95% equal-tailed credible intervals, the probability that the parameter is greater than 0, and, if known, a description of the distributions.

example

SummaryStatistics = summarize(Mdl) returns a structure array storing:

  • A table containing the summary of the regression coefficients and disturbance variance

  • A table containing the covariances between variables

  • A description of the joint distribution of the parameters

Examples

collapse all

Consider the multiple linear regression model that predicts U.S. real gross national product (GNPR) using a linear combination of industrial production index (IPI), total employment (E), and real wages (WR).

For all , is a series of independent Gaussian disturbances with a mean of 0 and variance .

Assume that the prior distributions are:

  • . 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 variables names.

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

Mdl is a conjugateblm Bayesian linear regression model object representing the prior distribution of the regression coefficients and disturbance variance.

Summarize the prior distribution.

summarize(PriorMdl)
 
           |  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)        
 

A table of summary statistics and other information about the prior distribution appears at the command line.

Load the Nelson-Plosser data set, and create variables for the predictor and response data.

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

Estimate the posterior distributions.

PosteriorMdl = estimate(PriorMdl,X,y,'Display',false);

PosteriorMdl is a conjugateblm model object that contains the posterior distributions of and .

Summarize the prior distribution. Request a table of summary statistics.

summary = summarize(PosteriorMdl)
summary = 

  struct with fields:

    MarginalDistributions: [5x5 table]
              Covariances: [5x5 table]
        JointDistribution: "Sigma2 ~ IG(A,B), Beta|Sigma2 ~ N(Mu,Sigma2*V)"

A table of summary statistics and other information about the posterior distribution appears at the command line. summary is a structure array containing three fields.

Display each field of summary.

summary.MarginalDistributions
summary.Covariances
summary.JointDistribution
ans =

  5x5 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 =

  5x5 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


ans = 

    "Sigma2 ~ IG(A,B), Beta|Sigma2 ~ N(Mu,Sigma2*V)"

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. JointDistribution is a string scalar describing the joint posterior distribution.

Input Arguments

collapse all

Bayesian linear regression model, specified as an object in this table.

ValueBayesian Linear Regression Model Description
conjugateblm model objectDependent, normal-inverse-gamma conjugate model returned by bayeslm or estimate
semiconjugateblm model objectIndependent, normal-inverse-gamma semiconjugate model returned by bayeslm
diffuseblm model objectDiffuse prior model returned by bayeslm
empiricalblm model objectSamples from prior distributions characterize prior model returned by bayeslm or estimate
customblm model objectPrior distribution function that you declare returned by bayeslm

Output Arguments

collapse all

Parameter distribution summary, returned as a structure array containing the information in this table.

Structure FieldDescription
MarginalDistributions

Table containing a summary of the parameter distributions. Rows correspond to parameters and columns correspond to the:

  • Estimated posterior mean (Mean)

  • Standard deviation (Std)

  • 95% equal-tailed credible interval (CI95)

  • Posterior probability that the parameter is greater than 0 (Positive)

  • Description of the marginal or conditional posterior distribution of the parameter (Distribution)

Row names are the names in Mdl.VarNames, and the name of the last row is Sigma2.

CovariancesTable containing covariances between parameters. Rows and columns correspond to the intercept, if one exists, the regression coefficients, and then the disturbance variance. Row and column names are the same as the row names in MarginalDistributions.
JointDistributionA string scalar that describes the distributions of the regression coefficients (Beta) and the disturbance variance (Sigam2) when known.

For distribution descriptions:

  • N(Mu,V) denotes the normal distribution with mean Mu and variance matrix V. This distribution can be multivariate.

  • IG(A,B) denotes the inverse gamma distribution with shape A and scale B.

  • t(Mu,V,DoF) denotes Student’s t distribution with mean Mu, variance V, and degrees of freedom DoF.

More About

collapse all

Bayesian Linear Regression Model

A Bayesian linear regression model treats the parameters β and σ2 in the multiple linear regression (MLR) model yt = xtβ + εt as random variables.

For times t = 1,...,T:

  • yt is the observed response.

  • xt is a 1-by-(p + 1) row vector of observed values of p predictors. To accommodate a model intercept, x1t = 1 for all t.

  • β is a (p + 1)-by-1 column vector of regression coefficients corresponding to the variables composing the columns of xt.

  • εt is the random disturbance having a mean of zero and Cov(ε) = σ2IT×T, while ε is a T-by-1 vector containing all disturbances. These assumptions imply that the data likelihood is

    (β,σ2|y,x)=t=1Tϕ(yt;xtβ,σ2).

    ϕ(yt;xtβ,σ2) is the Gaussian probability density with mean xtβ and variance σ2 evaluated at yt;.

Before considering the data, a joint prior distribution assumption is imposed on (β,σ2). In a Bayesian analysis, the beliefs about the distribution of the parameters are updated using information about the parameters gleaned from the likelihood of the data. The result is the joint posterior distribution of (β,σ2) or the conditional posterior distributions of the parameters.

Introduced in R2017a

Was this topic helpful?