Radial (Galbraith) Plot Diagnostics in Metafor Package R
Introduction
In meta-analysis, outliers and influential studies can significantly impact the results and overall conclusions. The Galbraith plot is a diagnostic tool used to identify potential outliers or influential studies in a meta-analysis. This blog post will delve into the Radial (Galbraith) plot diagnostics in the Metafor package for R.
What is the Radial Plot?
The Radial plot, also known as the Galbraith plot, is a graphical representation of the lower and upper limits of the confidence interval for the estimated effect size. The plot is used to visualize the data points within the confidence interval and those that fall outside it. This allows researchers to identify potential outliers or influential studies that may be driving the heterogeneity or inconsistency observed in the meta-analysis results.
How to Create a Radial Plot
To create a radial plot, you need to first fit an equal-effects model using the rma() function from the Metafor package. The following code snippet demonstrates how to do this:
library(metafor)
# Fit equal-effects model
res <- rma(yi, vi, data = dat.hackshaw1998, method = "EE")
# Draw radial plot
radial(res)
In this example, the rma() function is used to fit an equal-effects model to the data in dat.hackshaw1998. The resulting object, res, is then passed to the radial() function to create the radial plot.
Customizing the Radial Plot
While creating a radial plot, it may be desirable to raise a warning if a study falls outside the confidence region. This can be achieved by modifying the radial.rma function.
Accessing the Confidence Limits
To access the lower and upper limits of the confidence interval, you need to look at the ll and ul components of the output. The ll component represents the lower limit, while the ul component represents the upper limit.
Modifying the Radial Plot Function
The following code snippet demonstrates how to modify the radial.rma function to raise a warning if a study falls outside the confidence region:
fix("radial.rma") # opens editor to change function locally
## now change the last lines:
ll <- -zcrit + xi * beta
ul <- zcrit + xi * beta
if (is.null(x$not.na.yivi)) {
invisible(data.frame(x = xi, y = zi, ids = x$ids[x$not.na],
slab = x$slab[x$not.na], ll, ul, stringsAsFactors = FALSE))
} else {
invisible(data.frame(x = xi, y = zi, ids = x$ids[x$not.na.yivi],
slab = x$slab[x$not.na.yivi], ll, ul, stringsAsFactors = FALSE))
}
# and call the function again
radial_data <- radial(res)
In this modified version of the radial.rma function, a warning is raised if the study falls outside the confidence region.
Filtering for Outliers
To filter for outliers, you can assign the output of the radial() function to a variable and then use data manipulation techniques to identify studies that fall outside the confidence interval.
# call the function again
radial_data <- radial(res)
# filter for y-values outside CI
outliers <- radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul]
In this example, the radial() function is called to create a data frame containing the confidence limits. The resulting data frame is then filtered to identify studies that fall outside the confidence interval.
Using Shiny to Display Outliers
To display outliers in an R-shiny app, you can use the following code snippet:
library(shiny)
# Define UI for application
ui <- fluidPage(
# Add plot output
plotOutput("plot_output")
)
# Define server function
server <- function(input, output) {
# Create reactive expression to generate data frame
observeEvent(radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul],
uiOutput("outlier_plot"))
# Return plot output
return(list(
plot_output = renderPlot({
# Plot outliers using base R plots
plot(radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul],
main = "Outliers",
xlab = "Study ID",
ylab = "Effect Size")
}),
outlier_plot = renderUI({
# Plot outliers using base R plots
plot(radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul],
main = "Outliers",
xlab = "Study ID",
ylab = "Effect Size")
})
))
}
# Run application
shinyApp(ui = ui, server = server)
In this code snippet, the observeEvent function is used to create a reactive expression that generates a data frame containing outliers. The resulting data frame is then passed to the renderPlot and renderUI functions to generate plots using base R graphics.
Conclusion
The Radial (Galbraith) plot is an essential tool for meta-analysis, allowing researchers to identify potential outliers or influential studies that may be driving the heterogeneity or inconsistency observed in the results. By modifying the radial.plot function and using data manipulation techniques, researchers can raise warnings if a study falls outside the confidence region and display outliers in an R-shiny app.
Code
library(metafor)
# Fit equal-effects model
res <- rma(yi, vi, data = dat.hackshaw1998, method = "EE")
# Draw radial plot
radial(res)
fix("radial.rma") # opens editor to change function locally
## now change the last lines:
ll <- -zcrit + xi * beta
ul <- zcrit + xi * beta
if (is.null(x$not.na.yivi)) {
invisible(data.frame(x = xi, y = zi, ids = x$ids[x$not.na],
slab = x$slab[x$not.na], ll, ul, stringsAsFactors = FALSE))
} else {
invisible(data.frame(x = xi, y = zi, ids = x$ids[x$not.na.yivi],
slab = x$slab[x$not.na.yivi], ll, ul, stringsAsFactors = FALSE))
}
# and call the function again
radial_data <- radial(res)
# filter for y-values outside CI
outliers <- radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul]
library(shiny)
# Define UI for application
ui <- fluidPage(
# Add plot output
plotOutput("plot_output")
)
# Define server function
server <- function(input, output) {
# Create reactive expression to generate data frame
observeEvent(radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul],
uiOutput("outlier_plot"))
# Return plot output
return(list(
plot_output = renderPlot({
# Plot outliers using base R plots
plot(radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul],
main = "Outliers",
xlab = "Study ID",
ylab = "Effect Size")
}),
outlier_plot = renderUI({
# Plot outliers using base R plots
plot(radial_data$y[radial_data$x > radial_data$ll | radial_data$x < radial_data$ul],
main = "Outliers",
xlab = "Study ID",
ylab = "Effect Size")
})
))
}
# Run application
shinyApp(ui = ui, server = server)
Last modified on 2023-08-19