# Easy post-hoc tests when meta-analyzing with the metafor package in r

I am conducting meta-analysis using metafor in R. I would like to compare among 7 levels in a factor (i.e. different types of treatments).

fit <- rma (yi, vi, mods = type_of_treatment - 1, data = dat)
fit


I found several websites explaining how to compare among levels by using anova() (e.g., Post hoc analysis after meta regression & http://www.metafor-project.org/doku.php/tips:testing_factors_lincoms?s[]=anova); however, because I have seven levels (i.e. seven different types of treatments), doing comparisons by myself is pretty trouble same.

I tried glht() in the multcomp package, but the following command provides error.

summary(glht(fit, linfct = mcp(~type_of_treatment = "Tukey"))


I would really appreciate if you could let me know if there is any easy way to conduct a pairwise comparison among levels, like the glht() or emmeans() for lm.

You could use the contrMat() function. Something like this should work:
summary(glht(fit, linfct=cbind(contrMat(rep(1,7), type="Tukey"))), test=adjusted("none"))

You might want to consider an adjustment for multiple testing though. See help(summary.glht) for some options.