Learn R Programming

spikeslab (version 1.0.2)

predict.spikeslab: Spike and Slab Prediction

Description

Prediction on test data using spike and slab regression.

Usage

## S3 method for class 'spikeslab':
predict(object, newdata = NULL, ...)

Arguments

object
An object of class spikeslab.
newdata
Data frame containing test data.
...
Further arguments passed to or from other methods.

Value

  • A vector of fitted values for the BMA and gnet and a matrix of fitted values for the gnet path.

Details

Computes the predicted value using a test data set.

References

Ishwaran H. and Rao J.S. (2003). Detecting differentially expressed genes in microarrays using Bayesian model selection. J. Amer. Stat. Assoc., 98:438-455. Ishwaran H. and Rao J.S. (2005a). Spike and slab variable selection: frequentist and Bayesian strategies. Ann. Statist., 33:730-773.

Ishwaran H. and Rao J.S. (2005b). Spike and slab gene selection for multigroup microarray data. J. Amer. Stat. Assoc., 100:764-780.

Ishwaran H. and Rao J.S. (2009). Generalized ridge regression: geometry and computational solutions when p is larger than n.

See Also

spikeslab.

Examples

Run this code
#------------------------------------------------------------
# Example 1: ozone data with interactions
#------------------------------------------------------------

data(ozoneI, package = "spikeslab")
train.pt <- sample(1:nrow(ozoneI), nrow(ozoneI) * 0.80)
obj <- spikeslab(ozone ~ . , ozoneI[train.pt, ])
ytest <- ozoneI$ozone[-train.pt]
ss.pred <- predict(obj, ozoneI[-train.pt, ])
yhat.bma <- ss.pred$yhat.bma
yhat.gnet <- ss.pred$yhat.gnet
plot(ytest, yhat.bma, ylab = "yhat", pch = 16, col = 4)
points(ytest, yhat.gnet, pch = 16, col = 2)
abline(0, 1, lty = 2, col = 2)
legend("bottomright", legend = c("bma", "gnet"), col = c(4, 2), pch = 16)

Run the code above in your browser using DataLab