Hello Community

I have a two layer hierarchical model of a regression (x * beta). With a second layer I am trying to put a prior on the proportions (beta [0,1]) calculated for many “replicates”

```
for(s in 1:S) beta[s] ~ dirichlet( to_vector( beta_hat[s] ) );
```

Now since I have a covariate (X) for each replicate, I am trying to regress the predicted probabilities:

```
beta_hat = exp(X * alpha);
for(s in 1:S) beta[s] ~ dirichlet( to_vector(beta_hat[s]) );
```

My questions are:

- is this a sensible this to do?
- Should I use log-link regression since hyperparameter of a Dirichlet must be >0?

Thanks a lot

Below the full model.

```
data{
int G; // Number of marker genes
int P; // Number of cell types
int S; // Number of mix samples
int<lower=1> R; // Number of covariates (e.g., treatments)
vector<lower=0>[G] y[S]; // Mix samples matrix
matrix<lower=0>[G,P] x; // Array of covariates
matrix[S,R] X; // Array of covariates hierarchical
}
transformed data{
vector[G] y_log[S]; // Mix samples matrix
for(s in 1:S) y_log[s] = log(y[s] + 1);
}
parameters {
simplex[P] beta[S]; // coefficients for predictors
real<lower=0> sigma; // error scale
matrix[R,P] alpha; // Prior to a
}
transformed parameters{
vector[G] y_hat[S];
for(s in 1:S) y_hat[s] = x* beta[s];
}
model {
matrix[S,P] beta_hat;
// Regression
sigma ~ normal(0, 0.01);
// Dirichlet prior on proportions
alpha[1] ~ normal(0, 0.2);
if(R > 1) to_vector(alpha[2:R]) ~ normal(0, 0.2);
// Regression
for(s in 1:S) y_log[s] ~ student_t(8, log(y_hat[s]), sigma);
// Hypothesis testing
beta_hat = exp(X * alpha);
for(s in 1:S) beta[s] ~ dirichlet( to_vector(beta_hat[s]) );
}
```

P.S. I had to simplify the model I hope to not have left any incongruence

Thanks