Implements Bayesian variable selection using a spike-and-slab prior with a Laplace (double-exponential) slab
on nonzero coefficients. Latent inclusion indicators gamma
follow Bernoulli(theta
), and their probabilities
follow independent Beta(a
, b
) priors.
spike_laplace_partially_mcmc(
X,
Y,
intercept = TRUE,
a = 2,
b = NULL,
nburn = 4000,
npost = 4000,
seed = NULL,
verbose = TRUE,
printevery = 1000,
chain_index = 1
)
A named list with components:
post_rho
Numeric vector length npost
, sampled global scale \(\rho\).
post_gamma
Matrix npost * p
of sampled inclusion indicators.
post_theta
Matrix npost * p
of sampled Beta parameters \(\theta_j\).
post_alpha
Matrix npost * D
of sampled intercepts (if used).
post_lambda2
Matrix npost * p
of sampled local scale parameters \(\lambda_j^2\).
post_sigma2
Numeric vector length npost
, sampled residual variances.
post_beta
Array npost * D * p
of sampled regression coefficients.
post_fitted_Y
Array npost * D * n
of posterior predictive draws (including noise).
post_pool_beta
Matrix (npost * D) * p
of pooled coefficient draws.
post_pool_fitted_Y
Matrix (npost * D) * n
of pooled predictive draws (with noise).
hat_matrix_proj
Matrix D * n * n
of averaged projection hat-matrices. To avoid recalculate for estimating degree of freedom.
a
, b
Numeric values of the rho hyperparameters used.
A 3-D array of predictors with dimensions D * n * p
.
A matrix of outcomes with dimensions D * n
.
Logical; include an intercept term? Default TRUE
.
Numeric; shape parameter of the Gamma prior. Default 2
.
Numeric or NULL
; scale parameter of the Gamma prior. If NULL
,
defaults to 0.5*(D+1)/(D*(a-1))
.
Integer; number of burn-in MCMC iterations. Default 4000
.
Integer; number of post-burn-in samples to retain. Default 4000
.
Integer or NULL
; random seed for reproducibility. Default NULL
.
Logical; print progress messages? Default TRUE
.
Integer; print progress every this many iterations. Default 1000
.
Integer; index of this MCMC chain (for labeling messages). Default 1
.
sim <- sim_B(n = 100, p = 20, type = "MAR", SNP = 1.5, corr = 0.5,
low_missing = TRUE, n_imp = 5, seed = 123)
X <- sim$data_MI$X
Y <- sim$data_MI$Y
fit <- spike_laplace_partially_mcmc(X, Y, nburn = 10, npost = 10)
Run the code above in your browser using DataLab