
Last chance! 50% off unlimited learning
Sale ends in
Predictive densities for conditional forecasts
pred.density(object, newdata = NULL, n = 300, hnbsteps = 30, ...)
pred.density
returns a list of class pred.density
with
the following elements
a list whose elements each contain the estimated density for each forecasted observation
a vector with the expected values of the predictions (the 'point forecasts')
a vector with the standard deviations of the predictions (the 'standard errors')
Returns the
densities of realized response variables provided in realized.y
.
If realized.y
is a matrix, then each row corresponds to a forecast
observation in newdata
if not left empty, predict.index
specifies to which observations in newdata the realized.y should apply
Computes the log predictive score
for the response varaible provided in realized.y
(cf.
lps.bma
) -
Note that the LPS equals minus the mean of the
logarithmized results from dyf
)
the same
as plot.pred.density
The number of equally spaced
points for which the density (under densities()
was computed.
The number of best models predictive densities are based upon.
the call that created this pred.density
object
a bma object - see bms
, alternativel a
zlm
object
A data.frame, matrix or vector containing variables with which to predict.
The integer number of equally spaced points at which the density is to be estimated.
The number of numerical integration steps to be used in case
of a hyper-g prior (cf. argument g
in bms
). Increase
this number to increase accuracy. Must be an even integer.
arguments to be passed on to plot.density
.
The predictive density is a mixture density based on the nmodels
best
models in a bma
object (cf. nmodel
in bms
).
The number of 'best models' to retain is therefore vital and should be set
quite high for accuracy.
predict.bma
for simple point forecasts,
plot.pred.density
for plotting predictive densities,
lps.bma
for calculating the log predictive score
independently, quantile.pred.density
for extracting quantiles
Check http://bms.zeugner.eu for additional help.
data(datafls)
mm=bms(datafls,user.int=FALSE)
#predictive densityfor two 'new' data points
pd=pred.density(mm,newdata=datafls[1:2,])
#fitted values based on best models, same as predict(mm, exact=TRUE)
pd$fit
#plot the density for the first forecast observation
plot(pd,1)
# the same plot ' naked'
plot(pd$densities()[[1]])
#predict density for the first forecast observation if the dep. variable is 0
pd$dyf(0,1)
#predict densities for both forecasts for the realizations 0 and 0.5
pd$dyf(rbind(c(0,.5),c(0,.5)))
# calc. Log Predictive Score if both forecasts are realized at 0:
lps.bma(pd,c(0,0))
Run the code above in your browser using DataLab