Forecast responses of Bayesian linear regression model
yF = forecast(Mdl,XF)
yF = forecast(Mdl,XF,X,y)
yF = forecast(___,Name,Value)
[yF,YFCov]
= forecast(___)
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, then
forecast
produces the posterior
predictive distribution by “updating” the prior model
with information about the parameters that it gleans from the
data.
If Mdl
is a posterior model, then
forecast
updates the posteriors with
information about the parameters that it gleans from the additional
data. That is, the complete data likelihood is composed of the
additional data X
and y
, and
the data that created Mdl
.
uses any of the input arguments in the previous syntaxes and additional options
specified by one or more yF
= forecast(___,Name,Value
)Name,Value
pair arguments. For
example, you can specify a value for one of β or
σ2 to forecast from the
conditional predictive distribution of one parameter
given the specified value of the other parameter.
If Mdl
is an empiricalblm
model object, then you cannot specify
Beta
or Sigma2
. That is, you cannot
forecast from conditional predictive distributions using an empirical prior
distribution.
Monte Carlo simulation is subject to variation. That is, if forecast
uses
Monte Carlo simulation, then estimates and inferences might vary when
you call forecast
multiple times under seemingly
equivalent conditions. To reproduce estimation results, set a random
number seed using rng
before
calling forecast
.
If forecast
issues an error while estimating the posterior
distribution using a custom prior model, then try adjusting initial parameter values using
BetaStart
or Sigma2Start
, or try adjusting the
declared log prior function and then reconstructing the model. The error can indicate that
the log of the prior distribution is -Inf
at the specified initial
values.
To forecast responses from the conditional posterior predictive distribution
of analytically intractable models, except for empirical models, pass your prior
model object and the estimation-sample data to forecast
,
and specify the Beta
or Sigma2
name-value pair argument; specify the former to forecast from the conditional
posterior of σ2, and specify the
latter to forecast from the conditional posterior of
β.
Whenever forecast
must estimate a posterior
distribution (for example, when Mdl
represents a prior
distribution and you supply X
and y
)
and the posterior is analytically tractable, forecast
evaluates the closed form solutions to Bayes estimators. Otherwise,
forecast
resorts to Monte Carlo simulation to
forecast using the posterior predictive distribution. For more details, see
Posterior Estimation and Inference.
This figure describes how forecast
reduces
the Monte Carlo sample using the values of NumDraws
, Thin
,
and BurnIn
.
Rectangles represent
successive draws from the distribution. forecast
removes
the white rectangles from the Monte Carlo sample. The remaining NumDraws
black
rectangles compose the Monte Carlo sample.
conjugateblm
| customblm
| diffuseblm
| empiricalblm
| lassoblm
| mixconjugateblm
| mixsemiconjugateblm
| semiconjugateblm