Title: | Effect Size Estimation and Visualisation |
---|---|
Description: | An easy-to-use yet powerful system for plotting grouped data effect sizes. Various types of effect size can be estimated, then plotted together with a representation of the original data. Select from many possible data representations (box plots, violin plots, raw data points etc.), and combine as desired. 'Durga' plots are implemented in base R, so are compatible with base R methods for combining plots, such as 'layout()'. See Khan & McLean (2023) <doi:10.1101/2023.02.06.526960>. |
Authors: | Kawsar Khan [aut] |
Maintainer: | Jim McLean <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.0.9000 |
Built: | 2025-02-22 03:09:32 UTC |
Source: | https://github.com/khankawsar/estimationplot |
Measurements of the body size and mass for adult and juvenile males of Xanthagrion erythroneurum damselflies. In this species, juvenile males are coloured yellow and change to red upon sexual maturity.
damselfly
damselfly
A data frame with 77 observations and 3 variables.
length
Measured body length (mm) of damselflies
mass
Measured body mass (mg) of damselflies
maturity
Male age groups; adult
or juvenile
used for body size and weight measurements
Khan, M. K., & Herberstein, M. E. (2021). Male-male interactions select for conspicuous male coloration in damselflies. Animal Behaviour, 176, 157-166.
petunia, insulin.wide, insulin
DurgaPlot
with confidence bracketsBrackets are added to a DurgaPlot
that already exists. That means you
must ensure there is sufficient space for the brackets above the plot. To do
this, either specify ylim
to DurgaPlot
, or create a
large top margin (par(mar = c(...))
) and turn off the plot frame
(DurgaPlot(..., frame.plot = FALSE)
). In either case, experiment with
the values until the result is visually pleasing. The annotation can be drawn
into the margin as it will not be cropped.
DurgaBrackets( plot.stats, contrasts, labels = "level CI", br.lwd = NULL, br.col = NULL, br.lty = 1, lb.col = NULL, lb.font = NULL, lb.cex = 1, snap.to = 1, shorten = 1.5, tip.length = 2, data.gap = 2.5, vertical.gap = 1.3, text.pad = 1.5, round.fn = function(x) signif(x, 2), ... )
DurgaBrackets( plot.stats, contrasts, labels = "level CI", br.lwd = NULL, br.col = NULL, br.lty = 1, lb.col = NULL, lb.font = NULL, lb.cex = 1, snap.to = 1, shorten = 1.5, tip.length = 2, data.gap = 2.5, vertical.gap = 1.3, text.pad = 1.5, round.fn = function(x) signif(x, 2), ... )
plot.stats |
Object returned by the call to |
contrasts |
Set of contrasts (i.e. group comparisons) to be displayed as
brackets. Defaults to contrasts passed to |
labels |
Text to display above each bracket. May be NULL, otherwise one
of: |
br.col , br.lwd , br.lty
|
Graphical parameters (colour, line weight and
style) that control the bracket appearance - passed to
|
lb.col , lb.cex , lb.font
|
Graphical parameters (colour, scale and font)
that control the label appearance - passed to |
snap.to |
Snaps the base of the lowest brackets onto horizontal grid
lines separated by |
shorten |
Amount (mm) to shrink brackets at each end |
tip.length |
Length of bracket tips (mm). May be a vector with length 2; length of tip at groups 1 and 2 respectively |
data.gap |
Vertical distance (mm) between top-most data point and bottom of bracket |
vertical.gap |
Vertical distance (mm) between overlapping brackets |
text.pad |
Gap (mm) between bracket and text |
round.fn |
By default, numbers displayed as text are printed to 2
significant figures. To change this behaviour, set |
... |
Additional arguments passed to |
Default values for br.lwd
, br.col
, lb.col
and
lb.font
depend on the confidence intervals (CI) being plotted. If the
CI covers 0, brackets and text are grey. If the CI does not cover 0, text is
dark grey and bold, and brackets are dark grey with a line width of 2.
No return value. DurgaBrackets
is called for its side effect
of adding confidence brackets to the current plot.
d <- DurgaDiff(petunia, 1, 2) # Don't draw frame because brackets will appear in the upper margin p <- DurgaPlot(d, ef.size = FALSE, frame.plot = FALSE) # Add the brackets to the plot DurgaBrackets(p, lb.cex = 0.8) # Only draw brackets that do not include zero p <- DurgaPlot(d, ef.size = FALSE, frame.plot = FALSE) diffs <- Filter(function(pwes) (pwes$bca[4] > 0 || pwes$bca[5] < 0), p$es$group.differences) DurgaBrackets(p, contrasts = diffs)
d <- DurgaDiff(petunia, 1, 2) # Don't draw frame because brackets will appear in the upper margin p <- DurgaPlot(d, ef.size = FALSE, frame.plot = FALSE) # Add the brackets to the plot DurgaBrackets(p, lb.cex = 0.8) # Only draw brackets that do not include zero p <- DurgaPlot(d, ef.size = FALSE, frame.plot = FALSE) diffs <- Filter(function(pwes) (pwes$bca[4] > 0 || pwes$bca[5] < 0), p$es$group.differences) DurgaBrackets(p, contrasts = diffs)
Estimates differences between groups in preparation for plotting by
DurgaPlot
.
DurgaDiff(x, ...) ## Default S3 method: DurgaDiff( x, data.col, group.col, id.col, groups, contrasts = "*", effect.type = "mean", R = 1000, boot.params = list(), ci.conf = 0.95, boot.ci.params = list(), na.rm = FALSE, ... )
DurgaDiff(x, ...) ## Default S3 method: DurgaDiff( x, data.col, group.col, id.col, groups, contrasts = "*", effect.type = "mean", R = 1000, boot.params = list(), ci.conf = 0.95, boot.ci.params = list(), na.rm = FALSE, ... )
x |
A data frame (or similar) containing values to be compared, or a
formula (see |
... |
Ignored |
data.col |
Name (character) or index (numeric) of the column within
|
group.col |
Name or index of the column within |
id.col |
Specify for paired data/repeated measures/with-subject
comparisons only. Name or index of ID column for repeated measures/paired
data. Observations for the same individual must have the same ID. For
non-paired data, do not specify an |
groups |
Vector of group names. Defaults to all groups in |
contrasts |
Specify the pairs of groups to be compared. By default, all
pairwise differences are generated. May be a single string, a vector of
strings, or a matrix. Specify
|
effect.type |
Type of group difference to be estimated. Values cannot be abbreviated. See Details for further information. |
R |
The number of bootstrap replicates. |
boot.params |
Optional list of additional names parameters to pass to
the |
ci.conf |
Numeric confidence level of the required confidence interval,
e.g. |
boot.ci.params |
Optional list of additional names parameters to pass to
the |
na.rm |
a logical evaluating to TRUE or FALSE indicating whether NA
values should be stripped before the computation proceeds. If |
x
may be a formula; see DurgaDiff.formula
.
If x
is a data.frame
(or similar) it may be in either long or wide
format. In long format, one column (data.col
) contains the measurement or value to be
compared, and another column (group.col
) contains the group identity. Repeated
measures/paired data/within-subject comparisons in long format require a subject
identity column (id.col
).
Wide format contains different measurements in different columns of the same row, and
is well-suited for repeated measures/paired/within-subject comparison data. To pass
wide format data, do not specify the arguments data.col
or
group.col
. Instead, you must explicitly specify the groups to be
compared in the groups
argument. Each group must be the name of a
column in x
. For paired data, you may specify id.col
, although it is not
required, as wide format data is assumed to be paired. The id.col
can be a column
that already exists and uniquely identifies each specimen, or it can be the name of a
column to be created, in which case the specimen ID will be a generated integer sequence.
Unpaired data can be in wide format, but it is necessary to inform Durga by passing id.col = NULL
.
Wide format data will be internally converted to long format, then processing continues as
for long format input.
The pairs of groups to be compared are defined by the parameter
contrasts
. An asterisk ("*"
, the default) creates contrasts for
all possible pairs of groups. A single string has a format such as
"group1 - group2, group3 - group4"
. A single string such as ".-
control"
compares all groups against the "control"
group, i.e. the
"."
expands to all groups except the named group. A vector of strings
looks like c("group1 - group2", "group3 - group4")
. If a matrix is
specified, it must have a column for each contrast, with the first group in
row 1 and the second in row 2.
The effect.type
parameter determines the effect size measure to be
calculated. Our terminology generally follows Lakens (2013), with d meaning
a biased estimate and g meaning a bias-corrected estimate. Some writers
reverse this usage or use alternative terminology. Cumming (2012) recommends
always using a bias-corrected estimate (although bias
correction is unnecessary for large sample sizes).
Durga applies Hedges' exact method for bias correction.
The effect type we call
for unpaired data is called
by Delacre et al. (2021). For paired data, our
is
identical to
for unpaired data (Delacre et al. 2021); it is called
by Cumming (2012; equation 11.10). For further details, refer to Khan and McLean (2023).
The set of possible values for the effect.type
argument, and
their meanings, is described below.
Code | Label | Effect type | Standardiser |
mean |
|
Unstandardised difference of group means | NA |
cohens d |
|
Difference in means standardised by non-pooled average SD (Delacre et al. 2021) | |
hedges g |
|
Bias-corrected (Delacre et al. 2021) |
|
cohens d_s |
|
Difference in means standardised by the pooled standard deviation (Lakens 2013, equation 1) | |
hedges g_s |
|
Bias-corrected (Lakens 2013, equation 4) |
|
glass delta_pre |
|
Difference in means standardised by the standard deviation of the pre-measurement group (which is the 2nd group in a contrast). Lakens (2013) recommends using Glass's whenever standard deviations differ substantially between conditions |
|
glass delta_post |
|
Difference in means standardised by the standard deviation of the post-measurement group (which is the 1st group in a contrast) | |
Code | Label | Effect type | Standardiser |
mean |
|
Unstandardised mean of group differences | NA |
cohens d |
|
Similar to except that the normaliser is non-pooled average SD rather than mean SD, as recommended by Cummings (2012, eqn 11.9) |
|
hedges g |
|
Bias-corrected |
|
cohens d_z |
|
Mean of differences, standardised by the standard deviation of the differences, (Lakens 2013, equation 6). Cummings (2012) recommends against using , preferring |
|
hedges g_z |
|
Bias-corrected |
|
cohens d_av |
|
Difference in means standardised by the average standard deviation of the groups (Lakens 2013, equation 10) | |
hedges g_av |
|
Bias-corrected |
|
As a simple rule of thumb, if you want a standardised effect type and you
don't know which one to use, use "hedges g"
for either paired or unpaired data,
as it is recommended by Delacre et al., (2021) for unpaired data and cumming (2012)
for paired data.
Additional effect types can be applied by passing a function for
effect.type
. The function must accept two
parameters and return a single numeric value, the effect size.
Each parameter is a vector of values from one of the two groups to be
compared (group 2 and group 1).
Confidence intervals for the estimate are determined using bootstrap
resampling, using the adjusted bootstrap percentile (BCa) method (see
boot
and boot.ci
). Additional
arguments can be passed to the boot
(boot.ci
) by passing a named list of values as the
argument boot.params
(boot.ci.params
).
A DurgaDiff
object, which is a list containing:
group.statistics |
Matrix with a row for each group, columns
are: |
group.differences |
List of |
groups |
Vector of group names |
group.names |
Labels used to identify groups |
effect.type |
Value of |
effect.name |
Name of the effect type; may include formatting such as subscripts |
effect.name.print |
Text-only version of
|
data.col |
Value of |
data.col.name |
Name of the |
group.col |
Value of |
group.col.name |
Name of the |
id.col |
Value of |
paired.data |
|
data |
The input data frame ( |
call |
How this function was called |
A DurgaGroupDiff
object is a boot
object (as returned by
boot
) with added bootci
components (as returned
by boot.ci
) and components identifying the groups used
to estimate the difference. Particularly relevant members are:
t0 |
The observed value of the statistic |
bca[4] |
The lower endpoint of the confidence interval |
bca[5] |
The upper endpoint of the confidence interval |
groups |
The difference is estimated on |
Cumming, G. (2012). Understanding the new statistics : effect sizes, confidence intervals, and meta-analysis (1st ed.). New York: Routledge.
Delacre, M., Lakens, D., Ley, C., Liu, L., & Leys, C. (2021). Why Hedges' g* based on the non-pooled standard deviation should be reported with Welch's t-test. doi:10.31234/osf.io/tu6mp
Khan, M. K., & McLean, D. J. (2023). Durga: An R package for effect size estimation and visualisation. bioRxiv, 2023.2002.2006.526960. doi:10.1101/2023.02.06.526960
Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4. doi:10.3389/fpsyg.2013.00863
DurgaDiff.formula
, boot
,
boot.ci
, DurgaPlot
d <- DurgaDiff(insulin, "sugar", "treatment", "id") print(d) # Change group order and displayed group labels, reverse the # direction of one of the contrasts from the default d <- DurgaDiff(petunia, 1, 2, groups = c("Self-fertilised" = "self_fertilised", "Intercrossed" = "inter_cross", "Westerham-crossed" = "westerham_cross"), contrasts = c("Westerham-crossed - Self-fertilised", "Westerham-crossed - Intercrossed", "Intercrossed - Self-fertilised")) # Wide format data d <- DurgaDiff(insulin.wide, groups = c("sugar.before", "sugar.after"))
d <- DurgaDiff(insulin, "sugar", "treatment", "id") print(d) # Change group order and displayed group labels, reverse the # direction of one of the contrasts from the default d <- DurgaDiff(petunia, 1, 2, groups = c("Self-fertilised" = "self_fertilised", "Intercrossed" = "inter_cross", "Westerham-crossed" = "westerham_cross"), contrasts = c("Westerham-crossed - Self-fertilised", "Westerham-crossed - Intercrossed", "Intercrossed - Self-fertilised")) # Wide format data d <- DurgaDiff(insulin.wide, groups = c("sugar.before", "sugar.after"))
Estimates differences between groups in preparation for plotting by
DurgaPlot
. The formula interface allows the value and group
columns to be specified in a formula, which means, for example, that
transformation functions can be applied to columns.
## S3 method for class 'formula' DurgaDiff(x, data = NULL, id.col, ...)
## S3 method for class 'formula' DurgaDiff(x, data = NULL, id.col, ...)
x |
a formula, such as |
data |
a data.frame (or list) from which the variables in formula should be taken. |
id.col |
Specify for paired data/repeated measures/with-subject
comparisons only. Name or index of ID column for repeated measures/paired
data. Observations for the same individual must have the same ID. For
non-paired data, do not specify an |
... |
Arguments passed on to
|
Applies the formula, x
, and a data set, data
, to construct a
data frame that is then passed, with all remaining arguments, to the function
DurgaDiff.default
.
A DurgaDiff
object, which is a list containing:
group.statistics |
Matrix with a row for each group, columns
are: |
group.differences |
List of |
groups |
Vector of group names |
group.names |
Labels used to identify groups |
effect.type |
Value of |
effect.name |
Name of the effect type; may include formatting such as subscripts |
effect.name.print |
Text-only version of
|
data.col |
Value of |
data.col.name |
Name of the |
group.col |
Value of |
group.col.name |
Name of the |
id.col |
Value of |
paired.data |
|
data |
The input data frame ( |
call |
How this function was called |
A DurgaGroupDiff
object is a boot
object (as returned by
boot
) with added bootci
components (as returned
by boot.ci
) and components identifying the groups used
to estimate the difference. Particularly relevant members are:
t0 |
The observed value of the statistic |
bca[4] |
The lower endpoint of the confidence interval |
bca[5] |
The upper endpoint of the confidence interval |
groups |
The difference is estimated on |
Cumming, G. (2012). Understanding the new statistics : effect sizes, confidence intervals, and meta-analysis (1st ed.). New York: Routledge.
Delacre, M., Lakens, D., Ley, C., Liu, L., & Leys, C. (2021). Why Hedges' g* based on the non-pooled standard deviation should be reported with Welch's t-test. doi:10.31234/osf.io/tu6mp
Khan, M. K., & McLean, D. J. (2023). Durga: An R package for effect size estimation and visualisation. bioRxiv, 2023.2002.2006.526960. doi:10.1101/2023.02.06.526960
Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4. doi:10.3389/fpsyg.2013.00863
DurgaDiff.default
, boot
,
boot.ci
, DurgaPlot
d <- DurgaDiff(log(sugar) ~ treatment, insulin, id.col = "id") print(d)
d <- DurgaDiff(log(sugar) ~ treatment, insulin, id.col = "id") print(d)
Plot grouped data and effect size in base R, with control over a large range
of possible display formats and options. To plot your data, first calculate
group differences by calling DurgaDiff
, then pass the result to
DurgaPlot
. Because there are so many parameters to this
function, they are prefixed according to the component they affect. Hence,
for example, all parameters that affect box plots are prefixed with
box
.
DurgaPlot( es, contrasts, group.dx = 0, group.colour = "Set2", points = TRUE, points.method = c("quasirandom", "pseudorandom", "smiley", "maxout", "frowney", "minout", "tukey", "tukeyDense", "jitter", "overplot"), points.spread = ifelse(points.method == "jitter", 0.1, 0.3), points.dx = group.dx, points.adjust = 1, points.params = list(), violin = isFALSE(box) && isFALSE(bar), violin.shape = c("left-half", "right-half", "full"), violin.fill = TRUE, violin.params = list(), violin.adj = 1.5, violin.width = 0.35, violin.trunc = TRUE, violin.dx = group.dx, box = FALSE, box.fill = TRUE, box.outline = TRUE, box.notch = FALSE, box.params = list(boxwex = 0.8, staplewex = 0.5, outwex = 0.5), box.dx = group.dx, bar = FALSE, bar.fill = TRUE, bar.width = 0.8, bar.dx = group.dx, ef.size = TRUE, ef.size.position = c("right", "below"), ef.size.violin = TRUE, ef.size.violin.fill = TRUE, ef.size.violin.shape = c("right-half", "left-half", "full"), ef.size.violin.trunc = TRUE, ef.size.pch = 17, ef.size.cex = 1.5, ef.size.lty = 1, ef.size.lwd = 2, ef.size.ticks = NULL, ef.size.label = es$effect.name, ef.size.dx = 0, ef.size.adj.margin = TRUE, ef.size.top.pad = 2.5, ef.size.height = 0.35, ef.size.mean.line.dx = group.dx, ef.size.line.col = "grey50", ef.size.line.lty = ifelse(ef.size.position == "below", 3, 1), ef.size.line.lwd = 1, ef.size.params = list(), paired = es$paired.data, paired.lty = 1, paired.lwd = 1, central.tendency = isFALSE(box) && isFALSE(bar), central.tendency.type = c("mean", "median"), central.tendency.symbol = c("point", "segment"), central.tendency.width = violin.width, central.tendency.params = list(), central.tendency.dx = group.dx, error.bars = !isFALSE(central.tendency) || !isFALSE(bar), error.bars.type = c("CI", "SD", "SE"), error.bars.lty = 1, error.bars.lwd = 3, error.bars.cross.width = 0, x.axis = TRUE, x.axis.dx = group.dx, xlab = "", left.ylab = es$data.col.name, left.las = graphics::par("las"), add = FALSE, xlim, ylim, ... )
DurgaPlot( es, contrasts, group.dx = 0, group.colour = "Set2", points = TRUE, points.method = c("quasirandom", "pseudorandom", "smiley", "maxout", "frowney", "minout", "tukey", "tukeyDense", "jitter", "overplot"), points.spread = ifelse(points.method == "jitter", 0.1, 0.3), points.dx = group.dx, points.adjust = 1, points.params = list(), violin = isFALSE(box) && isFALSE(bar), violin.shape = c("left-half", "right-half", "full"), violin.fill = TRUE, violin.params = list(), violin.adj = 1.5, violin.width = 0.35, violin.trunc = TRUE, violin.dx = group.dx, box = FALSE, box.fill = TRUE, box.outline = TRUE, box.notch = FALSE, box.params = list(boxwex = 0.8, staplewex = 0.5, outwex = 0.5), box.dx = group.dx, bar = FALSE, bar.fill = TRUE, bar.width = 0.8, bar.dx = group.dx, ef.size = TRUE, ef.size.position = c("right", "below"), ef.size.violin = TRUE, ef.size.violin.fill = TRUE, ef.size.violin.shape = c("right-half", "left-half", "full"), ef.size.violin.trunc = TRUE, ef.size.pch = 17, ef.size.cex = 1.5, ef.size.lty = 1, ef.size.lwd = 2, ef.size.ticks = NULL, ef.size.label = es$effect.name, ef.size.dx = 0, ef.size.adj.margin = TRUE, ef.size.top.pad = 2.5, ef.size.height = 0.35, ef.size.mean.line.dx = group.dx, ef.size.line.col = "grey50", ef.size.line.lty = ifelse(ef.size.position == "below", 3, 1), ef.size.line.lwd = 1, ef.size.params = list(), paired = es$paired.data, paired.lty = 1, paired.lwd = 1, central.tendency = isFALSE(box) && isFALSE(bar), central.tendency.type = c("mean", "median"), central.tendency.symbol = c("point", "segment"), central.tendency.width = violin.width, central.tendency.params = list(), central.tendency.dx = group.dx, error.bars = !isFALSE(central.tendency) || !isFALSE(bar), error.bars.type = c("CI", "SD", "SE"), error.bars.lty = 1, error.bars.lwd = 3, error.bars.cross.width = 0, x.axis = TRUE, x.axis.dx = group.dx, xlab = "", left.ylab = es$data.col.name, left.las = graphics::par("las"), add = FALSE, xlim, ylim, ... )
es |
Data returned from a call to |
contrasts |
Set of contrasts (i.e. group comparisons) to be plotted.
Defaults to contrasts passed to |
group.dx |
Used to shift group centres horizontally. E.g.,
|
group.colour |
Colours to use for each group. Either an
|
points |
If not |
points.method |
Method used to avoid overplotting points. Use
|
points.spread |
Numeric value used to adjust the points scatter method
points horizontally (ignored if |
points.dx |
Horizontal shift to be applied to points in each group. |
points.adjust |
Adjust the bandwidth used to calculate kernel density when drawing points. Smaller values mean a tighter fit. |
points.params |
List of named parameters to pass on to
|
violin |
If not |
violin.shape |
Desired violin shape - left-half only ( |
violin.fill |
Colour used to fill violins. Specify |
violin.params |
Additional graphical parameters applied to drawing
violins. May include |
violin.adj |
Value used to control violin plot smoothness by adjusting
the kernel density bandwidth. Higher values produce a smoother plot.
Passed unchanged as the |
violin.width |
Width of maximum violin horizontal extents, as a proportion of the distance between groups. |
violin.trunc |
Numeric value that specifies what vertical proportion of the violin is truncated. |
violin.dx |
Horizontal shift to be applied to each violin. |
box |
If not |
box.fill |
Colour used to fill the bodies of the box-and-whisker plot. If FALSE or NA, bodies are not filled. |
box.outline |
If FALSE, don't draw outliers with the box plot. |
box.notch |
If TRUE, draws notches in the sides of the boxes. See
|
box.params |
List with additional graphical parameters to control the
box plot appearance. Many aspects of the plots can be controlled, e.g.
|
box.dx |
Horizontal shift to be applied to each box. |
bar |
If not |
bar.fill |
Colour used to fill bars. |
bar.width |
Width of bars. |
bar.dx |
Horizontal shift to be applied to each bar. |
ef.size |
If not |
ef.size.position |
Effect sizes are plotted to the right of the main
plot if there is only one effect size to plot and |
ef.size.violin |
If not |
ef.size.violin.fill |
Colour used to fill effect size violins. Default
is a transparent version of |
ef.size.violin.shape |
Shape of the effect size violin. One of
|
ef.size.violin.trunc |
If |
ef.size.pch |
Symbol to represent mean effect size. |
ef.size.cex |
Mean effect size symbol magnification (default is 1.5). |
ef.size.lty |
Line style for the effect size error bar. |
ef.size.lwd |
Line weight for the effect size error bar. |
ef.size.ticks |
Optional locations and labels for ticks on the effect
size y-axis. E.g. to interpret effect size using Cohen's default values,
specify |
ef.size.label |
Label to display on y-axis for effect size. |
ef.size.dx |
Horizontal shift to be applied to each contrast/effect
size. Unlike other |
ef.size.adj.margin |
If TRUE (the default), the right margin (if ES is
right) or bottom margin (if ES is below) is automatically increased to make
room to display the effect size or axis annotations. The margins are
restored before control returns from |
ef.size.top.pad |
Gap (in units of default character height scaled by
|
ef.size.height |
Height of the effect size plot region as a proportion of the main plot region. Only applies when effect size is positioned below. |
ef.size.mean.line.dx |
Horizontal shift to be applied to the start (i.e. left end) of the group mean horizontal lines when effect size is on the right. |
ef.size.line.col |
Colour of horizontal effect-size lines that depict group means if effect size is on the right, otherwise colour of line at y = 0. |
ef.size.line.lty |
Line style of horizontal effect-size lines. |
ef.size.line.lwd |
Line width of horizontal effect-size lines. |
ef.size.params |
List of graphical parameters to apply when drawing
effect
sizes. These parameters are passed to |
paired |
If not |
paired.lty |
Line style for pair lines. |
paired.lwd |
Line width for pair lines. |
central.tendency |
If not |
central.tendency.type |
Should the indicated measure of central tendency
be |
central.tendency.symbol |
Should central tendency be shown as a point or a horizontal line segment? |
central.tendency.width |
Width of the central tendency line segment. |
central.tendency.params |
Additional arguments to be passed to
|
central.tendency.dx |
Horizontal shift to apply to central tendency indicator and error bars. |
error.bars |
Should error bars be displayed? May be the colour to be used for error bars. |
error.bars.type |
Should error bars depict 95% confidence intervals of
the mean ( |
error.bars.lty |
Line style for error bars. |
error.bars.lwd |
Line width for error bars. |
error.bars.cross.width |
Length (in inches) of the horizontal crossbars at the ends of the error bars. If 0, no crossbar is drawn. |
x.axis |
if TRUE, display the x-axis ticks and labels. The effect of
|
x.axis.dx |
Horizontal shifts to be applied to each x-axis tick and label. |
xlab |
X axis label. |
left.ylab |
Left-hand y-axis label. |
left.las |
Orientation of axis labels on left-hand y-axis label (0 = parallel to axis, 1 = horizontal). |
add |
If TRUE, the effect size plot is added to the current plot. If FALSE, a new plot is created. |
xlim , ylim
|
If specified, overrides the default plot extents. |
... |
Additional arguments are passed on to the
|
Group data may be visualised in multiple ways: points
, violin
,
box
and bar
. Each visualisation type is controlled by a set of
parameters with the same prefix. To display a type, for example box plots,
specify box = TRUE
. Rather than box = TRUE
, you may specify a
colour (e.g. box \ "blue"
), which is used as the border/outline for
the boxes. You may also specify a vector of colours, one for each group. For
points
, you may specify a colour for each individual point. When
colours are not specified, they default to the group colours
(group.colour
).
Group data annotations are controlled with parameters central.tendency
and error.bars
. central.tendency
visually represents the mean
or median (central.tendency.type
) of each group, while
error.bars
are vertical bars showing the 95% CI of the mean, standard
deviation or standard error of the groups (error.bars.type
).
An effect size (for our purposes) is the difference in means between two
groups. Effect size display is controlled by ef.size
. The set of
effect sizes (aka "contrasts") to be plotted is controlled by the
contrasts
parameter. If a single effect size is displayed, it may be
positioned to the right of - or below - the main plot
(ef.size.position
). If more than one effect size is displayed, it must
be below the main plot. If below, an effect size is drawn underneath its
primary group. See DurgaBrackets
for a way to display multiple
effect sizes that would overlap if displayed as normal effect sizes.
Custom labels for individual effects can be specified as part of the
contrasts
parameter. If contrasts
is a named vector, the names
are used as contrast labels, e.g. contrasts = c("Adult change" = "adult
- control", "Juvenile change" = "juvenile - control")
. A more flexible
(although more advanced) method is to assign the label.plot
member of
a DurgaDiff
object within x
, see Examples for usage.
The contrasts
parameter may be a single string, a vector of strings,
or a matrix. A single string has a format such as "group1 - group2,
group3 - group4"
. A single asterisk, "*"
creates contrasts for all
possible pairs of groups. A single string such as ".- control"
compares all groups against the "control"
group, i.e. the "."
expands to all groups except the named group. A vector of strings looks like
c("group1 - group2", "group3 - group4")
. If a matrix is specified, it
must have a column for each contrast, with the first group in row 1 and the
second in row 2. See also the contrasts
parameter to
DurgaDiff
. It is an error to attempt to plot a contrast that
was not estimated by DurgaDiff
.
A list (returned invisibly) with 4 elements:
es |
Value of the |
extents |
Matrix with the x-axis locations and y-axis extents of each displayed group. |
plot.differences |
A list of the
displayed differences, as |
palette |
Vector of colours used by default for each group. |
Gardner, M. J., & Altman, D. G. (1986). Confidence intervals rather than P values: estimation rather than hypothesis testing. Br Med J (Clin Res Ed), 292(6522), 746-750. doi:10.1136/bmj.292.6522.746
Cumming, G. (2012). Understanding the new statistics : effect sizes, confidence intervals, and meta-analysis (1st edition ed.). New York: Routledge.
DurgaDiff
, DurgaBrackets
,
DurgaTransparent
, offsetX
, boxplot
,
bxp
d <- DurgaDiff(petunia, "height", "group") # Default plot DurgaPlot(d) # Boxplot with a single effect size plotted on the right DurgaPlot(d, contrasts = "westerham_cross - self_fertilised", box = TRUE, points = "black", points.params = list(cex = 0.8)) # Use confidence brackets to show all group differences p <- DurgaPlot(d, ef.size = FALSE, group.colour = "Set1", points = "black", points.method = "jitter", points.params = list(pch = 21), points.dx = 0.15, violin.dx = -0.05, violin = "black", violin.adj = 0.5, ylim = c(12, 75)) DurgaBrackets(p) # Adjust group names, contrasts d <- DurgaDiff(petunia, 1, 2, groups = c("self-fertilised" = "self_fertilised", "intercrossed" = "inter_cross", "Westerham-crossed" = "westerham_cross"), contrasts = c("Westerham-crossed - self-fertilised", "Westerham-crossed - intercrossed", "intercrossed - self-fertilised")) # Shift the 2nd effect size horizontally (Westerham-crossed - intercrossed) # so it doesn't overlap another DurgaPlot(d, ef.size.dx = c(0, -2, 0)) # Custom difference labels with italics d <- DurgaDiff(petunia, 1, 2) d$group.differences[[3]]$label.plot <- expression(italic("sp. 2")~"-"~italic("sp. 1")) d$group.differences[[2]]$label.plot <- expression(italic("sp. 3")~"-"~italic("sp. 1")) DurgaPlot(d)
d <- DurgaDiff(petunia, "height", "group") # Default plot DurgaPlot(d) # Boxplot with a single effect size plotted on the right DurgaPlot(d, contrasts = "westerham_cross - self_fertilised", box = TRUE, points = "black", points.params = list(cex = 0.8)) # Use confidence brackets to show all group differences p <- DurgaPlot(d, ef.size = FALSE, group.colour = "Set1", points = "black", points.method = "jitter", points.params = list(pch = 21), points.dx = 0.15, violin.dx = -0.05, violin = "black", violin.adj = 0.5, ylim = c(12, 75)) DurgaBrackets(p) # Adjust group names, contrasts d <- DurgaDiff(petunia, 1, 2, groups = c("self-fertilised" = "self_fertilised", "intercrossed" = "inter_cross", "Westerham-crossed" = "westerham_cross"), contrasts = c("Westerham-crossed - self-fertilised", "Westerham-crossed - intercrossed", "intercrossed - self-fertilised")) # Shift the 2nd effect size horizontally (Westerham-crossed - intercrossed) # so it doesn't overlap another DurgaPlot(d, ef.size.dx = c(0, -2, 0)) # Custom difference labels with italics d <- DurgaDiff(petunia, 1, 2) d$group.differences[[3]]$label.plot <- expression(italic("sp. 2")~"-"~italic("sp. 1")) d$group.differences[[2]]$label.plot <- expression(italic("sp. 3")~"-"~italic("sp. 1")) DurgaPlot(d)
Returns a transparent version of the specified colour(s).
DurgaTransparent(colour, transparency, relative = FALSE)
DurgaTransparent(colour, transparency, relative = FALSE)
colour |
The R colour (or colours) to be made transparent. May be
specified in any way recognised by |
transparency |
Transparency, from |
relative |
Determines what happens if |
A colour or colours that are transparent versions of colour
.
transparentPink <- DurgaTransparent("red", 0.8) transparentPink
transparentPink <- DurgaTransparent("red", 0.8) transparentPink
Selected results of experiments performed by Banting et al., (1922), testing whether insulin reduces blood sugar. Insulin was administered in rabbits and blood sugar was measured within three hours. Data collated from Table 1 and Table 2 of Banting et al., (1922). This data set is in long format. insulin.wide is an equivalent data set in wide format.
insulin
insulin
A data frame with 104 observations and 5 variables.
sugar
Measured blood sugar level (%)
treatment
Blood sugar measurements treatment group; before
or after
administering insulin
id
Identifier of individual being measured (not in original data set)
experimenter_time
Initial of researchers who performed the experiment and at what date
time
Time of blood sugar measurement; minutes after administration of insulin
Banting, F. G., Best, C. H., Collip, J. B., Macleod, J. J., & Noble, E. C. (1922). The effect of pancreatic extract (insulin) on normal rabbits. American Journal of Physiology-Legacy Content, 62(1), 162-176.
insulin.wide, petunia, damselfly
This data set contains the same information as insulin, however it is in wide format rather than long format. Refer to insulin for further details.
insulin.wide
insulin.wide
A data frame with 52 observations and 5 variables.
sugar.before
Blood sugar measurement before administering insulin (%)
sugar.after
Blood sugar measurement after administering insulin (%)
time
Time of blood sugar measurement; minutes after administration of insulin
experimenter
Initials of researcher who performed the experiment
date
Date of experiment (month day)
Banting, F. G., Best, C. H., Collip, J. B., Macleod, J. J., & Noble, E. C. (1922). The effect of pancreatic extract (insulin) on normal rabbits. American Journal of Physiology-Legacy Content, 62(1), 162-176.
Charles Darwin's experimental results on petunia plants to determine the difference of plant length between self fertilised and cross-fertilised, either with the same stock (inter-cross) or with a fresh stock (westerham-cross)
petunia
petunia
A data frame with 64 observations and 3 variables. Plants (self fertilised, inter-cross and westerham-cross) were measured to the tops of their stems when coming into flower. Data collated from Darwin (1877)
height
Measured height of plants (inches)
group
Plant fertilisation groups; westerham_cross
, inter_cross
or self_fertilised
pot_no
Identifier of pot number in which each plant was grown
Darwin, C. (1877). The effects of cross and self fertilisation in the vegetable kingdom. John Murray, Albemarle Street, London.
insulin, insulin.wide, damselfly