View source: R/poisson.spike.R
poisson.spike | R Documentation |
MCMC algorithm for Poisson regression models with a 'spike-and-slab' prior that places some amount of posterior probability at zero for a subset of the coefficients.
poisson.spike(formula,
exposure = 1,
niter,
data,
subset,
prior = NULL,
na.action = options("na.action"),
contrasts = NULL,
drop.unused.levels = TRUE,
initial.value = NULL,
ping = niter / 10,
nthreads = 4,
seed = NULL,
...)
formula |
A model formula, as would be passed to |
exposure |
A vector of exposure durations matching the length of
the response vector. If |
niter |
The number of MCMC iterations to run. |
data |
An optional data frame, list or environment (or object
coercible by |
subset |
An optional vector specifying a subset of observations to be used in the fitting process. |
prior |
A list such as that returned by
|
na.action |
A function which indicates what should happen when
the data contain |
contrasts |
An optional list. See the |
drop.unused.levels |
A logical value indicating whether factor levels that are unobserved should be dropped from the model. |
initial.value |
Initial value for the MCMC algorithm. Can either
be a numeric vector, a |
ping |
If positive, then print a status update to the console
every |
nthreads |
The number of CPU-threads to use for data augmentation. |
seed |
Seed to use for the C++ random number generator. It
should be |
... |
Extra arguments to be passed to |
The MCMC algorithm used here is based on the auxiliary mixture sampling algorithm published by Fruhwirth-Schnatter, Fruhwirth, Held, and Rue (2009).
Returns an object of class poisson.spike
. The returned object
is a list with the following elements.
beta |
A |
prior |
The prior used to fit the model. If a |
Steven L. Scott
Sylvia Fruhwirth-Schnatter, Rudolf Fruhwirth, Leonhard Held, and Havard Rue. Statistics and Computing, Volume 19 Issue 4, Pages 479-492. December 2009
lm.spike
SpikeSlabPrior
,
plot.lm.spike
,
summary.lm.spike
,
predict.lm.spike
.
simulate.poisson.spike <- function(n = 100, p = 10, ngood = 3, niter=1000){
x <- cbind(1, matrix(rnorm(n * (p-1)), nrow=n))
beta <- c(rnorm(ngood), rep(0, p - ngood))
lambda <- exp(x %*% beta)
y <- rpois(n, lambda)
x <- x[,-1]
model <- poisson.spike(y ~ x, niter=niter)
return(invisible(model))
}
model <- simulate.poisson.spike()
plot(model)
summary(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.