Using a metafor model object of class rma or rma.mv, a results table of class orchard, or a raw data.frame, the bubble_plot function creates a bubble plot from slope estimates or raw effect sizes. When a raw data.frame is provided, only the data points are plotted (no model fit lines). In cases when a model includes interaction terms, this function creates panels of bubble plots.
bubble_plot(
object,
mod,
group = NULL,
xlab = "Moderator",
ylab = "Effect size",
N = NULL,
alpha = 0.5,
cb = TRUE,
k = TRUE,
g = FALSE,
transfm = c("none", "tanh", "invlogit", "percent", "percentr"),
n_transfm = NULL,
est.lwd = 1,
ci.lwd = 0.5,
pi.lwd = 0.5,
est.col = "black",
ci.col = "black",
pi.col = "black",
point.size = c(1, 3.5),
legend.pos = c("top.left", "top.right", "bottom.right", "bottom.left", "top.out",
"bottom.out", "none"),
k.pos = c("top.right", "top.left", "bottom.right", "bottom.left", "none"),
condition.nrow = 2,
condition.order = NULL,
weights = "prop",
by = NULL,
at = NULL,
yi = NULL,
vi = NULL,
stdy = NULL
)Bubble plot
Model object of class rma, rma.mv, orchard table of model results, or a data.frame containing raw effect sizes.
The name of a continuous moderator, to be plotted on the x-axis of the bubble plot.
The grouping variable that one wishes to plot beside total effect sizes, k. This could be study, species, or any grouping variable one wishes to present sample sizes for. Not needed if an orchard_plot is provided with a mod_results object of class orchard.
Moderator label.
Effect size measure label.
The vector of sample size which an effect size is based on. Defaults to precision (the inverse of sampling standard error).
The level of transparency for pieces of fruit (effect size).
If TRUE, it uses a colourblind-friendly palette of 20 colours (do not make this TRUE, when colour = TRUE).
If TRUE, it displays k (number of effect sizes) on the plot.
If TRUE, it displays g (number of grouping levels for each level of the moderator) on the plot.
If set to "tanh", a tanh transformation will be applied to effect sizes, converting Zr to a correlation or pulling in extreme values for other effect sizes (lnRR, lnCVR, SMD). "invlogit" can be used to convert lnRR to the inverse logit scale. "percentr" can convert to the percentage change scale when using response ratios and "percent" can convert to the percentage change scale of an log transformed effect size. Defaults to "none".
The vector of sample sizes for each effect size estimate. This is used when transfm = "inv_ft". Defaults to NULL.
Size of the point estimate.
Size of the confidence interval.
Size of the prediction interval.
Colour of the point estimate.
Colour of the confidence interval.
Colour of the prediction interval.
Numeric vector of length 2, specifying the minimum and maximum point sizes for effect size bubbles. Defaults to c(1, 3.5). Useful for controlling bubble size in small figures.
Where to place the legend, or not to include a legend ("none").
The position of effect size number, k.
Number of rows to plot condition variable.
Order of the levels of the condition variable in the plot. Defaults to NULL.
How to marginalize categorical variables; used when one wants marginalised means. The default is weights = "prop", which weights means for moderator levels based on their proportional representation in the data. For example, if "sex" is a moderator, and males have a larger sample size than females, then this will produce a weighted average, where males are weighted more towards the mean than females. This may not always be ideal when, for example, males and females are typically roughly equally prevalent in a population. In cases such as these, you can give the moderator levels equal weight using weights = "equal".
Character vector indicating the name that predictions should be conditioned on for the levels of the moderator.
List of levels one wishes to predict at for the corresponding variables in by. Used when one wants marginalised means. This argument can also be used to suppress levels of the moderator when argument subset = TRUE. Provide a list as follows: list(mod = c("level1", "level2")).
Character string. The name of the effect size column in the data.frame. Only used when object is a data.frame.
Character string. The name of the sampling variance column in the data.frame. Only used when object is a data.frame.
Character string. The name of the study identifier column in the data.frame, used for computing k and g labels. Only used when object is a data.frame.
Shinichi Nakagawa - s.nakagawa@unsw.edu.au
Daniel Noble - daniel.noble@anu.edu.au
# \donttest{
data(lim)
lim[, "year"] <- as.numeric(lim$year)
lim$vi <- 1 / (lim$N - 3)
model <- metafor::rma.mv(
yi = yi, V = vi, mods = ~ Environment * year,
random = list(~ 1 | Article, ~ 1 | Datapoint), data = na.omit(lim)
)
test <- orchaRd::mod_results(
model, mod = "year", group = "Article",
data = lim, weights = "prop", by = "Environment")
orchaRd::bubble_plot(
test, mod = "year", group = "Article",
legend.pos = "top.left")
# Or just using model directly
orchaRd::bubble_plot(
model, mod = "year", legend.pos = "top.left",
group = "Article", weights = "prop",
by = "Environment")
# }
Run the code above in your browser using DataLab