predict.lm.spike | R Documentation |
Generate draws from the posterior predictive distribution of a spike and slab regression.
## S3 method for class 'lm.spike' predict(object, newdata = NULL, burn = 0, na.action = na.pass, mean.only = FALSE, ...) ## S3 method for class 'logit.spike' predict(object, newdata, burn = 0, type = c("prob", "logit", "link", "response"), na.action = na.pass, ...) ## S3 method for class 'poisson.spike' predict(object, newdata = NULL, exposure = NULL, burn = 0, type = c("mean", "log", "link", "response"), na.action = na.pass, ...) ## S3 method for class 'probit.spike' predict(object, newdata, burn = 0, type = c("prob", "probit", "link", "response"), na.action = na.pass, ...) ## S3 method for class 'qreg.spike' predict(object, newdata, burn = 0, na.action = na.pass, ...) ## S3 method for class 'BayesNnet' predict(object, newdata = NULL, burn = 0, na.action = na.pass, mean.only = FALSE, seed = NULL, ...)
object |
A model object of class |
newdata |
Either If If |
exposure |
A vector of positive real numbers the same size as
newdata, or |
burn |
The number of MCMC iterations in the object to be discarded as burn-in. |
na.action |
a function which indicates what should happen when
the data contain |
type |
The type of prediction desired. For For Both cases also accept |
mean.only |
Logical. If |
seed |
Random seed for the C++ random number generator. This is only needed for models that require C++ to implement their predict method. |
... |
Unused, but present for compatibility with generic
|
Returns a matrix of predictions, with each row corresponding to a row in newdata, and each column to an MCMC iteration.
Steven L. Scott
lm.spike
SpikeSlabPrior
summary.lm.spike
plot.lm.spike
niter <- 1000 n <- 100 p <- 10 ngood <- 3 x <- cbind(1, matrix(rnorm(n * (p-1)), nrow=n)) beta <- rep(0, p) good <- sample(1:p, ngood) beta[good] <- rnorm(ngood) sigma <- 1 y <- rnorm(n, x %*% beta, sigma) model <- lm.spike(y ~ x - 1, niter=niter) plot(model) plot.ts(model$beta) hist(model$sigma) ## should be near true value new.x <- cbind(1, matrix(rnorm(100 * (p-1)), ncol = (p-1))) pred <- predict(model, newdata = new.x, burn = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.