-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
127 lines (91 loc) · 5.86 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# esvis
R Package for effect size visualization and estimation.
[![Build Status](https://travis-ci.org/datalorax/esvis.svg?branch=master)](https://travis-ci.org/datalorax/esvis)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/datalorax/esvis?branch=master&svg=true)](https://ci.appveyor.com/project/datalorax/esvis)
[![codecov](https://codecov.io/gh/datalorax/esvis/branch/master/graph/badge.svg)](https://codecov.io/gh/datalorax/esvis)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/esvis)](https://cran.r-project.org/package=esvis)
This package is designed to help you very quickly estimate and visualize distributional differences by categorical factors (e.g., the effect of treatment by gender and income category). Emphasis is placed on evaluating distributional differences across the entirety of the scale, rather than only by measures of central tendency (e.g., means).
## Installation
Install directly from CRAN with
```{r cran_install, eval = FALSE}
install.packages("esvis")
```
Or the development version from GitHub with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("datalorax/esvis")
```
## Plotting methods
There are three primary data visualizations: (a) binned effect size plots, (b) probability-probability plots, and (c) empirical cumulative distribution functions. All plots use the [ggplot2](http://ggplot2.tidyverse.org) package and are fully manipulable after creation using standard ggplot commands (e.g., changing the theme, labels, etc.). These plots were all produced by first running `library(ggplot2); theme_set(theme_minimal())` to produce the plots with the minimal theme, but no theme structure is imposed on any of the plots.
### Binned ES Plot
At present, the binned effect size plot can only be produced with Cohen's *d*, although future development will allow the user to select the type of effect size. The binned effect size plot splits the distribution into quantiles specified by the user (defaults to lower, middle, and upper thirds), calculates the mean difference between groups within each quantile bin, and produces an effect size for each bin by dividing by the overall pooled standard deviation (i.e., not by quantile). For example
```{r theme_set, include = FALSE}
library(ggplot2)
library(esvis)
theme_set(theme_minimal())
```
```{r, binned_plot1, fig.width = 8}
library(esvis)
binned_plot(benchmarks, math ~ ell)
```
![](https://github.com/datalorax/esvis/raw/master/docs/README-binned_plot1-1.png)
Note that in this plot one can clearly see that the magnitude of the differences between the groups depends upon scale location, as evidence by the reversal of the effect (negative to positive) for the Non-ELL (non-English Language Learners) group. We could also change the reference group, change the level of quantile binning, and evaluate the effect within other factors. For example, we can look by season eligibility for free or reduced price lunch, with quantiles binning, and non-ELL students as the reference group with
```{r, binned_plot2, fig.width = 8}
binned_plot(benchmarks,
math ~ ell + frl + season,
ref_group = "Non-ELL",
qtile_groups = 5)
```
![](https://github.com/datalorax/esvis/raw/master/docs/README-binned_plot2-1.png)
The `ref_group` argument can also supplied as a formula.
### PP Plots
Probability-probability plot can be produced with a call to `pp_plot` and an equivalent argument structure. In this case, we're visualizing the difference in reading achievement by race/ethnicity by season.
```{r, pp_plot1, fig.width = 8}
pp_plot(benchmarks, reading ~ ethnicity + season)
```
![](https://github.com/datalorax/esvis/raw/master/docs/README-pp_plot1-1.png)
Essentially, the empirical cummulative distribution function (ECDF) for the reference group (by default, the highest performing group) is mapped against the ECDF for each corresponding group. The magnitude of the achievement gap is then displayed by the distance from the diagonal reference line, representing, essentially, the ECDF for the reference group.
By default, the area under the curve is shaded, which itself is an effect-size like measure, but this is also manipulable.
### ECDF Plot
Finally, the `ecdf_plot` function essentially dresses up the base `plot.ecdf` function, but also adds some nice referencing features through additional, optional arguments. Below, I have included the optional `hor_ref = TRUE` argument such that horizontal reference lines appear, relative to the cuts provided.
```{r, ecdf_plot, fig.width = 8}
ecdf_plot(benchmarks, math ~ season,
cuts = c(190, 200, 215))
```
![](https://github.com/datalorax/esvis/raw/master/docs/README-ecdf_plot-1.png)
These are the curves that go into the PP-Plot, but occasionally can be useful on their own.
## Estimation Methods
Compute effect sizes for all possible pairwise comparisons.
```{r, coh_d1}
coh_d(benchmarks, math ~ season + frl)
```
Or specify a reference group. In this case, I've used the formula-based interface, but a string vector specifying the specific reference group could also be supplied.
```{r, coh_d2}
coh_d(benchmarks,
math ~ season + frl,
ref_group = ~Fall + `Non-FRL`)
```
Notice that the reference to Non-FRL is wrapped in back-ticks, which should be used anytime there are spaces or other non-standard characters.
Other effect sizes are estimated equivalently. For example, compute *V* ([Ho, 2009](https://journals.sagepub.com/doi/10.3102/1076998609332755)) can be estimated with
```{r v}
v(benchmarks,
math ~ season + frl,
ref_group = ~Fall + `Non-FRL`)
```
or *AUC* with
```{r auc}
auc(benchmarks,
math ~ season + frl,
ref_group = ~Fall + `Non-FRL`)
```