Hi!

I am working on a research project in which two treatments are evaluated by a randomized clinical trial and the outcome is measured in three moments (before de intervention, right after the intervention and one month follow-up).

I want to evaluate the differential treatment effect in the slope, similar to the CD4 model in ARM book (Chapter 20, section 5):

y_i \sim N(\alpha_{ji} + \beta_{ji} t_i, \sigma_y)

with \alpha and \beta modeled by a multivariate normal with mean parameters \gamma^{\alpha}_0 and \gamma^{\beta}_0 + \gamma^{\beta}_1 t_j, in which t is a binary treatment indicator.

So far, so good, I can fit such a model with ease. But I hypothetize that there are two latent classes: some subjects have better results with treatment 1, and some have better results with treatment 2. A finite mixture model is the obvious choice, but I couldnât find a model in the literature that corresponds exactly to my problem.

At first, I implemented a finite mixture regression model without the hierarchical component, and the model definition was quite clear, and Stan recovered all parameters beautifully.

But when the model has two levels, how the mixture should be defined? Fermund and Magidson (https://jeroenvermunt.nl/gfkl2004a.pdf) suggests mixture in both levels, but I donât think it makes sense, in my case, to consider mixture at the single measurement level.

So far, I implemented a model (code below) in which the mixture component applies only to the second level (varying intercepts and slopes), and it also recovers all parameters correctly (I think). But I really would like some input in how to better model this problem. Papers about similar models are welcome!

Thanks!

Erikson

```
data {
int<lower=1> N;
int<lower=1> J;
vector[J] t;
vector[N] time;
vector[N] y;
int id[N];
}
parameters {
// Group model
real<lower=0, upper=1> theta;
// Intercept model
vector[2] muAlpha;
vector<lower=0>[2] sigmaAlpha;
vector[J] alpha;
ordered[2] muBeta;
ordered[2] tau;
vector<lower=0>[2] sigmaBeta;
vector[J] beta;
corr_matrix[2] Omega0;
corr_matrix[2] Omega1;
real<lower=0> sigma;
}
model {
theta ~ beta(5, 5);
muAlpha ~ normal(0, 10);
tau ~ normal(0, 10);
sigmaAlpha ~ lognormal(0, 0.3);
muBeta ~ normal(0, 10);
sigmaBeta ~ lognormal(0, 0.3);
sigma ~ student_t(5, 0, 3);
Omega0 ~ lkj_corr(3);
Omega1 ~ lkj_corr(3);
{
matrix[J, 2] regPars;
matrix[J, 2] mu0;
matrix[J, 2] mu1;
vector[2] sigma0;
vector[2] sigma1;
regPars[, 1] = alpha;
regPars[, 2] = beta;
mu0[, 1] = rep_vector(muAlpha[1], J);
mu0[, 2] = muBeta[1] + tau[2] * t;
mu1[, 1] = rep_vector(muAlpha[2], J);
mu1[, 2] = muBeta[2] + tau[1] * t;
sigma0[1] = sigmaAlpha[1];
sigma0[2] = sigmaBeta[1];
sigma1[1] = sigmaAlpha[2];
sigma1[2] = sigmaBeta[2];
for (j in 1:J) {
target += log_mix(theta,
multi_normal_lpdf(regPars[j, ] | mu0[j, ],
quad_form_diag(Omega0, sigma0)),
multi_normal_lpdf(regPars[j, ] | mu1[j, ],
quad_form_diag(Omega1, sigma1)));
}
}
y ~ normal(alpha[id] + beta[id] .* time, sigma);
}
```