A forest plot is a graphical representation of the results of a meta-analysis, which is a statistical method for combining the results of multiple studies. It is used to visualize the overall effect size of the studies included in the meta-analysis, as well as the degree of heterogeneity (variability) among the studies. In this article, we will show you how to create a forest plot in R with a detailed implementation.
What is the forest plot?
In R, the forest plot is a type of graph to represent the meta-analyst. From left to right, a forest plot has the following components:
– Name of the studies and maybe contain the name of authors and public year
– Intervention group or treatment group
– Control group
– The relative risk is displayed by shapes to represent the confidence interval, weight of the studies,
– The relative risk is displayed by figures such as odd ratio, risk ratio, p-value
– The weight that displayed the effect size data of the studies
Forest plot in R
In this part, we will discover how to create a forest plot by the
forest() functions. For more details about the functions, please visit the official website to have an explanation. This tutorial only explains the relative parameters to create an example forest plot.
# Import the required library to use the metabin() function library(meta) # Create sample data set to do the meta analysis Country <- c("Banglades", "Gambla", "Jordan", "Peru", "Tanzania", "Maldives", "Timor", "Egypt", "Cambodia", "Kenya", "Nepal", "Pakistan", "Cameroon") Event1 <- c(4505, 1138, 7135, 7142, 4514, 1498, 3320, 7802, 4358, 11085, 1366, 2999, 4898) Total1 <- c(12019, 2517, 9929, 15961, 7899, 4133, 4866, 15222, 9805, 19503, 4314, 5094, 8531) Event2 <- c(2887, 3195, 319, 533, 1441, 1698, 2549, 3456, 1249, 2996, 3287, 5386, 1897) Total2 <- c(4060, 4328, 375, 659, 1822, 1901, 3103, 4548, 1918, 3425, 4485, 6871, 2492) # Create a data frame from vectors df <- data.frame(Country, Even1, Total1, Even2, Total2) # Produce a meta-analysis object by the metabin() function meta_analysis <- metabin(event.e = Even1, n.e = Total1, event.c = Even2, n.c = Total2, studlab = Country, data = df, sm = "OR") # Visualize the forest plot by the forest() function forest(meta_analysis)
In the example above, event1, total1, event2, total2 are the number of events and observations in the treatment group and the number of events and observations in the control group, respectively. The studlab parameter means study label. In the example, “Country” is considered as a study and mapped to the parameters. The data parameter is pointed to the data frame that stores data, and the sm parameter is used to determine the measure of the studies.
Finally, the meta-object is passed to the forest() function to create a forest plot graph.
In summary, the forest plot is a graph with statistical fields to display a meta-analysis of relative studies. The forest plot is helpful because we can see the heterogeneity, pooled result, and publication bias.
Maybe you are interested:
- The Normal Probability Plot In R: How To Plot
- Density And Histogram In R
- append To List R: How To Add Elements To The List in R
My name is Robert Collier. I graduated in IT at HUST university. My interest is learning programming languages; my strengths are Python, C, C++, and Machine Learning/Deep Learning/NLP. I will share all the knowledge I have through my articles. Hope you like them.
Name of the university: HUST
Programming Languages: Python, C, C++, Machine Learning/Deep Learning/NLP