Learn R Programming

BAS (version 1.2.1)

predict.basglm: Prediction Method for an object of class basglm

Description

Predictions under model averaging from a BMA (BAS) object for GLMS

Usage

## S3 method for class 'basglm':
predict(object, newdata, top=NULL, type=c("link", "response"), ...)

Arguments

object
An object of class "basglm", created by bas.glm
newdata
dataframe, new matrix or vector of data for predictions. May include a column for the intercept or just the predictor variables. If a dataframe, the variables are extracted using model.matrix using the call that created 'object'.
top
A scalar interger M. If supplied, subset the top M models, based on posterior probabilities for model predictions and BMA.
type
Type of predictions required. The default is on the scale of the linear predictors; the alternative "response" is on the scale of the response variable. Thus for a default binomial model the default predictions are of log-odds (probabilities on logit scal
...
optional extra arguments

Value

  • a list of
  • Ybmapredictions using BMA
  • Ypredmatrix of predictions under each model
  • postprobsrenormalized probabilities of the top models
  • bestindex of top models included

Details

Use BMA to form predictions using the top highest probability models.

See Also

bas.glm, predict.bas, fitted.bas

Examples

Run this code
library(MASS)
data(Pima.tr)
data(Pima.te)
Pima.bas =  bas.glm(type ~ ., data=Pima.tr, family=binomial(), a=1, s=0,
b=nrow(Pima.tr)/2, modelprior=uniform(), n.models=2^7, method="BAS")
YHPM = predict(Pima.bas, newdata=Pima.te, top=1)  # Highest Probability model

Run the code above in your browser using DataLab