| pred.density {BMS} | R Documentation |
Predictive densities for conditional forecasts
pred.density(object, newdata = NULL, n = 300, hnbsteps = 30, ...)
object |
|
newdata |
A data.frame, matrix or vector containing variables with which to predict. |
n |
The integer number of equally spaced points at which the density is to be estimated. |
hnbsteps |
The number of numerical integration steps to be used in case of a hyper-g prior (cf. argument |
... |
arguments to be passed on to |
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.
pred.density returns a list of class pred.density with the following elements
densities() |
a list whose elements each contain the estimated density for each forecasted observation |
fit |
a vector with the expected values of the predictions (the 'point forecasts') |
std.err |
a vector with the standard deviations of the predictions (the 'standard errors') |
dyf(realized.y, predict_index=NULL) |
Returns the densities of realized response variables provided in |
lps(realized.y, predict_index=NULL) |
Computes the log predictive score for the response varaible provided in |
plot((x, predict_index = NULL, addons = "eslz", realized.y = NULL, addons.lwd = 1.5, ...) |
the same as |
n |
The number of equally spaced points for which the density (under |
nmodel |
The number of best models predictive densities are based upon. |
call |
the call that created this |
In BMS version 0.3.0, pred.density may only cope with built-in gpriors, not with any user-defined priors.
Martin Feldkircher and Stefan Zeugner
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))