An estimation plot has two key features.
It presents all datapoints as a swarmplot or sinaplot, which orders each point to display the underlying distribution.
It presents the effect size as a bootstrap 95 percent confidence interval on a separate but aligned axes.
Estimation plots emerge from estimation statistics, an intuitive framework that avoids the pitfalls of significance testing. It uses familiar statistical concepts: means, mean differences, and error bars. More importantly, it focuses on the effect size of one's experiment/intervention, as opposed to a false dichotomy engendered by P values. This function takes the output of the effect size functions and produces an estimation plot.
# S3 method for dabest_effsize
plot(
x,
...,
color.column = NULL,
palette = "Set1",
float.contrast = TRUE,
slopegraph = TRUE,
group.summaries = "mean_sd",
rawplot.type = c("swarmplot", "sinaplot"),
rawplot.ylim = NULL,
rawplot.ylabel = NULL,
rawplot.markersize = 2,
rawplot.groupwidth = 0.3,
effsize.ylim = NULL,
effsize.ylabel = NULL,
effsize.markersize = 4,
theme = ggplot2::theme_classic(),
tick.fontsize = 11,
axes.title.fontsize = 14,
show.legend = TRUE,
swarmplot.params = NULL,
sinaplot.params = NULL,
slopegraph.params = NULL
)
A ggproto
object. This object is actually
composed of two ggplot2
objects (one for the rawdata swarmplot or
slopegraph, another for the effect sizes and bootstrapped confidence
intervals). These are arranged in the desired configuration (whether as a
Gardner-Altman plot or a Cumming plot) by the
plot_grid()
function in the cowplot
package.
A dabest_effsize
object, generated by one of the
effect size functions currently available in
dabestr
.
Signature for S3 generic function.
default NULL
. This is a column in the data.frame
passed to the dabest
function. This column will be treated as a
factor and used to color the datapoints in the rawdata swarmplot.
default "Set1". Accepts any one of the RColorBrewer palettes,
or a vector of colors. Colors can be specified as RGB hexcode or as a named
color. See the "Palettes" section in scale_color_brewer for more on
palettes. To obtain all 657 named colors in R, enter colors()
at the
console.
default TRUE
. If idx
in the
dabest
object contains only 2 groups, float.contrast = TRUE
will plot the effect size and the bootstrap confidence interval in a
horizontally-aligned axes (also known as a
Gardner-Altman plot).
boolean, default TRUE
. If the dabest
object
contains paired comparisons, slopegraph = TRUE
will plot the rawdata
as a Tufte slopegraph.
"mean_sd", "median_quartiles", or NULL
. Plots
the summary statistics for each group. If 'mean_sd', then the mean and
standard deviation of each group is plotted as a gapped line beside each
group. If 'median_quartiles', then the median and 25th & 75th percentiles
of each group is plotted for each group as a gapped line. If
group.summaries = NULL
, the summaries are not shown.
default "beeswarm". Accepts either "beeswarm" or "sinaplot". See geom_quasirandom and geom_sina for more information.
default NULL
. Enter a custom y-limit for the
rawdata plot. Accepts a vector of length 2 (e.g. c(-50, 50)) that will be
passed along to coord_cartesian.
default NULL
. Accepts a string that is used to
label the rawdata y-axis. If NULL
, the column name passed to
y
is used.
default 2. This is the size (in points) of the dots used to plot the individual datapoints. There are 72 points in one inch. See this article for more info.
default 0.3. This is the maximum amount of spread (in the x-direction) allowed, for each group.
default NULL
. Enter a custom y-limit for the
effect size plot. This parameter is ignored if float.contrast =
TRUE
. Accepts a vector of length 2 (e.g. c(-50, 50)
) that will be
passed along to coord_cartesian.
default NULL
. Accepts a string that is used to
label the effect size y-axis. If NULL
, this axes will be labeled
"(un)paired <effect size>", where effect size is the
effect size function used to generate the
dabest_effsize
object currently being plotted.
default 4. This is the size (in points) of the dots used to indicate the effect size.
default theme_classic. This is the ggplot2
theme
that is used to style various elements of the estimation plot.
default 11. This controls the font size (in points) of all tick labels.
default 14. This determines the font size (in points) of the axes titles.
boolean, default TRUE
. If FALSE
, the color
legend will not be displayed, even if color.column
is supplied.
default NULL
. Supply list of keyword =
value
pairs to geom_quasirandom.
default NULL
. Supply list of keyword =
value
pairs to ggforce::geom_sina()
.
default NULL
. Supply list of keyword =
value
pairs to ggplot2
's
geom_line()
.
This controls the appearance of the lines plotted for a paired slopegraph.
Moving beyond P values: Data analysis with estimation graphics. Nature Methods 2019, 1548-7105. Joses Ho, Tayfun Tumkaya, Sameer Aryal, Hyungwon Choi, Adam Claridge-Chang
Loading data for effect size computation.
Effect size computation from the loaded data.
Run vignette("Using dabestr", package = "dabestr")
in the console to
read more about using parameters to control the plot features.
# Performing unpaired (two independent groups) analysis.
# We want to obtain the mean difference between the petal widths
# of setosa and versicolor species.
unpaired_mean_diff <- dabest(iris, Species, Petal.Width,
idx = c("setosa", "versicolor"),
paired = FALSE) %>%
mean_diff()
# Create a Gardner-Altman estimation plot.
plot(unpaired_mean_diff)
if (FALSE) {
# Comparing versicolor and virginica petal widths to setosa petal width.
shared_control_data <- dabeıst(iris, Species, Petal.Width,
idx = c("setosa", "versicolor", "virginica")) %>%
mean_diff()
# Create a Cumming estimation plot.
plot(shared_control_data)
}
Run the code above in your browser using DataLab