empiricalblm
Bayesian linear regression model with samples from prior or posterior distributions
Description
The Bayesian linear regression
                model object empiricalblm contains samples from the prior
            distributions of β and
                σ2, which MATLAB® uses to characterize the prior or posterior distributions.
The data likelihood is where ϕ(yt;xtβ,σ2) is the Gaussian probability density evaluated at yt with mean xtβ and variance σ2. Because the form of the prior distribution functions are unknown, the resulting posterior distributions are not analytically tractable. Hence, to estimate or simulate from posterior distributions, MATLAB implements sampling importance resampling.
You can create a Bayesian linear regression model with an empirical prior directly
            using bayeslm or empiricalblm.
            However, for empirical priors, estimating the posterior distribution requires that the
            prior closely resemble the posterior. Hence, empirical models are better suited for
            updating posterior distributions estimated using Monte Carlo sampling (for example,
            semiconjugate and custom prior models) given new data.
Creation
Either the estimate function returns an
                empiricalblm object or you directly create one by using
                empiricalblm.
- Return - empiricalblmobject using- estimate: For semiconjugate, empirical, custom, and variable-selection prior models,- estimateestimates the posterior distribution using Monte Carlo sampling. Specifically,- estimatecharacterizes the posterior distribution by a large number of draws from that distribution.- estimatestores the draws in the- BetaDrawsand- Sigma2Drawsproperties of the returned Bayesian linear regression model object. Hence, when you estimate- semiconjugateblm,- empiricalblm,- customblm,- lassoblm,- mixconjugateblm, and- mixconjugateblmmodel objects,- estimatereturns an- empiricalblmobject.
- Create - empiricalblmobject directly: If you want to update an estimated posterior distribution using new data, and you have draws from the posterior distribution of β and σ2, you can create an empirical model using- empiricalblm.
Syntax
Description
PriorMdl = empiricalblm(NumPredictors,'BetaDraws',BetaDraws,'Sigma2Draws',Sigma2Draws)PriorMdl) composed of
                            NumPredictors predictors and an intercept, and sets
                        the NumPredictors property. The random samples from the
                        prior distributions of β and
                            σ2,
                            BetaDraws and Sigma2Draws,
                        respectively, characterize the prior distributions.
                            PriorMdl is a template that defines the prior
                        distributions and the dimensionality of β.
PriorMdl = empiricalblm(NumPredictors,'BetaDraws',BetaDraws,'Sigma2Draws',Sigma2Draws,Name,Value)NumPredictors) using name-value pair arguments.
                        Enclose each property name in quotes. For example,
                                empiricalblm(2,' specifies the random samples from the prior
                        distributions of β and
                            σ2 and specifies a
                        regression model with 2 regression coefficients, but no intercept.BetaDraws',BetaDraws,'Sigma2Draws',Sigma2Draws,'Intercept',
                            false)
Properties
Object Functions
| estimate | Estimate posterior distribution of Bayesian linear regression model parameters | 
| simulate | Simulate regression coefficients and disturbance variance of Bayesian linear regression model | 
| forecast | Forecast responses of Bayesian linear regression model | 
| plot | Visualize prior and posterior densities of Bayesian linear regression model parameters | 
| summarize | Distribution summary statistics of standard Bayesian linear regression model | 
Examples
More About
Algorithms
- After implementing sampling importance resampling to sample from the posterior distribution, - estimate,- simulate, and- forecastcompute the effective sample size (ESS), which is the number of samples required to yield reasonable posterior statistics and inferences. Its formula is- If ESS < - 0.01*NumDraws, then MATLAB throws a warning. The warning implies that, given the sample from the prior distribution, the sample from the proposal distribution is too small to yield good quality posterior statistics and inferences.
- If the effective sample size is too small, then: - Increase the sample size of the draws from the prior distributions. 
- Adjust the prior distribution hyperparameters, and then resample from them. 
 
- Specify - BetaDrawsand- Sigma2Drawsas samples from informative prior distributions. That is, if the proposal draws come from nearly flat distributions, then the algorithm can be inefficient.
Alternatives
            The bayeslm function can create any supported prior model object for Bayesian linear regression.
        
Version History
Introduced in R2017a
