Hello @Bob_Carpenter ,

yes I always try to keep at minimum for not overwhelm. Here a better part of the (bigger) original model.

basically sometime I have information about groups of pi, for an higher hierarchy. I known that the proportion of higher hierarchy sub cell types, meaning that the sum off immune cell types makes the 50% of the mixture.

Therefore I want to constrain their sum to be what I want.

Very important… I want to do it in a way that the same code can deal with any grouping so this grouping/constrain/prior cannot be hard coded. That’s why I though to put a harsh prior on their sum.

```
data{
int G; // Number of marker genes
int P; // Number of cell types
int S; // Number of mix samples
vector[G] m[S]; // Mix samples matrix
}
parameters{
simplex[P] pi[S]; // Matrix of cell type proportions
real<lower=0> sigma; // Standard deviation of predicted mixed expression
vector[P] expr[G]; // Predicted marker signature
}
model{
sigma ~ normal(0,0.5);
for(s in 1:S) alpha[group[s]] ~ gamma(1.1,0.1); // Prior to alpha
for(s in 1:S) pi[s] ~ dirichlet(alpha[group[s]]); // Prior to a
for(s in 1:S) for(g in 1:G) {
m[s,g] ~ student_t(2, log_sum_exp(expr[g] + log(pi[s])), sigma); // Calculating probability of inferred mixed gene expression
}
}
```