Stan does not support integer parameters; these need to be marginalized out. However, this generally doesn’t work well for the spike and slab, and it’s often (but not universally) recommended to use a horseshoe prior as a viable alternative. For more, see
- Sparsity Blues
- 7 Latent Discrete Parameters | Stan User’s Guide
- Rao-Blackwellization and discrete parameters in Stan | Statistical Modeling, Causal Inference, and Social Science
- Maxwell B. Joseph: A step-by-step guide to marginalizing over discrete parameters for ecologists using Stan
See also your earlier post here
And this post
Note also that in your code where you have
beta1 ~ lambda*slab+(1-lambda*spike);
you are using the ~
sampling notation but the right-hand side is not a distribution (it’s just a number). This is in one sense a secondary concern since the spike-and-slab probably isn’t achievable in the way you want in the first place. In another sense, it’s important to understand what ~
does and why statements like this one don’t mean anything in the Stan language to support your future modeling endeavors in Stan.