Description Usage Arguments Details Value References Examples
Random-Walk Metropolis Hastings sampler for Binomial and Poisson Mixture Link models.
1 2 3 4 5 6 7 8 9 | rwmetrop.mixlink.binomial(y, X, m, R, burn = 0, thin = 1,
invlink = plogis, Beta.init = NULL, Pi.init, kappa.init = NULL,
hyper = NULL, report.period = R + 1, use.laplace.approx = TRUE,
proposal = NULL, param.grp = NULL, fixed.kappa = FALSE)
rwmetrop.mixlink.poisson(y, X, offset = rep(0, length(y)), R, burn = 0,
thin = 1, invlink = exp, Beta.init = NULL, Pi.init, kappa.init = NULL,
hyper = NULL, report.period = R + 1, use.laplace.approx = TRUE,
proposal = NULL, param.grp = NULL, fixed.kappa = FALSE)
|
y |
Observations. |
X |
Design matrix for regression. |
m |
Number of success/failure trials. |
R |
Number of MCMC draws to take. |
burn |
Number of initial MCMC draws to discard. |
thin |
After burn-in period, save one of every |
invlink |
The inverse link function for the mean. Default is
|
Beta.init |
Starting value for \bm{β}. |
Pi.init |
Starting value for \bm{π}. |
kappa.init |
Starting value for κ. |
hyper |
A list with hyperparameters corresponding to the prior from the
Details section. |
report.period |
Report progress every |
use.laplace.approx |
Maximize a Laplace approximation to the posterior, to find a starting value for MCMC. |
proposal |
A list with two elements. |
param.grp |
A vector of integers of length d + (J-1) + 1, where |
fixed.kappa |
Keep κ fixed at |
offset |
Constant offset term to add to x^T β. |
Priors for Bayesian Mixture Link model are
\bm{β} \sim \textrm{N}(\bm{0}, V_{β} \bm{I}) ,
\bm{π} \sim \textrm{Dirichlet}_J(\bm{α}_π) ,
κ \sim \textrm{Gamma}(a_κ, b_κ) , parameterized with \textrm{E}(κ) = a_κ / b_κ.
A list with the MCMC results:
par.hist |
R \times [d + (J-1) + 1] matrix of saved MCMC draws before transformations are applied. Most users will not need this. |
Beta.hist |
R \times d matrix of saved \bm{β} draws |
Pi.hist |
R \times J matrix of saved \bm{π} draws |
kappa.hist |
R \times 1 vector of κ draws |
accept |
Percentages that MCMC proposals were accepted. Corresponds to
|
elapsed.sec |
Elapsed time for sampling, in seconds. |
laplace.out |
Output of Laplace approximation. |
R.keep |
Number of draws kept, after thinning and burn-in. |
X.names |
Names of columns of design matrix. |
Can be accessed with the functions print
, summary
, and DIC
.
Andrew M. Raim, Nagaraj K. Neerchal, and Jorge G. Morel. An Extension of Generalized Linear Models to Finite Mixture Outcomes. arXiv preprint: 1612.03302
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## Not run:
library(Matrix)
# ----- Generate data -----
n <- 200
x <- runif(n, 1, 3)
X <- model.matrix(~ x)
Beta.true <- c(0, 1)
mean.true <- exp(X %*% Beta.true)
kappa.true <- 0.95
Pi.true <- c(1,3)/4
d <- ncol(X)
J <- length(Pi.true)
y <- r.mixlink.pois(n, mean.true, Pi.true, kappa.true)
# ----- Run Metropolis-within-Gibbs sampler -----
hyper <- list(VBeta = diag(1000, d), alpha.Pi = rep(1, J),
kappa.a = 1, kappa.b = 1/2)
proposal <- list(
var = bdiag(solve(t(X) %*% X), diag(J-1), 1),
scale = 0.5)
metrop.out <- rwmetrop.mixlink.poisson(y, X, R = 20000, burn = 1000,
thin = 10, Pi.init = c(1,9)/10, hyper = hyper,
report.period = 1000, use.laplace.approx = TRUE, proposal = proposal)
print(metrop.out)
DIC(metrop.out)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.