Hi,

I am new to Stan. I created the following Beta-Binomial model for daily samples, which assumes the success rate of the Binomial distribution is sampled from a Beta distribution each day, and the mean of the Beta distribution is estimated using a logistic regression. I am trying to use that to estimate the success rate for multiple binomial distributions (so the mapping variable in the Stan code). The problem I encountered is with 4 MCMC chains, I always have one chain that takes much more time to finish than the other chains (more than x10 times) wh. I am wonder if this is a model specification issue and any way to improve that.

```
data {
int<lower=1> L;
int<lower=0> ref_block[L, 2];
int<lower=0> N;
int<lower=0> M;
int<lower=0> n[N];
int<lower=0> y[N];
matrix[N, M] X; // design matrix
int mapping[N];
}
transformed data {
int num_cell;
num_cell = max(mapping);
}
parameters {
// beta params
vector[M] beta;
vector<lower=0>[num_cell] phi;
real<lower=0> rho_sq[L];
real<lower=0, upper=1> theta[N];
}
transformed parameters {
vector[num_cell] mu; //the linear predictor
vector<lower=0>[num_cell] Alpha; //the first shape parameter for the beta distribution
vector<lower=0>[num_cell] Beta; //the second shape parameter for the beta distribution
for (nn in 1:N) {
mu[mapping[nn]] = inv_logit(X[nn, :] * beta); //using logit link
Alpha[mapping[nn]] = mu[mapping[nn]] * phi[mapping[nn]];
Beta[mapping[nn]] = (1 - mu[mapping[nn]]) * phi[mapping[nn]];
}
}
model {
for (nn in 1:N) {
y[nn] ~ beta_binomial(n[nn], Alpha[mapping[nn]], Beta[mapping[nn]]);
}
// Specify intercept priors
beta[1] ~ cauchy(0, 2.5);
for (l in 1:L) {
beta[(ref_block[l][1]+1):(ref_block[l][2]+1)] ~ normal(0, rho_sq[l]);
}
rho_sq ~ cauchy(0, 10);
phi ~ inv_gamma(1, 1);
}
generated quantities {
real<lower=0,upper=1> theta_pred[N];
for (nn in 1:N) {
theta_pred[nn] = beta_rng(Alpha[mapping[nn]], Beta[mapping[nn]]);
}
}
```