pcarbo / varbvs

Large-scale Bayesian variable selection for R and MATLAB.
http://pcarbo.github.io/varbvs
GNU General Public License v3.0
42 stars 14 forks source link

How to sample from the posterior? #35

Open garyzhubc opened 12 months ago

garyzhubc commented 12 months ago

How to sample from the posterior?

pcarbo commented 12 months ago

@garyzhubc The code for function varbvspve illustrates how to do this.

garyzhubc commented 8 months ago

I'm seeing this loop

  pve <- rep(0, nr)
  for (i in 1:nr) {
    j <- sample(ns, 1, prob = fit$w)
    b <- with(fit, mu[, j] + sqrt(s[, j]) * rnorm(p))
    b <- b * (runif(p) < fit$alpha[, j])
    sz <- c(var1(X %*% b))
    pve[i] <- sz/(sz + fit$sigma[j])
  }

Is b here a posterior sample of inclusion?