1

I am trying to do a lasso variable selection on my classical and Bayesian models but none of them is working and it crashes my whole program.

My data are:
https://i.stack.imgur.com/wFTRV.png

My models are:

# Classical model
model1 <- lm(V128~., data=subset)
# Bayesian model
model2 <- bas.lm(V128s ~ . , data = subset, method="MCMC", prior = "ZS-null", modelprior = uniform()) 

And the code I am using is:

# Lasso for classical model
lasso <- glmnet(subset[,-13], subset$V128, family="gaussian", alpha=1, lambda=NULL)

# build Lasso (variable selection)
blasso(subset, subset$V128 ,T = 1000, thin = NULL, RJ = TRUE, M = 12,
       beta = NULL, lambda2 = 0, s2 = var(subset$V128-mean(subset$V128)),
       case = c("default", "ridge", "hs", "ng"), mprior = c(0.5,0.5), rd = NULL,
       ab = NULL, theta = 0, rao.s2 = TRUE, icept = TRUE,
       normalize = TRUE, verb = 1)

What shall i do to make it work?

Gwendoline
  • 33
  • 4
  • 2
    [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making an R question that folks can help with. That includes a sample of data, not a picture of it which can't be loaded into R – camille Nov 18 '19 at 17:29
  • I'm not familiar with the `BAS` package, so I don't know what their priors are. In theory, setting a Laplace prior is equivalent to lasso, so you shouldn't have to do any extra variable selecting for the Bayesian case. In `rstanarm`, setting `stan_glm`'s `prior` argument to `laplace()` uses a fixed penalty, whereas `lasso()` will tune the penalty as a hyperparameter, as stated [in this post](https://statmodeling.stat.columbia.edu/2017/02/14/lasso-regression-etc-stan/). – merv Nov 18 '19 at 20:35

0 Answers0