MCMCnegbin | R Documentation |
This function generates a sample from the posterior distribution of a Negative Binomial regression model via auxiliary mixture sampling. The user supplies data and priors, and a sample from the posterior distribution is returned as an mcmc object, which can be subsequently analyzed with functions provided in the coda package.
MCMCnegbin(
formula,
data = parent.frame(),
b0 = 0,
B0 = 1,
e = 2,
f = 2,
g = 10,
burnin = 1000,
mcmc = 1000,
thin = 1,
verbose = 0,
seed = NA,
beta.start = NA,
rho.start = NA,
rho.step = 0.1,
nu.start = NA,
marginal.likelihood = c("none", "Chib95"),
...
)
formula |
Model formula. |
data |
Data frame. |
b0 |
The prior mean of |
B0 |
The prior precision of |
e |
The hyperprior for the distribution |
f |
The hyperprior for the distribution |
g |
The hyperprior for the distribution |
burnin |
The number of burn-in iterations for the sampler. |
mcmc |
The number of Metropolis iterations for the sampler. |
thin |
The thinning interval used in the simulation. The number of mcmc iterations must be divisible by this value. |
verbose |
A switch which determines whether or not the progress of the
sampler is printed to the screen. If |
seed |
The seed for the random number generator. If NA, the Mersenne
Twister generator is used with default seed 12345; if an integer is passed
it is used to seed the Mersenne twister. The user can also pass a list of
length two to use the L'Ecuyer random number generator, which is suitable
for parallel computation. The first element of the list is the L'Ecuyer
seed, which is a vector of length six or NA (if NA a default seed of
|
beta.start |
The starting value for the |
rho.start |
The starting value for the |
rho.step |
Tuning parameter for the slice sampling approach to
sampling |
nu.start |
The starting values for the random effect,
|
marginal.likelihood |
How should the marginal likelihood be calculated?
Options are: |
... |
further arguments to be passed. |
MCMCnegbin
simulates from the posterior distribution of a
Negative Binomial regression model using a combination of auxiliary
mixture sampling and slice sampling. The simulation proper is done
in compiled C++ code to maximize efficiency. Please consult the
coda documentation for a comprehensive list of functions that can
be used to analyze the posterior sample.
The model takes the following form:
y_i \sim \mathcal{P}oisson(\nu_i\mu_i)
Where the inverse link function:
\mu_i = \exp(x_i'\beta)
We assume a multivariate Normal prior on \beta
:
\beta \sim \mathcal{N}(b_0,B_0^{-1})
The unit-level random effect that handles overdispersion is assumed to be distributed Gamma:
\nu_i \sim \mathcal{G}amma(\rho, \rho)
The overdispersion parameter has a prior with the following form:
f(\rho|e,f,g) \propto \rho^{e-1}(\rho + g)^{-(e+f)}
The model is simulated via blocked Gibbs, with the the \beta
being simulated via the auxiliary mixture sampling method of
Fuerhwirth-Schanetter et al. (2009). The \rho
is updated via
slice sampling. The \nu_i
are updated their (conjugate) full
conditional, which is also Gamma.
An mcmc object that contains the posterior sample. This object can be summarized by functions provided by the coda package.
Andrew D. Martin, Kevin M. Quinn, and Jong Hee Park. 2011. “MCMCpack: Markov Chain Monte Carlo in R.”, Journal of Statistical Software. 42(9): 1-21. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v042.i09")}.
Daniel Pemstein, Kevin M. Quinn, and Andrew D. Martin. 2007. Scythe Statistical Library 1.0. http://scythe.wustl.edu.s3-website-us-east-1.amazonaws.com/.
Martyn Plummer, Nicky Best, Kate Cowles, and Karen Vines. 2006. “Output Analysis and Diagnostics for MCMC (CODA)”, R News. 6(1): 7-11. https://CRAN.R-project.org/doc/Rnews/Rnews_2006-1.pdf.
Sylvia Fruehwirth-Schnatter, Rudolf Fruehwirth, Leonhard Held, and Havard Rue. 2009. “Improved auxiliary mixture sampling for hierarchical models of non-Gaussian data”, Statistics and Computing 19(4): 479-492. <doi:10.1007/s11222-008-9109-4>
plot.mcmc
,summary.mcmc
,
glm.nb
## Not run:
n <- 150
mcmcs <- 5000
burnin <- 5000
thin <- 5
x1 <- runif(n, 0, 2)
rho.true <- 1.5
nu.true <- rgamma(n, rho.true, rho.true)
mu <- nu.true * exp(1 + x1 * 1)
y <- rpois(n, mu)
posterior <- MCMCnegbin(y ~ x1)
plot(posterior)
summary(posterior)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.