I am having difficulty customizing my forest plot in Metafor, using R.
Specifically, I want to print a simple line beneath the plot, positioned to the left, that reads: 'RE model (Q = XX, df = XX, p = XX, I^2 = XX, tau^2 = XX)' or similar.
I have been following Wolfgang's instructions described here (https://www.metafor-project.org/doku.php/plots:forest_plot) - specifically using the code below. However, while the forest plot appears as expected in every other regard, the summary estimate of the RE model does not appear.
### Run RE model where yi=FishersZr and v=V
res <- rma(FishersZr, V, data = dat, slab = paste(Author, Year, sep = ", "), method = "REML")
### print results
res
### Create forest plot
forest(res)
### Add text with summary estimates for RE model
text(-16, -1, pos=4, cex=0.75, bquote(paste("RE Model (Q = ",
.(formatC(res$QE, digits=2, format="f")), ", df = ", .(res$k - res$p),
", p = ", .(formatC(res$QEp, digits=2, format="f")), "; ", I^2, " = ",
.(formatC(res$I2, digits=1, format="f")), "%)")))
I have tried experimenting with custom plot margins using the par() function, and defining the relevant values of the RE model (e.g., Q_value <- 28.22 and so on) and then attempting to print defined values, but this does not work either. No error messages appear. Rather, the forest plot remains unchanged, with no summary text appearing below. I have also tried inserting the summary estimate manually using:
mtext("Your Custom Text Here", side = 1, line = 5, adj = 0, cex = 0.8, font = 2)
But this does also not work. No error, but no change to the plot either. I have looked through multiple other questions posted on this site (e.g., here, here and here) but have not been able to apply answers to these to my problem successfully.
Apologies for asking as I am almost certain this is a simple problem and I am likely missing something very basic, but I don't have sufficient experience with R programming generally to work out what it is. I would be very grateful for any advice.