View source: R/exalStaticMCMC.R
| exalStaticMCMC | R Documentation |
The function applies a Gibbs sampler for static Extended Asymmetric Laplace regression
(exAL). We update \beta, v, s from their full conditionals, then update
(\sigma,\gamma) either jointly on transformed coordinates
(\ell,\eta)=(\log \sigma,\mathrm{logit}((\gamma-L)/(U-L))) (for
"rw" and "laplace_rw") or with univariate gamma kernels
("slice", "slice_eta", "laplace_local").
Optional multi-refresh and global-jump controls are available to improve
exAL mixing in hard cases.
exalStaticMCMC(
y,
X,
p0,
b0 = NULL,
V0 = NULL,
beta_prior = c("ridge", "rhs", "rhs_ns"),
beta_prior_controls = NULL,
a_sigma = 1,
b_sigma = 1,
gamma_bounds = c(L.fn(p0), U.fn(p0)),
log_prior_gamma = NULL,
init = NULL,
dqlm.ind = FALSE,
al.ind = NULL,
n.burn = 2000,
n.mcmc = 1500,
thin = 1,
init.from.vb = FALSE,
vb_init_controls = NULL,
vb_init_fit = NULL,
mcmc_control = NULL,
sigmagam_controls = NULL,
mh.proposal = c("slice", "laplace_rw", "rw", "slice_eta", "laplace_local"),
mh.adapt = TRUE,
mh.adapt.interval = 50L,
mh.target.accept = c(0.2, 0.45),
mh.scale.bounds = c(0.1, 10),
mh.max_scale.step = 0.35,
mh.min_burn_adapt = 50L,
slice.width = 0.1,
slice.max.steps = Inf,
gamma.substeps = 1L,
p.global.eta.jump = 0,
global.eta.jump.scale = 1,
trace.diagnostics = TRUE,
trace.every = 1L,
verbose = TRUE,
progress_callback = NULL
)
y |
Numeric vector of length |
X |
Numeric matrix |
p0 |
Quantile level in |
b0, V0 |
Prior mean and covariance for |
beta_prior |
Coefficient prior type: |
beta_prior_controls |
Optional list of prior-specific controls. For
RHS-family priors (that is, when |
a_sigma, b_sigma |
Hyperparameters for an inverse-gamma prior on
|
gamma_bounds |
Numeric length-2 vector (L, U) for |
log_prior_gamma |
Function |
init |
Optional list with starting values: |
dqlm.ind |
Logical; if |
al.ind |
Optional static-model alias for |
n.burn |
Number of burn-in iterations. Default |
n.mcmc |
Number of kept MCMC iterations (after burn). Default |
thin |
Integer; save every |
init.from.vb |
Logical; if |
vb_init_controls |
Optional list controlling VB warm start. Supported keys:
|
vb_init_fit |
Optional precomputed static VB fit object used as the
warm-start reference when |
mcmc_control |
Optional normalized MCMC control list, usually from
|
sigmagam_controls |
Optional list controlling warmup/freeze behavior
for the nonconjugate |
mh.proposal |
Character string controlling the exAL nonconjugate update
kernel. |
mh.adapt |
Logical; adapt the random-walk proposal scale during burn-in
for |
mh.adapt.interval |
Integer adaptation window for RW-based kernels. |
mh.target.accept |
Numeric length-2 target acceptance band. |
mh.scale.bounds |
Numeric length-2 lower/upper bounds for RW proposal scale multiplier. |
mh.max_scale.step |
Numeric multiplicative adaptation cap in |
mh.min_burn_adapt |
Integer minimum burn-in before adaptation starts. |
slice.width |
Positive numeric width for bounded slice updates when
|
slice.max.steps |
Positive integer or |
gamma.substeps |
Positive integer; number of consecutive gamma-kernel
refreshes per outer MCMC iteration. Default |
p.global.eta.jump |
Numeric in |
global.eta.jump.scale |
Positive numeric scale multiplier applied to the Laplace proposal SD used in global eta jumps. |
trace.diagnostics |
Logical; if |
trace.every |
Positive integer; when |
verbose |
Print progress every |
progress_callback |
Optional callback invoked with a named list at MCMC start, at each progress checkpoint, and on completion. Intended for workflow-level per-case progress logging. |
An object of class "exalStaticMCMC" containing:
run.time - total wall time in seconds.
X, p0, bounds - design, quantile, and (L, U).
samp.beta - posterior sample of beta as coda::mcmc (n.mcmc x p).
samp.sigma - posterior sample of sigma as coda::mcmc.
samp.gamma - posterior sample of gamma as coda::mcmc.
samp.v - latent v draws as coda::mcmc (n.mcmc x n).
samp.s - latent s draws as coda::mcmc (n.mcmc x n).
samp.lambda, samp.tau, samp.c2 - RHS latent
draws when an RHS-family prior is used; otherwise NULL.
beta_prior - prior metadata and, for RHS-family priors,
posterior summaries of the shrinkage block. For "rhs_ns",
the state tracks lambda2, nu, tau2, xi,
and zeta2.
mh.diagnostics - proposal kernel diagnostics for the exAL gamma update,
including whether the saved kernel is exact/signoff-ready.
rhs.diagnostics - RHS latent summaries and optional trace
metadata when an RHS-family prior is used, including the resolved
preflight configuration used at fit start.
last - last state of the chain (useful for restarts).
set.seed(123)
n <- 60; p <- 3
X <- cbind(1, rnorm(n), rnorm(n))
beta0 <- c(0.5, -1, 0.8); sigma0 <- 1.2
y <- as.numeric(X %*% beta0 + rnorm(n, 0, sigma0))
fit <- exalStaticMCMC(
y, X, p0 = 0.5, n.burn = 60, n.mcmc = 60, thin = 1, verbose = FALSE
)
summary(fit$samp.beta)
fit_rhs <- exalStaticMCMC(
y, X, p0 = 0.5,
beta_prior = "rhs",
beta_prior_controls = list(tau0 = 0.5, nu = 3, s2 = 1, shrink_intercept = FALSE),
n.burn = 50, n.mcmc = 50, thin = 1, mh.proposal = "slice", verbose = FALSE
)
fit_rhs$beta_prior$type
fit_rhs_ns <- exalStaticMCMC(
y, X, p0 = 0.5,
beta_prior = "rhs_ns",
beta_prior_controls = list(tau0 = 0.5, a_zeta = 1.5, b_zeta = 1, zeta2_fixed = 1),
n.burn = 40, n.mcmc = 40, thin = 1, mh.proposal = "slice", verbose = FALSE
)
fit_rhs_ns$beta_prior$type
fit_al <- exalStaticMCMC(
y, X, p0 = 0.5,
al.ind = TRUE,
n.burn = 50, n.mcmc = 50, thin = 1, verbose = FALSE
)
fit_al$dqlm.ind
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.