I'm working on a meta-analysis of prevalence data. The aim is to get estimates of prevalence at the country level. The main issue is that the disease is highly correlated with age, and the sample ages of included studies are highly heterogeneous. Only median age is available for most studies, so I can't use SMR-like tricks. I figured I could use meta-regression to solve this, including age as a fixed-effect and introducing study-level and country-level random-effects.

The idea (that I took from Fowkes et al) was to use this model to make country-specific predictions of prevalence for each 5-year age group from 15 to 60 (using the median age of the group), and to apply these predictions to the actual population size of each of those groups in the selected country, in order to obtain total infected population and to calculate age-adjusted prevalence in the 15-60 population from that.

I tried several ways to do this using R with packages meta and mgcv. I got some satisfying results, but I'm not that confident with my results and would appreciate some feedback.

First is some simulated data, then the description of my different approaches:


Standard random-effect meta-analysis with package meta.

I used metaprop() to get a first estimate of the prevalence in each country without taking age into account, and to obtain weights. As expected, heterogeneity was very high, so I used weights from the random-effects model.

 meta <- metaprop(event=n_events,n=n_total,byvar=country,sm="PLOGIT",method.tau="REML",data=data)

I used meta to get a first estimate of the prevalence without taking age into account, and to obtain weights. As expected, heterogeneity was very high, so I used weights from the random-effects model.

Generalized additive model to include age with package mgcv.

The gam() model parameters (k and sp) were chosen using BIC and GCV number (not shown here).

 model <- gam( cbind(n_events,n_total-n_events) ~ s(study_median_age,bs="cr",k=4,sp=2) + s(country,bs="re"), weights=weight, data=data, family="binomial"(link=logit), method="REML")
 plot(model,pages=1,residuals=T, all.terms=T, shade=T)

Predictions for each age group were obtained from this model as explained earlier. CI were obtained directly using predict.gam(), that uses the Bayesian posterior covariance matrix of the parameters. For exemple considering UK:

 plot(newdat$prev~newdat$study_median_age, type="l",ylim=c(0,.12))
 lines(newdat$CIinf~newdat$study_median_age, lty=2)
 lines(newdat$CIsup~newdat$study_median_age, lty=2)

The results were satisfying, representing the augmentation of the prevalence with advanced age, with coherent confidence intervals. I obtained a total prevalence for the country using the country population structure (not shown, I hope it is clear enough).

However, I figured I needed to include study-level random-effects since there was a high heterogeneity (even though I did not calculate heterogeneity after the meta-regression).

Introducing study-level random-effect with package gamm4.

Since mgcv models can't handle that much random-effect parameters, I had to switch to gamm4.

 model2 <- gamm4(cbind(n_events,n_total-n_events) ~ s(study_median_age,bs="cr",k=4) + s(country,bs="re"), random=~(1|id_study), data=data, weights=weight, family="binomial"(link=logit))
 plot(model2$gam,pages=1,residuals=T, all.terms=T, shade=T)

 plot(newdat$prev2~newdat$study_median_age, type="l",col="red",ylim=c(0,0.11))
 lines(newdat$CIinf2~newdat$study_median_age, lty=2,col="red")
 lines(newdat$CIsup2~newdat$study_median_age, lty=2,col="red")
 lines(newdat$prev~newdat$study_median_age, type="l",ylim=c(0,.12))
 lines(newdat$CIinf~newdat$study_median_age, lty=2)
 lines(newdat$CIsup~newdat$study_median_age, lty=2)

Since the study-level random effect was in the mer part of the fit, I didn't have to handle it.

As you can see, I obtain rather different results, with a much smoother relation between age and prevalence, and quite different confidence intervals. It is even more different in the full-data analysis, where the CI are much wider in the model including study-level RE, to the point it is sometimes almost uninformative (prevalence between 0 and 15%, but if it is the way it is...). Moreover, the study-level RE model seems to be more stable when outliers are excluded.

So, my questions are:

  • Did I properly extract the weights from the metaprop() function and used them further?
  • Did I properly built my gam() and gamm4() models? I read a lot about this, but I'm not used to this king of models.
  • Which of these models should I use?

I would really appreciate some help, since neither my teachers nor my colleagues could. It was a really harsh to conduct the systematic review, and very frustrating to struggle with the analysis... Thank you in advance!


1 Answer 1


I see your question is quite old, but still it might be worthwhile to try to answer, very humbly though.

First, I think you extracted correctly the weights from metaprop. Second, my impression (but I am not the ultimate expert) is that you built both your models correctly.

Third, I would consider reporting results from both models, but stick to the first model for the primary analysis and report the second mainly as sensitivity analysis.

In any case, thinking out the box, it will boil down to how many patients, studies, and study strata you are using for evidence synthesis.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.