# NOT RUN {
#################################
## Example on synethetic data. ##
#################################
n <- 50
p <- 80
X <- matrix(rnorm(n*p,-3,3), nrow=n, ncol=p)
beta.true <- c(rep(2,5), rep(0,p-5)) # True beta has five entries of '2' and rest '0'
X <- scale(X) # Center and scale X
y <- crossprod(t(X), beta.true) + rnorm(n)
################################
# Fit the NBP regression model #
# using variational Bayes #
################################
nbp.model <- nbp.VB(X=X, y=y, method.hyperparameters="mml", selection="dss")
nbp.model$beta.hat # posterior mean estimates
nbp.model$beta.var # posterior variance estimates
nbp.model$nbp.classifications # Variables selected
# }
Run the code above in your browser using DataLab