Hi, I’m trying to do something which I don’t know is possible (I’m not a very advanced user).

The model is hierarchical and consists of a set of equations, the key thing is that I want to use the sum of an estimated (right word?) variable in a function. I figured that writing separate loops could possibly work, but I really don’t know if this is doable, or if there is some other way of achieving the desired result.

This what I’m trying to do conceptually:

```
for (i in 1:N){
// a bunch of equations here that end with something like;
est_variable1[i] = beta * variable2[i];
}
for (i in 1:N){
// here I want to sum est_variable1 (well a little more complicated);
}
for (i in 1:N){
// here I want to use the sum of variable1 in a function
variable3[i] = variable4[i] / sum_of_est_variable1;
// some more functions
}
```

The model can be fitted with a solver, but I want to se how stable it is. So basically, can this be done at all in STAN, and can I do it in the way suggested?