Hi,

I am fitting a multilevel model to a collection of J curves with total N data points. I have a group level predictor grp_level_x for each of the J curves.

And I am fitting the following functional form:

y = (A*((x-B)/(100-B))^(-n))

The following stan code runs very slow and I am unable to run it long enough to see if this works. I had implemented an unpooled version before and that gave me reasonable results so now I was trying to get a multilevel model working. I am relatively new to stan so any help is appreciated. Thanks,

```
data {
int<lower=4> N;
int<lower=0> J;
vector[N] y;
vector[N] x;
int curveId[N];
vector[J] grp_level_x;
}
transformed data{
}
parameters {
vector<lower = 0.25,upper=5>[J] n;
vector<lower=0>[J] A;
vector[J] B;
real<lower=0> eps;
// B model
real alpha_B;
real beta_B;
real<lower=0> eps_B;
// n model
real alpha_n;
real beta_n;
real<lower=0> eps_n;
// A model
real alpha_A;
real beta_A;
real<lower=0> eps_A;
}
transformed parameters {
}
model {
vector[N] y_hat;
for (i in 1:N){
y_hat[i] = (A[curveId[i]]*((x[i] - B[curveId[i]])/(100. - B[curveId[i]]))^(-n[curveId[i]]));
}
for (j in 1:J){
B[j] ~ lognormal(alpha_B + beta_B*grp_level_x[j],eps_B);
n[j] ~ lognormal(alpha_n + beta_n*grp_level_x[j],eps_n)T[0.25,10];
A[j] ~ lognormal(alpha_A + beta_A*grp_level_x[j],eps_A);
}
y ~ normal(y_hat,eps);
}
```