binned_plot {esvis}R Documentation

Quantile-binned effect size plot

Description

Plots the effect size between focal and reference groups by matched (binned) quantiles (i.e., the results from binned_es), with the matched quantiles plotted along the x-axis and the effect size plotted along the y-axis. The intent is to examine how (if) the magnitude of the effect size varies at different points of the distributions. The mean differences within each quantile bin are divided by the overall pooled standard deviation for the two groups being compared.

Usage

binned_plot(
  data,
  formula,
  ref_group = NULL,
  qtile_groups = 3,
  es = "g",
  lines = TRUE,
  points = TRUE,
  shade = TRUE,
  shade_alpha = 0.4,
  rects = TRUE,
  rect_fill = "gray20",
  rect_alpha = 0.35,
  refline = TRUE,
  refline_col = "gray40",
  refline_lty = "solid",
  refline_lwd = 1.1
)

Arguments

data

The data frame to be plotted

formula

A formula of the type out ~ group where out is the outcome variable and group is the grouping variable. Note this variable can include any arbitrary number of groups. Additional variables can be included with + to produce separate plots by the secondary or tertiary variable of interest (e.g., out ~ group + characteristic1 + characteristic2). No more than two additional characteristics can be supplied at this time.

ref_group

Optional character vector (of length 1) naming the reference group. Defaults to the group with the highest mean score.

qtile_groups

The number of quantile bins to split the data by and calculate effect sizes. Defaults to 3 bins (lower, middle, upper).

es

The effect size to plot. Defaults to "g", in which case Hedge's g is plotted, which is better for small samples. At present, the only other option is "d" for Cohen's D.

lines

Logical. Should the PP Lines be plotted? Defaults to TRUE.

points

Logical. Should points be plotted for each qtiles be plotted? Defaults to TRUE.

shade

Logical. Should the standard errors around the effect size point estimates be displayed? Defaults to TRUE, with the uncertainty displayed with shading.

shade_alpha

Transparency level of the standard error shading. Defaults to 0.40.

rects

Logical. Should semi-transparent rectangles be plotted in the background to show the binning? Defaults to TRUE.

rect_fill

Color fill of rectangles to be plotted in the background, if rects == TRUE. Defaults to "gray20".

rect_alpha

Transparency level of the rectangles in the background when rects == TRUE. Defaults to 0.35.

refline

Logical. Defaults to TRUE. Should a diagonal reference line, representing the point of equal probabilities, be plotted?

refline_col

The color of the reference line. Defaults to "gray40"

refline_lty

Line type of the reference line. Defaults to "solid".

refline_lwd

Line width of the reference line. Defaults to 1.1.

Examples

# Binned Effect Size Plot: Defaults to Hedges' G
binned_plot(star, math ~ condition)
 
# Same plot, separated by sex
binned_plot(star, math ~ condition + sex)

# Same plot by sex and race
## Not run: 
  pp_plot(star, math ~ condition + sex + race)

## End(Not run)
## Evaluate with simulated data: Plot is most interesting when variance
# in the distributions being compared differ.

library(tidyr)
library(ggplot2)

# simulate data with different variances
set.seed(100)
common_vars <- data.frame(low  = rnorm(1000, 10, 1),
                        high = rnorm(1000, 12, 1),
                        vars = "common")
diff_vars <- data.frame(low  = rnorm(1000, 10, 1),
                      high = rnorm(1000, 12, 2),
                      vars = "diff")
d <- rbind(common_vars, diff_vars)

# Plot distributions 
d <- d %>% 
gather(group, value, -vars) 

ggplot(d, aes(value, color = group)) +
 geom_density() +
 facet_wrap(~vars)

# Note that the difference between the distributions depends on where you're 
# evaluating from on the x-axis. The binned plot helps us visualize this. 
# The below shows the binned plots when there is a common versus different
# variance

binned_plot(d, value ~ group + vars)   

[Package esvis version 0.3.1 Index]