Home > Net >  How to create timberplots in R
How to create timberplots in R

Time:05-20

i am looking for a way to display estimates of a meta-analysis with lots of comparisons in a wide format instead of a forestplot. I came across a timberplot as displayed in this publication in figure 1: enter image description here


EDIT

With the sample data, we can now do the following:

  1. Make the papers a factor variable, with the ordering of the factor being from the lowest to highest effect size
  2. Add upper and lower columns representing one standard error above and one standard error below the effect size. If you want this to be a 95% confidence interval instead, do effect size /- 1.96 times the standard error.

First, we need to make sure every paper is uniquely identified. At the moment, your sample data contains two different papers with the same name (Zhang 2016), so we need to change one of them to mark it as unique:

df$Author[12] <- "Zhang (b) 2016"

Now let's get the papers arranged by effect size, and add our lower and upper bounds for each paper:

df$Author <- factor(df$Author, df$Author[order(df$Effect.size)])
df$lower <- df$Effect.size - df$Standard.error
df$upper <- df$Effect.size   df$Standard.error

The plot itself is then just:

ggplot(df, aes(Author, Effect.size))  
  geom_point()  
  geom_linerange(aes(ymin = lower, ymax = upper))  
  geom_hline(yintercept = mean(df$Effect.size), linetype = 2)  
  annotate(geom = 'text', x = 1, y = mean(df$Effect.size), vjust = -0.5,
           label = paste('Mean =', round(mean(df$Effect.size), 1)), hjust = 0)  
  theme_light()  
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

enter image description here

  • Related