Bayesian meta-analysis models including fixed effects, random effects, and network meta-analysis with Stan and JAGS implementations.
View on GitHubchoxos/BayesianAgent
bayesian-modeling
plugins/bayesian-modeling/skills/meta-analysis/SKILL.md
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/choxos/BayesianAgent/blob/main/plugins/bayesian-modeling/skills/meta-analysis/SKILL.md -a claude-code --skill meta-analysisInstallation paths:
.claude/skills/meta-analysis/# Meta-Analysis Models
## Fixed Effects Meta-Analysis
### Stan
```stan
data {
int<lower=0> K; // Number of studies
vector[K] y; // Effect estimates
vector<lower=0>[K] se; // Standard errors
}
parameters {
real theta; // Common effect
}
model {
theta ~ normal(0, 10);
y ~ normal(theta, se);
}
```
### JAGS
```
model {
for (i in 1:K) {
y[i] ~ dnorm(theta, prec[i])
prec[i] <- pow(se[i], -2)
}
theta ~ dnorm(0, 0.0001)
}
```
## Random Effects Meta-Analysis
### Stan (Non-centered, recommended)
```stan
data {
int<lower=0> K;
vector[K] y;
vector<lower=0>[K] se;
}
parameters {
real mu; // Overall mean
real<lower=0> tau; // Between-study SD
vector[K] eta; // Study effects (standardized)
}
transformed parameters {
vector[K] theta = mu + tau * eta;
}
model {
// Priors
mu ~ normal(0, 10);
tau ~ cauchy(0, 0.5); // Half-Cauchy
eta ~ std_normal();
// Likelihood
y ~ normal(theta, se);
}
generated quantities {
real theta_new = normal_rng(mu, tau); // Predictive
real I2 = square(tau) / (square(tau) + mean(square(se)));
}
```
### JAGS
```
model {
for (i in 1:K) {
y[i] ~ dnorm(theta[i], prec[i])
prec[i] <- pow(se[i], -2)
theta[i] ~ dnorm(mu, tau.theta)
}
mu ~ dnorm(0, 0.0001)
tau.theta <- pow(sigma.theta, -2)
sigma.theta ~ dunif(0, 10)
# Heterogeneity
tau2 <- pow(sigma.theta, 2)
}
```
## Binary Outcomes
### Stan (Log-Odds)
```stan
data {
int<lower=0> K;
array[K] int<lower=0> r1; // Events in treatment
array[K] int<lower=0> n1; // Total in treatment
array[K] int<lower=0> r2; // Events in control
array[K] int<lower=0> n2; // Total in control
}
parameters {
real d; // Overall log-OR
real<lower=0> tau;
vector[K] delta; // Study-specific log-OR
vector[K] mu; // Baseline log-odds
}
model {
d ~ normal(0, 10);
tau ~ cauchy(0, 0.5);
delta ~ normal(d, t