Hi all, I have been having problems fitting a model for a meta analysis of relative drug efficacy based on a literature review. I’ve tracked my issue down to a single sign change: my model contains a variant of the line

```
for (i in 1:n_i) {
eta[i] = mu[study[i]] - mean(mu);
}
```

And fails to fit (chains don’t converge, all \mu_i have the same (broad) posterior). *However*, if I change the above to

```
for (i in 1:n_i) {
eta[i] = mu[study[i]] + mean(mu);
}
```

Everything works fine. I’m sort of at a loss as to why; eta is subsequently constrained to lie in [0,1] by an `inv_logit`

function, so I don’t see why shifting it in a different direction fails. Below is the minimal model which exhibits the issue: I’ve replicated in both Rstan and pystan, so I don’t think it’s a problem with my set up. I’ve also included some simple data (in R) below so you can just copy-paste to run.

Help appreciated!

```
data {
// Constants
int<lower = 2> n_i;
// Data
int<lower = 1> study[n_i];
int<lower = 0> y[n_i];
int<lower = 1> n[n_i];
// Priors
real<lower = 0> prior_sd_mu;
}
transformed data {
int<lower = 1> n_s = max(study);
}
parameters {
vector[n_s] mu;
}
transformed parameters {
vector[n_i] eta;
vector[n_i] theta;
for (i in 1:n_i) {
eta[i] = mu[study[i]] - mean(mu);
}
// Logit model
theta = inv_logit(eta);
}
model {
// Priors
mu ~ normal(0, prior_sd_mu);
// Likelihood
y ~ binomial(n, theta);
}
```

```
test_data <- list( n = c(108, 55, 177, 183, 96, 349, 218, 221, 26, 28, 380, 127, 40,
33, 175, 176, 178, 173, 70),
n_i=19,
prior_sd_mu = 10000,
study = c(9, 9, 5, 5, 5, 4, 7, 7, 1, 1, 6, 6, 8, 8, 2, 2, 3, 3, 4),
y = c(53, 10, 98, 59, 14, 202, 56, 21, 6, 4, 89, 16, 4,
9, 77, 8, 97, 22, 3))
```