Lasso prior on simulated data

Hi, I’m trying to get the lasso prior to work on some simulated data and I’m getting the following error:

Error in ans[!test & ok] <- rep(no, length.out = length(ans))[!test & :
replacement has length zero
In addition: Warning message:
In rep(no, length.out = length(ans)) :
‘x’ is NULL so the result will be NULL

Any advice as to what is happening. When I run a simple stan_lm it works just fine.

library(rstanarm)

X = matrix(rnorm(500), nrow = 100)
Y = 3+X%*%c(1,2,3,0,0)+rnorm(100)
data = as.data.frame(cbind(Y,X))

model2 = stan_lm(V1~., data = data, prior = lasso(df = 1, location = 0.2, scale = NULL, autoscale = TRUE), adapt_delta= 0.99)

The stan_lm function does not permit a lasso prior, although the prior on the R^2 that it does support has some of the same characteristics. You can use laplace() or lasso() with stan_glm but the hs and hs_plus priors are better for that purpose.

3 Likes

Thanks!