bubble_plot: bubble_plot

View source: R/bubble_plot.R

bubble_plotR Documentation

bubble_plot

Description

Using a metafor model object of class rma or rma.mv, or a results table of class orchard, the bubble_plot function creates a bubble plot from slope estimates. In cases when a model includes interaction terms, this function creates panels of bubble plots.

Usage

bubble_plot(
  object,
  mod,
  group = NULL,
  xlab = "Moderator",
  ylab = "Effect size",
  N = "none",
  alpha = 0.5,
  cb = TRUE,
  k = TRUE,
  g = FALSE,
  transfm = c("none", "tanh", "invlogit", "percent", "percentr"),
  est.lwd = 1,
  ci.lwd = 0.5,
  pi.lwd = 0.5,
  est.col = "black",
  ci.col = "black",
  pi.col = "black",
  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,
  weights = "prop",
  by = NULL,
  at = NULL,
  cond_levels = NULL
)

Arguments

object

Model object of class rma, rma.mv, or orchard table of model results

mod

The name of a continuous moderator, to be plotted on the x-axis of the bubble plot.

group

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.

xlab

Moderator label.

ylab

Effect size measure label.

N

The vector of sample size which an effect size is based on. Defaults to precision (the inverse of sampling standard error).

alpha

The level of transparency for pieces of fruit (effect size).

cb

If TRUE, it uses a colourblind-friendly palette of 20 colours (do not make this TRUE, when colour = TRUE).

k

If TRUE, it displays k (number of effect sizes) on the plot.

g

If TRUE, it displays g (number of grouping levels for each level of the moderator) on the plot.

transfm

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".

est.lwd

Size of the point estimate.

ci.lwd

Size of the confidence interval.

pi.lwd

Size of the prediction interval.

est.col

Colour of the point estimate.

ci.col

Colour of the confidence interval.

pi.col

Colour of the prediction interval.

legend.pos

Where to place the legend, or not to include a legend ("none").

k.pos

The position of effect size number, k.

condition.nrow

Number of rows to plot condition variable.

weights

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".

by

Character vector indicating the name that predictions should be conditioned on for the levels of the moderator.

at

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")).

cond_levels

Order of the levels of the condition variable in the order to plot. Defaults to NULL.

Value

Orchard plot

Author(s)

Shinichi Nakagawa - s.nakagawa@unsw.edu.au

Daniel Noble - daniel.noble@anu.edu.au

Examples

## Not run: 
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", data = lim, group = "Article",legend.pos = "top.left")
# Or just using model directly
orchaRd::bubble_plot(model, mod = "year", legend.pos = "top.left", data = lim, group = "Article", weights = "prop", by = "Environment")


## End(Not run)

daniel1noble/orchaRd documentation built on May 12, 2024, 7:46 a.m.