Skip to contents

Model description

The longitudinal meta-analysis model estimates how the treatment effect evolves over time across studies. Studies contribute multiple time-point observations; a parametric trajectory describes the population-level effect at each time, with study-level random intercepts capturing between-study heterogeneity.

This vignette documents the linear trajectory implementation. See Longitudinal meta-analysis for the statistical rationale and alternative trajectory forms.

Mathematical specification

Likelihood:

yitθit𝒩(θit,sit2) y_{it} \mid \theta_{it} \sim \mathcal{N}(\theta_{it},\, s_{it}^2)

Trajectory:

θit=(μ0+ui)+μ1tit+vit \theta_{it} = (\mu_0 + u_i) + \mu_1 \cdot t_{it} + v_{it}

Priors:

μ0𝒩(0,1),μ1𝒩(0,0.5),τuHalf-Cauchy(0,0.5),τvHalf-Cauchy(0,0.5) \mu_0 \sim \mathcal{N}(0,\, 1), \qquad \mu_1 \sim \mathcal{N}(0,\, 0.5), \qquad \tau_u \sim \text{Half-Cauchy}(0,\, 0.5), \qquad \tau_v \sim \text{Half-Cauchy}(0,\, 0.5)

Stan code (linear trajectory)

data {
  int<lower=1> N;
  int<lower=1> K;
  vector[N] y;
  vector<lower=0>[N] se;
  vector[N] time;
  array[N] int<lower=1> study;
}

parameters {
  real mu0;
  real mu1;
  real<lower=0> tau_u;
  real<lower=0> tau_v;
  vector[K] z_u;
  vector[N] z_v;
}

transformed parameters {
  vector[K] u = tau_u * z_u;
  vector[N] v = tau_v * z_v;
}

model {
  target += normal_lpdf(mu0   | 0, 1);
  target += normal_lpdf(mu1   | 0, 0.5);
  target += cauchy_lpdf(tau_u | 0, 0.5);
  target += cauchy_lpdf(tau_v | 0, 0.5);
  target += std_normal_lpdf(z_u);
  target += std_normal_lpdf(z_v);

  target += normal_lpdf(y | (mu0 + u[study]) + mu1 * time + v, se);
}

generated quantities {
  real b_Intercept = mu0;
  real b_time      = mu1;
}

How bayesma calls this model

bayesma(
  data,
  model_type = "random_effect",
  time_col   = "weeks",
  trajectory = "linear"
)

The time vector in the Stan data is constructed from data[[time_col]], centred at the median observation time for interpretability.

Parameterisation notes

  • uiu_i is a study-level random intercept (deviation from μ0\mu_0 at t=0t = 0).
  • vitv_{it} is a study-by-time residual capturing deviations from the linear trajectory within studies.
  • For the exponential decay trajectory, an additional parameter λ>0\lambda > 0 is required with a Half-Normal(0,1)\text{Half-Normal}(0, 1) prior.
  • b_time reports the posterior for the rate of change μ1\mu_1 per unit of the centred time variable.

Known sampling difficulties

The residual term vitv_{it} can be weakly identified when each study contributes only one or two time-points. In this case, fix τv=0\tau_v = 0 (drop the vitv_{it} term) to improve mixing. The model then reduces to a random-intercept longitudinal meta-analysis.