Can anyone point me in the direction of a simple reproducible example of how to model discrete parameters in Stan? I’ve had a look a look at the manual in the Finite Mixtures section but I’m finding the examples a little overwhelming.
I’m ideally looking for a simple linear regression example that has reproducible data and uses an explanatory categorical variable.
I think I might be confusing discrete parameters with discrete variables. So a categorical (discrete) variable can just be imputed into Stan with a dummy variable matrix?
If that’s the case, I don’t think I’ve ever come across a discrete parameter, nor can I yet imagine where such a parameter would be necessary. I will keep digging though.
Discrete data is not a problem for Stan. You just have to make sure that you have a numerical representation for the variables; characters will not work. If it’s an observable explanatory variable, you can just treat it as any observable continuous variable. If your discrete data is an observed outcome variable, you have to declare that in the data block otherwise you cannot work with discrete distributions.
y_binary_outcome ~ some_discrete_distribution(...);
The problem of discrete parameters happens when you have an unobserved discrete parameter, you want to model. For instance, missing values for explanatory variables, or latent variables.