View source: R/mcmc_functions.R
spike_slab_logistic | R Documentation |
Generates Markov chain targeting the posterior corresponding to Bayesian logistic regression with spike and slab priors
spike_slab_logistic( chain_length, X, y, tau0, tau1, q, rinit = NULL, verbose = FALSE, burnin = 0, store = TRUE, Xt = NULL, XXt = NULL )
chain_length |
Markov chain length |
X |
matrix of length n by p |
y |
Response |
tau0 |
prior hyperparameter (non-negative real) |
tau1 |
prior hyperparameter (non-negative real) |
q |
prior hyperparameter (strictly between 0 and 1) |
rinit |
initial distribution of Markov chain (default samples from the prior) |
verbose |
print iteration of the Markov chain (boolean) |
burnin |
chain burnin (non-negative integer) |
store |
store chain trajectory (boolean) |
Xt |
Pre-calculated transpose of X |
XXt |
Pre-calculated matrix X*transpose(X) (n by n matrix) |
Output from Markov chain targeting the posterior corresponding to Bayesian logistic regression with spike and slab priors
# Synthetic dataset syn_data <- synthetic_data(n=100,p=200,s0=5,error_std=2,type='logistic') X <- syn_data$X y <- syn_data$y # Hyperparamters params <- spike_slab_params(n=nrow(X),p=ncol(X)) # Run S^3 sss_chain <- spike_slab_logistic(chain_length=4e3,burnin=1e3,X=X,y=y, tau0=params$tau0,tau1=params$tau1,q=params$q,verbose=FALSE,store=FALSE) # Use posterior probabilities for variable selection sss_chain$z_ergodic_avg[1:10]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.