Dear all,
I have a question on how to fit a random effects meta-analysis with three levels. I have observations (effect sizes), some of which are nested in papers, and for which I would like to estimate an overall distribution of effect sizes. An additional difficulty is that only some of the papers have several effect sizes, while the majority of papers report only one. Here is the model with only effect sizes and the overall distribution, which works fine:
data {
int<lower=1> N;
real g[N]; //this is the effect size
real se[N]; //this is the standard error
}
parameters {
real theta[N];//effect size parameters for each observation
real mu;
real<lower=0> tau;
}
model {
g ~ normal(theta, se);
theta ~ normal(mu, tau);
mu ~ normal(0,10);
tau ~ cauchy(0,5);
}
I have now tried for some time to model that the parameters theta could be themselves distributed with mean mu_p and standard deviation tau_p (defined at the paper level), with mu_p ~ normal(mu,tau), but I cannot seem to make this work. I have also played around with loops instead of the vector notation. While I at least got the program to work in that case, it is extremely slow and still does not give me what I want. What happens is that in some range I get the same effect size mu_p, while for some papers the estimation seems to work. Here is my code for that:
data {
int<lower=1> N;
real g[N];
real se[N];
int<lower=1,upper=N> study[N];
int<lower=1,upper=143> paper[N];
int<lower=0,upper=1> unique[N];//dummy indicating that the is only 1 effect in a paper
}
parameters {
vector[N] theta;
vector[143] mu_p;
real mu;"
vector<lower=0>[143] tau_p;
real<lower=0> tau;
}
model {
for (n in 1:N){
for (k in 1:143){
g[n] ~ normal(theta[study[n]],se[n]);
if (unique[n]==1) {
theta[study[n]] ~ normal(mu_p[paper[k]],se[n]);
} else {
theta[study[n]] ~ normal(mu_p[paper[k]],tau_p[paper[k]]);
}
mu_p[paper[k]] ~ normal(mu,tau);
}
}
mu ~ normal(0,10);
tau ~ cauchy(0,5);
}
Anybody out there who can help me with this?
Cheers,
Ferdinand