forecast
Forecast responses of Bayesian linear regression model
Syntax
Description
returns yF
= forecast(Mdl
,XF
)numPeriods
forecasted responses from the Bayesian linear regression
model
Mdl
given the predictor data in XF
, a
matrix with numPeriods
rows.
To estimate the forecast, forecast
uses the mean of
the numPeriods
-dimensional posterior predictive distribution.
NaN
s in the data indicate missing values, which
forecast
removes using list-wise deletion.
forecasts using the posterior predictive distribution produced or updated by
incorporating the predictor data yF
= forecast(Mdl
,XF
,X
,y
)X
and corresponding response
data y
.
If
Mdl
is a joint prior model, thenforecast
produces the posterior predictive distribution by updating the prior model with information about the parameters that it obtains from the data.If
Mdl
is a posterior model, thenforecast
updates the posteriors with information about the parameters that it obtains from the additional data. The complete data likelihood is composed of the additional dataX
andy
, and the data that createdMdl
.
uses any of the input argument combinations in the previous syntaxes and
additional options specified by one or more name-value pair arguments. For
example, you can specify a value for β or
σ2 to forecast from the
conditional predictive distribution of one parameter,
given the specified value of the other parameter.yF
= forecast(___,Name,Value
)
Examples
Input Arguments
Output Arguments
Limitations
If Mdl
is an empiricalblm
model object, then you cannot specify
Beta
or Sigma2
. You cannot forecast from
conditional predictive distributions by using an empirical prior distribution.
More About
Tips
Monte Carlo simulation is subject to variation. If
forecast
uses Monte Carlo simulation, then estimates and inferences might vary when you callforecast
multiple times under seemingly equivalent conditions. To reproduce estimation results, set a random number seed by usingrng
before callingforecast
.If
forecast
issues an error while estimating the posterior distribution using a custom prior model, then try adjusting initial parameter values by usingBetaStart
orSigma2Start
, or try adjusting the declared log prior function, and then reconstructing the model. The error might indicate that the log of the prior distribution is–Inf
at the specified initial values.To forecasted responses from the conditional posterior predictive distribution of analytically intractable models, except empirical models, pass your prior model object and the estimation-sample data to
forecast
. Then, specify theBeta
name-value pair argument to forecast from the conditional posterior of σ2, or specify theSigma2
name-value pair argument to forecast from the conditional posterior of β.
Algorithms
Whenever
forecast
must estimate a posterior distribution (for example, whenMdl
represents a prior distribution and you supplyX
andy
) and the posterior is analytically tractable,forecast
evaluates the closed-form solutions to Bayes estimators. Otherwise,forecast
resorts to Monte Carlo simulation to forecast by using the posterior predictive distribution. For more details, see Posterior Estimation and Inference.This figure illustrates how
forecast
reduces the Monte Carlo sample using the values ofNumDraws
,Thin
, andBurnIn
. Rectangles represent successive draws from the distribution.forecast
removes the white rectangles from the Monte Carlo sample. The remainingNumDraws
black rectangles compose the Monte Carlo sample.
Version History
Introduced in R2017a
See Also
Objects
conjugateblm
|semiconjugateblm
|diffuseblm
|empiricalblm
|customblm
|mixconjugateblm
|mixsemiconjugateblm
|lassoblm