Learn R Programming

BAS (version 1.4.7)

predict.bas: Prediction Method for an object of class BMA

Description

Predictions under model averaging or other estimators from a BMA object of class inheriting from 'bas'.

Usage

# S3 method for bas
predict(object, newdata, se.fit = FALSE, type = "link",
  top = NULL, estimator = "BMA", prediction = FALSE, ...)

Arguments

object

An object of class BAS, created by bas

newdata

dataframe for predictions. If missing, then use the dataframe used for fitting for obtaining fitted and predicted values.

se.fit

indicator for whether to compute se of fitted and predictied values

type

Type of predictions required. "Link" which is on the scale of the linear predictor is the only option currently.

top

a scalar integer M. If supplied, subset the top M models, based on posterior probabilities for model predictions and BMA.

estimator

estimator used for predictions. Currently supported options include: 'HPM' the highest probability model 'BMA' Bayesian model averaging, using optionally only the 'top' models 'MPM' the median probability model of Barbieri and Berger. 'BPM' the model that is closest to BMA predictions under squared error loss. BMA may be computed using only the 'top' models if supplied

prediction

logical value to indicate whether the observed design matrix used in fitting or the newdata will be used for estimating the mean or for making predictions. The default is FALSE for estimation of the mean.

...

optional extra arguments

Value

a list of

fit

fitted values based on the selected estimator

Ybma

predictions using BMA, the same as fit for non-BMA methods for compatibilty; will be deprecated

Ypred

matrix of predictions under each model for BMA

se.fit

se of fitted values; in the case of BMA this will be a matrix

se.pred

se for predicted values; in the case of BMA this will be a matrix

se.bma.fit

vector of posterior sd under BMA for posterior mean of the regression function. this will be NULL if estimator is not 'BMA'

se.bma.pred

vector of posterior sd under BMA for posterior predictive values. this will be NULL if estimator is not 'BMA'

best

index of top models included

bestmodels

subset of bestmodels used for fitting or prediction

df

scalar or vector of degrees of freedom for models

estimator

estimator upon which 'fit' is based.

Details

Use BMA and/or model selection to form predictions using the top highest probability models.

See Also

bas, fitted.bas, confint.pred.bas

Other predict methods: fitted.bas, predict.basglm

Other bas methods: BAS, bas.lm, coef.bas, confint.coef.bas, confint.pred.bas, diagnostics, fitted.bas, force.heredity.bas, image.bas, predict.basglm, summary.bas, update.bas

Examples

Run this code
# NOT RUN {
data("Hald")
hald.gprior =  bas.lm(Y ~ ., data=Hald, alpha=13, prior="g-prior")

predict(hald.gprior, newdata=Hald, estimator="BPM", se.fit=TRUE, prediction=FALSE)
# same as fitted
fitted(hald.gprior,estimator="BPM")

# default is BMA and estimation of mean vector
hald.bma = predict(hald.gprior, top=5, se.fit=TRUE)  
confint(hald.bma)

hald.BPM = predict(hald.gprior, newdata=Hald[1,],
                    prediction=TRUE, se.fit=TRUE,
                    estimator="BPM") 
confint(hald.BPM)

hald.hpm = predict(hald.gprior, newdata=Hald[1,],
                    prediction=TRUE, se.fit=TRUE,
                    estimator="HPM") 
confint(hald.hpm)

hald.mpm = predict(hald.gprior, newdata=Hald[1,],
                    prediction=TRUE, se.fit=TRUE,
                    estimator="MPM") 
confint(hald.mpm)

# }

Run the code above in your browser using DataLab