Trouble with non-central parameterization in meta-analysis

Dear All.

I’m trying to build a random effect meta-analytic model using rstan. (I’m actually doing this not for MA, but for data that described ratings given by 20-25 raters on open-ended answers of other participants, and want to account for the fact the the mean rating is not the true state of the original participants, but an estimate).

Here is the model:

int<lower=0> N; //number of data points
vector[N] y; //effect size
vector[N] P; //effect size variance

real<lower=0> sigmaRes; //true variance
vector[N] eta;

transformed parameters{
real mu;
vector[N] Y;

for (i in 1:N){



I get the following error:
Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Location parameter[1] is nan, but must be finite! (in ‘model1e087e7d5467_fae42cbcc023f3e79b89081a16a7be8f’ at line 26)

Now, when using a central parameterization, this basic model works, but as soon as I start adding random intercepts and slopes (i.e. by making mu -> mu[i] and specifying it as a linear combination of parameters, as done in a multilevel model) - I get bfmi warnings, and tree_depth issues. So I try non-central parameterization.

Thanks a lot in advance,

mu is undefined in the model so Y is undefined, which is also a location parameter, so you get the error.

Thanks for the response!
I’ve tried to add a prior for mu:
mu~normal(50,100); (The scale is 0-100),

but got an error:

Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must not be nan! (in ‘model1da06055fdf_6baf8af08d9ec2d712ad106daea3fa24’ at line 25)

Any ideas?

The tilde doesn’t assign a value to mu. What is mu supposed to be in this model?

Oh. Sorry for not clearing this up. Mu is supposed to be the estimate of the average effect (if this is a meta-analysis). yi is the observed effects, and P is the se’s. Yi are the studies’ true effects, and they are distributed around an average effect mu.

Sounds like you should make it a parameter then.

Oh… interesting. It was a transformed parameter before, because in the full model I’ve added a random effect:
But at least it works not when making it a parameter (rather than transformed one). So Thanks a lot for this!
I’m not sure I understand why it works as a parameter but not as a transformed parameter. Also - any way to add a linear model (random effects and potential fixed effects) to mu without making it a transformed parameter?

Thanks a lot!

You might want to read again the manual sections that describe the
different blocks. It confused me for a while too but its one of tree
things that makes the language more expressive.

Parameters are provided by initialization and then by the sampling algorithm. Transformed parameters are defined as functions of other parameters (and data).