My GMM models interaction times. A number of `persons`

are working on `items`

(it has a bit of hierarchy). The time spent ,`Tau`

, between items is calculated consecutively and is normally distributed. It can be either when they quit working after an item or when they are in a “session” and (typically) do one or more items. . No interactions between people and items. No time based components are in the Data Generating Process( DGP ).

The two components are:

- When the people are doing work the time spend is a function of a person’s \mu^r and an item’s( \mu^r) parameters respectively.

Tau[s, i] \sim Normal(\mu^r_{[s]} + \mu^r_{curr.item[s, i]}, \sigma_{work}) - When people are not working the time is dependent on just a person’s (\mu^{nonwork}) parameter and a common \sigma_{nonwork}.

Tau[s, i] \sim Normal(\mu^{nonwork}_{[s]}, \sigma_{nonwork})

The probability of switching between these two components is:

P(person\ s\ quits\ working\ after\ item\ i) = \frac{1}{(1+exp(\mu^q_{[s]} + \mu^q_{next.item[s]})}

were `s`

is index of the person and `i`

is the index of the event

The data table per person looks like:

```
Tau curr.item next.item
12.3 15 2
18.2 1 4
56.2 13 18
....
```

I read Michael’s excellent post on degeneracy. However I am not 100% on the labeling degeneracy mechanism within stan in case of exchangeable priors:

- My Component 1 and 2 have different names (
`mu_s_r_xx + mu_i_r_yy`

and`mu_work_`

). My intuition suggests this would also*not*be able to break the degeneracy definitively, because the priors are exchangeable. Am I right? - So assuming I need to break the degeneracy in (1). I am assuming the right thing to do is combine
`mu_s_r , mu_i_r , mu_s_nowork`

into one vector and make it`ordered`

and slice it later into the individual parts. Right?

```
data {
int<lower=0> Ni;
int <lower=0> Ns;
int<lower=0> Ne;
real taus[Ne, Ns]; //Ne * Ns person histories
int<lower=1, upper=Ni> curr_items[Ne, Ns]; // current item indexes that a person works on
int<lower=1, upper=Ni> next_items[Ne, Ns]; // next item indexes that a person works on
}
parameters {
real mu_s_r[Ns];
real mu_i_r[Ni];
real mu_s_q[Ns];
real mu_i_q[Ni];
real mu_s_nowork[Ns];
real<lower=0> sigma_work;
real<lower=0> sigma_nowork;
}
model {
mu_s_r ~ normal(0, 1);
mu_s_q ~ normal(0, 1);
mu_i_r ~ normal(0, 1);
mu_i_q ~ normal(0, 10);
// Weakly informative because when a person is not working he can be away for a large amount of time.
mu_s_nowork ~ normal(0, 10);
sigma_work ~ normal(0, 10);
sigma_nowork ~ student_t(1, 0, 1);
for(s in 1:Ns) {
// For each person
for (ev in 1:Ne) {
// For each event
real lambda;
// So the mu_i_q and mu_s_q update correctly?
lambda = inv_logit(mu_s_q[s] + mu_i_q[curr_items[ev, s]]);
target += log_mix(lambda,
normal_lpdf(taus[ev, s]| mu_s_r[s] + mu_i_r[next_items[ev, s]], sigma_work), // ----> Component 1
normal_lpdf(taus[ev, s]| mu_s_nowork[s], sigma_nowork) // -----------> Component 2
);
}
}
}
```