View source: R/predict.spikeslab.R
predict.spikeslab | R Documentation |
Prediction on test data using spike and slab regression.
## S3 method for class 'spikeslab' predict(object, newdata = NULL, ...)
object |
An object of class |
newdata |
Data frame or x-matrix containing test data (if omitted, the training data is used). |
... |
Further arguments passed to or from other methods. |
Computes the predicted value using a test data set.
A vector of fitted values for the BMA and gnet and a matrix of fitted values for the gnet path. Also returns the grr mixing predictor if the object has been parsed by the mixing wrapper.
Hemant Ishwaran (hemant.ishwaran@gmail.com)
J. Sunil Rao (rao.jsunil@gmail.com)
Udaya B. Kogalur (ubk@kogalur.com)
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. (2010). Generalized ridge regression: geometry and computational solutions when p is larger than n.
Ishwaran H., Kogalur U.B. and Rao J.S. (2010). spikeslab: prediction and variable selection using spike and slab regression. R Journal, 2(2), 68-73.
Ishwaran H. and Rao J.S. (2011). Mixing generalized ridge regressions.
spikeslab
.
## Not run: #------------------------------------------------------------ # Example 1: get the predictor for the training data #------------------------------------------------------------ data(diabetesI, package = "spikeslab") x <- diabetesI[, -1] y <- diabetesI[, 1] obj <- spikeslab(x = x, y = y) #gnet predictor yhat.gnet <- predict(obj)$yhat.gnet #an equivalent call is... yhat.gnet <- predict(obj, x = x)$yhat.gnet #------------------------------------------------------------ # Example 2: 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) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.