0

I'm trying to reproduce the graphics similar of Park and Caella (The Bayesian Lasso - 2008) in R, but the structure of the Bayesian Lasso is different of the Ordinary Lasso.

I found how to plot lasso beta coefficients (it's perfect!) but I would like to create the same graphics using Bayesian Lasso beta coefficients and so on compare two models, Bayesian lasso and ordinary lasso side by side.

I used the same data base and command from the link above

#Lasso
library(MASS)
library(glmnet)
Boston=na.omit(Boston)
x=model.matrix(crim~.,Boston)[,-1]
rownames(x)=c()
y=as.matrix(Boston$crim)
lasso.mod =glmnet(x,y, alpha =1, lambda = 0.1)
plot(lasso.mod, "norm", label = TRUE)

# For Bayesian Lasso I used this one:
# Bayesian Lasso
burnin <- 500
iter <- 1000
init_beta <- rep(-500, dim(x)[2])
ini_lambda2 <- 10
ini_var <- 500
ini_tau <- 2

# Starting Gibbs sampler
blasso.mod <- blasso(X = x, y = y, T = iter, 
beta = init_beta,
lambda2 = ini_lambda2,
s2 = ini_var)
StupidWolf
  • 45,075
  • 17
  • 40
  • 72
  • There is a package `monomvn` in R which has the function `blasso`, I thin this will suit your purpose, heres the link to the documentation, you might have to install and import monomvn in order to use : [link](https://www.rdocumentation.org/packages/monomvn/versions/1.9-13/topics/blasso) Also, within `glmnet`, I found this Github gist which might help you [glmnet bayesian lasso](https://github.com/amwag/Bayesian-Lasso/blob/master/Gibbs.R) – aryashah2k Dec 19 '20 at 04:32
  • Yes, I used the monomvn to run the Bayesian Lasso, but the graphics are different from Ordinary Lasso. I tryied to reproduce this code you suggested (glmnet bayesian lasso) but it's not run here, some erros returned. I couldn't see what's is code gives. I think my question is more simple the this, may be more difficult to implement. Thanks – DerekRR Dec 21 '20 at 23:38

0 Answers0