lm.spike(formula,
niter,
data,
subset,
prior = NULL,
contrasts = NULL,
drop.unused.levels = TRUE,
bma.method = c("SSVS", "ODA"),
oda.options = list(
fallback.probability = 0.0,
eigenvalue.fudge.factor = 0.01),
ping = niter / 10,
seed = NULL,
...)lm.SpikeSlabPrior. If prior is missing then a
default prior will be used. See SpikeSlabPrior.contrasts.arg
argument of model.matrix.default.fallback.probability: Each MCMC iteration will use
SSVS instead of ODA with this probability. In cases where
the latent data haping == 10 then an update
will be printed every 10 MCMC iterations.NULL then the seed will be set using the
clock.SpikeSlabPrior (if
method == "SSVS") or IndependentSpikeSlabPrior
(if metlm.spike, which is a list with the
following elementsniter by ncol(x) matrix of regression
coefficients, many of which may be zero. Each row corresponds to an
MCMC iteration.niter containing the MCMC
draws of the residual standard deviation parameter.prior was
supplied as an argument it will be returned. Otherwise this will be
the automatically generated prior based on the other function
arguments.Regarding the overall compute time, the DA method decomposes the (potentially very large) model matrix one time, at the start of the algorithm. But it then works with independent scalar updates. The SSVS algorithm does not have the upfront cost, but it works with many small matrix decompositions each MCMC iteration. The DA algorithm is very likely to be faster in terms of time per iteration.
Finally, note that the two algorithms require slightly different priors. The DA algorithm requires a priori independence, while the SSVS algorithm can work with arbitrary conjugate priors.
Ghosh and Clyde (2011) "Rao-Blackwellization for Bayesian variable
selection and model averaging in linear and binary regression: A novel
data augmentation approach", Journal of the American Statistical
Association, 106 1041-1052.
SpikeSlabPrior,
plot.lm.spike,
summary.lm.spike,
predict.lm.spike.n <- 100
p <- 10
ngood <- 3
niter <- 1000
sigma <- .8
x <- cbind(1, matrix(rnorm(n * (p-1)), nrow=n))
beta <- c(rnorm(ngood), rep(0, p - ngood))
y <- rnorm(n, x %*% beta, sigma)
x <- x[,-1]
model <- lm.spike(y ~ x, niter=niter)
plot.ts(model$beta)
opar <- par(ask=TRUE)
on.exit(par(opar))
hist(model$sigma) ## should be near 8
plot(model)
summary(model)Run the code above in your browser using DataLab