Fitting a multinomial logistic model where coefficients depend on a latent class

Hi,

I am attempting to estimate a multinomial logistic model where the coefficients of the model depend on a latent class. Specifically, a given customer i can choose from j = 1, …, 4 brands including an “outside option”. The model assumes alternative dependent constants as well as generic coefficients for two covariates, quantity and price. Furthermore, these constants and coefficients differ based on the latent customer type; here, we assume a customer can be of three types, indexed by 1, 2, and 3.

I have included the code that also generates the data set. Please pardon my RStan code, as it is not
terribly elegant or efficient. My main concern is that I am not able to recover the simulated parameters of the model. The traceplots show evidence of label switching. I am unsure of how I can apply parameter ordering in this particular case. Any suggestions on how I could resolve this issue would be greatly appreciated!

Best,
Paul

Please see attached code:
script_HomoMNL_v3.R (5.2 KB)

Sorry this didn’t get answered—long questions about statistics with attachments are the least likely to be answered on our forums because they take so long.

I tried taking a look but can’t follow the description or the code here. I’m not sure where a latent class comes into play. If there’s a latent discrete class, you’re going to need to marginalize it out and I didn’t see anyting like that in the code.

What do you get label switching on?

P.S. Whenever you see numerical suffixes, you want to be using arrays. That way, the code doesn’t sprawl with cut-and pastes, which are very error prone. For example, why are there only priors on the first rows of beta1 etc.?

A couple things,
First, look up the to_vector function. You can use it like to_vector(asc3) ~ normal(0,10) instead of using loops.
Next, you are doing manual assignment all over the place. This is common for cases of accumulation, but you are just copying variables from vectors to matrices.
For these two reasons, its very difficult to understand what’s going on!
Next, I would try to use avoid using the target += some_fn of variables motif, and possibly reformulate as data ~ expression of distributions, although I’m not sure if that’s possible with these types of mixture models.
Otherwise, just double check your beta{1,2,3} assignment, it looks like they are all the same!