From 6f1cbdde84a6ed1ec316cab4e1f69f2bc3cecdca Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Fri, 19 Jun 2020 11:05:54 -0700 Subject: [PATCH 01/28] write out iris in favor of gss --- CRAN-RELEASE | 2 - tests/figs/deps.txt | 2 +- .../ci-both-fill.svg | 72 +- .../ci-both-nofill.svg | 70 +- .../ci-extra-aes-1.svg | 66 +- .../ci-extra-aes-2.svg | 66 +- .../ci-null-endpoints.svg | 60 +- .../shade-confidence-interval/ci-sim-fill.svg | 66 +- .../ci-sim-nofill.svg | 64 +- tests/figs/shade-p-value/pval-both-both.svg | 274 +++---- .../figs/shade-p-value/pval-both-corrupt.svg | 266 +++---- tests/figs/shade-p-value/pval-both-left.svg | 270 +++---- tests/figs/shade-p-value/pval-both-null.svg | 266 +++---- tests/figs/shade-p-value/pval-both-right.svg | 270 +++---- .../shade-p-value/pval-direction-both.svg | 268 +++---- .../shade-p-value/pval-direction-left.svg | 264 +++---- .../shade-p-value/pval-direction-right.svg | 264 +++---- tests/figs/shade-p-value/pval-extra-aes-1.svg | 268 +++---- tests/figs/shade-p-value/pval-extra-aes-2.svg | 268 +++---- tests/figs/shade-p-value/pval-extra-aes-3.svg | 268 +++---- .../figs/shade-p-value/pval-null-obs-stat.svg | 60 +- tests/figs/shade-p-value/pval-sim-both.svg | 268 +++---- tests/figs/shade-p-value/pval-sim-corrupt.svg | 260 +++---- tests/figs/shade-p-value/pval-sim-left.svg | 264 +++---- tests/figs/shade-p-value/pval-sim-null.svg | 260 +++---- tests/figs/shade-p-value/pval-sim-right.svg | 264 +++---- tests/figs/shade-p-value/pval-theor-both.svg | 4 +- tests/figs/shade-p-value/pval-theor-left.svg | 2 +- tests/figs/shade-p-value/pval-theor-right.svg | 2 +- tests/figs/visualize/ci-vis.svg | 74 +- tests/figs/visualize/df-obs-stat-1.svg | 258 +++---- tests/figs/visualize/df-obs-stat-2.svg | 258 +++---- tests/figs/visualize/method-both.svg | 80 +-- tests/figs/visualize/vis-both-both-1.svg | 266 +++---- tests/figs/visualize/vis-both-both-2.svg | 262 +++---- tests/figs/visualize/vis-both-left-1.svg | 260 +++---- tests/figs/visualize/vis-both-left-2.svg | 276 +++---- tests/figs/visualize/vis-both-none-1.svg | 58 +- tests/figs/visualize/vis-both-none-2.svg | 66 +- tests/figs/visualize/vis-both-right-1.svg | 271 ++++--- tests/figs/visualize/vis-both-right-2.svg | 277 ++++---- .../visualize/vis-no-hypothesize-both.svg | 76 +- .../figs/visualize/vis-no-hypothesize-sim.svg | 64 +- tests/figs/visualize/vis-sim-both-1.svg | 271 +++---- tests/figs/visualize/vis-sim-both-2.svg | 75 +- tests/figs/visualize/vis-sim-left-1.svg | 266 +++---- tests/figs/visualize/vis-sim-none-1.svg | 60 +- tests/figs/visualize/vis-sim-right-1.svg | 262 +++---- tests/figs/visualize/vis-theor-both-1.svg | 234 +++--- tests/figs/visualize/vis-theor-both-2.svg | 346 ++++++++- tests/figs/visualize/vis-theor-left-1.svg | 672 +++++++++++++----- tests/figs/visualize/vis-theor-none-2.svg | 30 +- tests/figs/visualize/vis-theor-none-3.svg | 32 +- tests/figs/visualize/vis-theor-right-1.svg | 666 ++++++++++++----- tests/testthat/helper-data.R | 42 +- tests/testthat/test-aliases.R | 10 +- tests/testthat/test-calculate.R | 399 +++++------ tests/testthat/test-get_confidence_interval.R | 8 +- tests/testthat/test-get_p_value.R | 12 +- tests/testthat/test-print.R | 4 +- .../testthat/test-shade_confidence_interval.R | 34 +- tests/testthat/test-shade_p_value.R | 68 +- tests/testthat/test-visualize.R | 249 +++---- tests/testthat/test-wrappers.R | 198 +++--- 64 files changed, 6221 insertions(+), 5061 deletions(-) delete mode 100644 CRAN-RELEASE diff --git a/CRAN-RELEASE b/CRAN-RELEASE deleted file mode 100644 index e2c0a87a..00000000 --- a/CRAN-RELEASE +++ /dev/null @@ -1,2 +0,0 @@ -This package was submitted to CRAN on 2020-06-13. -Once it is accepted, delete this file and tag the release (commit 3d0d93ed59). diff --git a/tests/figs/deps.txt b/tests/figs/deps.txt index 0f64e23e..fa7c5968 100644 --- a/tests/figs/deps.txt +++ b/tests/figs/deps.txt @@ -1,3 +1,3 @@ - vdiffr-svg-engine: 1.0 -- vdiffr: 0.3.1 +- vdiffr: 0.3.2 - freetypeharfbuzz: 0.2.5 diff --git a/tests/figs/shade-confidence-interval/ci-both-fill.svg b/tests/figs/shade-confidence-interval/ci-both-fill.svg index 10b47360..b6ac21f0 100644 --- a/tests/figs/shade-confidence-interval/ci-both-fill.svg +++ b/tests/figs/shade-confidence-interval/ci-both-fill.svg @@ -19,25 +19,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -45,21 +45,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-confidence-interval/ci-both-nofill.svg b/tests/figs/shade-confidence-interval/ci-both-nofill.svg index 6946f438..034d716f 100644 --- a/tests/figs/shade-confidence-interval/ci-both-nofill.svg +++ b/tests/figs/shade-confidence-interval/ci-both-nofill.svg @@ -19,24 +19,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -44,21 +44,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-confidence-interval/ci-extra-aes-1.svg b/tests/figs/shade-confidence-interval/ci-extra-aes-1.svg index 8d23ae59..1a5e24cb 100644 --- a/tests/figs/shade-confidence-interval/ci-extra-aes-1.svg +++ b/tests/figs/shade-confidence-interval/ci-extra-aes-1.svg @@ -19,24 +19,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -44,19 +44,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-confidence-interval/ci-extra-aes-2.svg b/tests/figs/shade-confidence-interval/ci-extra-aes-2.svg index f1e14ffa..cf6c56ee 100644 --- a/tests/figs/shade-confidence-interval/ci-extra-aes-2.svg +++ b/tests/figs/shade-confidence-interval/ci-extra-aes-2.svg @@ -19,24 +19,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -44,19 +44,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-confidence-interval/ci-null-endpoints.svg b/tests/figs/shade-confidence-interval/ci-null-endpoints.svg index 7de0f2f0..371974dc 100644 --- a/tests/figs/shade-confidence-interval/ci-null-endpoints.svg +++ b/tests/figs/shade-confidence-interval/ci-null-endpoints.svg @@ -19,21 +19,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -41,19 +41,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-confidence-interval/ci-sim-fill.svg b/tests/figs/shade-confidence-interval/ci-sim-fill.svg index e45e0701..084cfee7 100644 --- a/tests/figs/shade-confidence-interval/ci-sim-fill.svg +++ b/tests/figs/shade-confidence-interval/ci-sim-fill.svg @@ -19,24 +19,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -44,19 +44,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-confidence-interval/ci-sim-nofill.svg b/tests/figs/shade-confidence-interval/ci-sim-nofill.svg index 201cb925..d0f5d21c 100644 --- a/tests/figs/shade-confidence-interval/ci-sim-nofill.svg +++ b/tests/figs/shade-confidence-interval/ci-sim-nofill.svg @@ -19,23 +19,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -43,19 +43,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-both-both.svg b/tests/figs/shade-p-value/pval-both-both.svg index a4dc93a4..7231a314 100644 --- a/tests/figs/shade-p-value/pval-both-both.svg +++ b/tests/figs/shade-p-value/pval-both-both.svg @@ -19,126 +19,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -146,21 +146,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-p-value/pval-both-corrupt.svg b/tests/figs/shade-p-value/pval-both-corrupt.svg index f186d61e..4169a5c0 100644 --- a/tests/figs/shade-p-value/pval-both-corrupt.svg +++ b/tests/figs/shade-p-value/pval-both-corrupt.svg @@ -19,122 +19,122 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -142,21 +142,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-p-value/pval-both-left.svg b/tests/figs/shade-p-value/pval-both-left.svg index 839d03a3..5be5fd38 100644 --- a/tests/figs/shade-p-value/pval-both-left.svg +++ b/tests/figs/shade-p-value/pval-both-left.svg @@ -19,124 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -144,21 +144,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-p-value/pval-both-null.svg b/tests/figs/shade-p-value/pval-both-null.svg index f186d61e..4169a5c0 100644 --- a/tests/figs/shade-p-value/pval-both-null.svg +++ b/tests/figs/shade-p-value/pval-both-null.svg @@ -19,122 +19,122 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -142,21 +142,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-p-value/pval-both-right.svg b/tests/figs/shade-p-value/pval-both-right.svg index 679f1d1d..ffd9d52d 100644 --- a/tests/figs/shade-p-value/pval-both-right.svg +++ b/tests/figs/shade-p-value/pval-both-right.svg @@ -19,124 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -144,21 +144,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - - - --2 -0 -2 + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/shade-p-value/pval-direction-both.svg b/tests/figs/shade-p-value/pval-direction-both.svg index e57c1def..20d28e6c 100644 --- a/tests/figs/shade-p-value/pval-direction-both.svg +++ b/tests/figs/shade-p-value/pval-direction-both.svg @@ -19,125 +19,125 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,19 +145,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-direction-left.svg b/tests/figs/shade-p-value/pval-direction-left.svg index ff9898e2..3a24bb7d 100644 --- a/tests/figs/shade-p-value/pval-direction-left.svg +++ b/tests/figs/shade-p-value/pval-direction-left.svg @@ -19,123 +19,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,19 +143,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-direction-right.svg b/tests/figs/shade-p-value/pval-direction-right.svg index 69b8c77f..a4697107 100644 --- a/tests/figs/shade-p-value/pval-direction-right.svg +++ b/tests/figs/shade-p-value/pval-direction-right.svg @@ -19,123 +19,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,19 +143,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-extra-aes-1.svg b/tests/figs/shade-p-value/pval-extra-aes-1.svg index 4c8014d0..5044f7db 100644 --- a/tests/figs/shade-p-value/pval-extra-aes-1.svg +++ b/tests/figs/shade-p-value/pval-extra-aes-1.svg @@ -19,125 +19,125 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,19 +145,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-extra-aes-2.svg b/tests/figs/shade-p-value/pval-extra-aes-2.svg index ab9e8d9b..14fa7823 100644 --- a/tests/figs/shade-p-value/pval-extra-aes-2.svg +++ b/tests/figs/shade-p-value/pval-extra-aes-2.svg @@ -19,125 +19,125 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,19 +145,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-extra-aes-3.svg b/tests/figs/shade-p-value/pval-extra-aes-3.svg index a6093a44..bedc1738 100644 --- a/tests/figs/shade-p-value/pval-extra-aes-3.svg +++ b/tests/figs/shade-p-value/pval-extra-aes-3.svg @@ -19,125 +19,125 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,19 +145,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-null-obs-stat.svg b/tests/figs/shade-p-value/pval-null-obs-stat.svg index 7de0f2f0..371974dc 100644 --- a/tests/figs/shade-p-value/pval-null-obs-stat.svg +++ b/tests/figs/shade-p-value/pval-null-obs-stat.svg @@ -19,21 +19,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -41,19 +41,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-sim-both.svg b/tests/figs/shade-p-value/pval-sim-both.svg index e57c1def..20d28e6c 100644 --- a/tests/figs/shade-p-value/pval-sim-both.svg +++ b/tests/figs/shade-p-value/pval-sim-both.svg @@ -19,125 +19,125 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,19 +145,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-sim-corrupt.svg b/tests/figs/shade-p-value/pval-sim-corrupt.svg index e0c73832..1102f938 100644 --- a/tests/figs/shade-p-value/pval-sim-corrupt.svg +++ b/tests/figs/shade-p-value/pval-sim-corrupt.svg @@ -19,121 +19,121 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -141,19 +141,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-sim-left.svg b/tests/figs/shade-p-value/pval-sim-left.svg index ff9898e2..3a24bb7d 100644 --- a/tests/figs/shade-p-value/pval-sim-left.svg +++ b/tests/figs/shade-p-value/pval-sim-left.svg @@ -19,123 +19,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,19 +143,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-sim-null.svg b/tests/figs/shade-p-value/pval-sim-null.svg index e0c73832..1102f938 100644 --- a/tests/figs/shade-p-value/pval-sim-null.svg +++ b/tests/figs/shade-p-value/pval-sim-null.svg @@ -19,121 +19,121 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -141,19 +141,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-sim-right.svg b/tests/figs/shade-p-value/pval-sim-right.svg index 69b8c77f..a4697107 100644 --- a/tests/figs/shade-p-value/pval-sim-right.svg +++ b/tests/figs/shade-p-value/pval-sim-right.svg @@ -19,123 +19,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,19 +143,25 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - --2 -0 -2 + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/shade-p-value/pval-theor-both.svg b/tests/figs/shade-p-value/pval-theor-both.svg index 47533efa..d664d7ac 100644 --- a/tests/figs/shade-p-value/pval-theor-both.svg +++ b/tests/figs/shade-p-value/pval-theor-both.svg @@ -20,9 +20,9 @@ - + - + diff --git a/tests/figs/shade-p-value/pval-theor-left.svg b/tests/figs/shade-p-value/pval-theor-left.svg index 44616b0c..2f1d5727 100644 --- a/tests/figs/shade-p-value/pval-theor-left.svg +++ b/tests/figs/shade-p-value/pval-theor-left.svg @@ -20,7 +20,7 @@ - + diff --git a/tests/figs/shade-p-value/pval-theor-right.svg b/tests/figs/shade-p-value/pval-theor-right.svg index 4a0dd468..d5359411 100644 --- a/tests/figs/shade-p-value/pval-theor-right.svg +++ b/tests/figs/shade-p-value/pval-theor-right.svg @@ -20,7 +20,7 @@ - + diff --git a/tests/figs/visualize/ci-vis.svg b/tests/figs/visualize/ci-vis.svg index 30771398..ece9d547 100644 --- a/tests/figs/visualize/ci-vis.svg +++ b/tests/figs/visualize/ci-vis.svg @@ -19,24 +19,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -44,23 +44,29 @@ 0 -5 -10 -15 +5 +10 +15 +20 - - - - - - - - --0.4 --0.3 --0.2 --0.1 -0.0 + + + + + + + + + + + +-0.15 +-0.10 +-0.05 +0.00 +0.05 +0.10 +0.15 stat count Simulation-Based Bootstrap Distribution diff --git a/tests/figs/visualize/df-obs-stat-1.svg b/tests/figs/visualize/df-obs-stat-1.svg index 26ae9c7d..a6221c41 100644 --- a/tests/figs/visualize/df-obs-stat-1.svg +++ b/tests/figs/visualize/df-obs-stat-1.svg @@ -19,121 +19,121 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -141,21 +141,21 @@ 0 -5 -10 -15 -20 +5 +10 +15 - - - - - - - -2 -3 -4 + + + + + + + +10 +20 +30 +40 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/df-obs-stat-2.svg b/tests/figs/visualize/df-obs-stat-2.svg index 1205e6bb..a6987e28 100644 --- a/tests/figs/visualize/df-obs-stat-2.svg +++ b/tests/figs/visualize/df-obs-stat-2.svg @@ -19,121 +19,121 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -141,19 +141,23 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - -3.9 -4.0 -4.1 + + + + + + + + +2 +3 +4 +5 +6 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/method-both.svg b/tests/figs/visualize/method-both.svg index 0aa8bff3..e21c8185 100644 --- a/tests/figs/visualize/method-both.svg +++ b/tests/figs/visualize/method-both.svg @@ -14,54 +14,50 @@ - - + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + -0.0 -0.1 -0.2 -0.3 -0.4 -0.5 - - - - - - - - - - -8 -10 -12 -14 -t stat +0.00 +0.25 +0.50 +0.75 + + + + + + + + +-3 +-2 +-1 +0 +t stat density -Simulation-Based and Theoretical t Null Distributions +Simulation-Based and Theoretical t Null Distributions diff --git a/tests/figs/visualize/vis-both-both-1.svg b/tests/figs/visualize/vis-both-both-1.svg index 9d1ac596..aef76c61 100644 --- a/tests/figs/visualize/vis-both-both-1.svg +++ b/tests/figs/visualize/vis-both-both-1.svg @@ -19,126 +19,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -146,21 +146,23 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.2 +0.4 +0.6 - - - - - + + + + + - --2 + + +-2 +-1 0 -2 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/visualize/vis-both-both-2.svg b/tests/figs/visualize/vis-both-both-2.svg index 46198372..9c345e34 100644 --- a/tests/figs/visualize/vis-both-both-2.svg +++ b/tests/figs/visualize/vis-both-both-2.svg @@ -19,126 +19,126 @@ - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -146,21 +146,23 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.2 +0.4 - - - - - + + + + + - --2 + + +-3 +-2 +-1 0 -2 +1 +2 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/visualize/vis-both-left-1.svg b/tests/figs/visualize/vis-both-left-1.svg index 90f281b6..f2e48722 100644 --- a/tests/figs/visualize/vis-both-left-1.svg +++ b/tests/figs/visualize/vis-both-left-1.svg @@ -19,124 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -144,17 +144,21 @@ 0.0 -0.2 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - --2 -0 -2 + + + + + + + +-2 +0 +2 t stat density Simulation-Based and Theoretical t Null Distributions diff --git a/tests/figs/visualize/vis-both-left-2.svg b/tests/figs/visualize/vis-both-left-2.svg index ec8aa00b..25e6f147 100644 --- a/tests/figs/visualize/vis-both-left-2.svg +++ b/tests/figs/visualize/vis-both-left-2.svg @@ -19,124 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -144,25 +144,29 @@ 0.0 -0.2 -0.4 -0.6 +0.1 +0.2 +0.3 +0.4 - - - - - - - - - --3 --2 --1 -0 -1 -2 + + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 z stat density Simulation-Based and Theoretical z Null Distributions diff --git a/tests/figs/visualize/vis-both-none-1.svg b/tests/figs/visualize/vis-both-none-1.svg index 0056a1a4..d751c0c1 100644 --- a/tests/figs/visualize/vis-both-none-1.svg +++ b/tests/figs/visualize/vis-both-none-1.svg @@ -19,22 +19,22 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -42,25 +42,21 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.2 +0.4 - - - - - - + + + + - - --2 --1 + + +-2 +-1 0 -1 -2 +1 +2 t stat density Simulation-Based and Theoretical t Null Distributions diff --git a/tests/figs/visualize/vis-both-none-2.svg b/tests/figs/visualize/vis-both-none-2.svg index 7c8419a0..67098f35 100644 --- a/tests/figs/visualize/vis-both-none-2.svg +++ b/tests/figs/visualize/vis-both-none-2.svg @@ -19,22 +19,22 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + @@ -42,25 +42,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 -0.5 +0.1 +0.2 +0.3 +0.4 +0.5 - - - - - + + + + + - - - -0 -2 -4 -6 + + + + +0.0 +2.5 +5.0 +7.5 +10.0 Chi-Square stat density Simulation-Based and Theoretical Chi-Square Null Distributions diff --git a/tests/figs/visualize/vis-both-right-1.svg b/tests/figs/visualize/vis-both-right-1.svg index 2bd028d3..1bd6b219 100644 --- a/tests/figs/visualize/vis-both-right-1.svg +++ b/tests/figs/visualize/vis-both-right-1.svg @@ -19,123 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,27 +144,23 @@ 0.00 -0.25 -0.50 -0.75 -1.00 +0.25 +0.50 +0.75 +1.00 - - - - - - - - - - -0 -10 -20 -30 -40 -50 + + + + + + + + +0 +2 +4 +6 F stat density Simulation-Based and Theoretical F Null Distributions diff --git a/tests/figs/visualize/vis-both-right-2.svg b/tests/figs/visualize/vis-both-right-2.svg index 5b88c504..b0ce56c7 100644 --- a/tests/figs/visualize/vis-both-right-2.svg +++ b/tests/figs/visualize/vis-both-right-2.svg @@ -19,123 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,29 +144,27 @@ 0.0 -0.1 -0.2 -0.3 -0.4 -0.5 +0.1 +0.2 +0.3 +0.4 +0.5 - - - - - - - - - - - -0 -10 -20 -30 -40 -50 + + + + + + + + + + +0 +2 +4 +6 +8 Chi-Square stat density Simulation-Based and Theoretical Chi-Square Null Distributions diff --git a/tests/figs/visualize/vis-no-hypothesize-both.svg b/tests/figs/visualize/vis-no-hypothesize-both.svg index 58a5b12f..a95c2f65 100644 --- a/tests/figs/visualize/vis-no-hypothesize-both.svg +++ b/tests/figs/visualize/vis-no-hypothesize-both.svg @@ -14,54 +14,46 @@ - - + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + -0.000 -0.025 -0.050 -0.075 - - - - - - - - - - -75 -80 -85 -90 -95 -100 -t stat +0.00 +0.05 +0.10 +0.15 + + + + + + +60 +65 +t stat density -Simulation-Based and Theoretical t Bootstrap Distributions +Simulation-Based and Theoretical t Bootstrap Distributions diff --git a/tests/figs/visualize/vis-no-hypothesize-sim.svg b/tests/figs/visualize/vis-no-hypothesize-sim.svg index 7e6c0390..52d1e32d 100644 --- a/tests/figs/visualize/vis-no-hypothesize-sim.svg +++ b/tests/figs/visualize/vis-no-hypothesize-sim.svg @@ -19,21 +19,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -41,27 +41,21 @@ 0 -5 -10 -15 -20 -25 +5 +10 +15 - - - - - - - - - - -2.90 -2.95 -3.00 -3.05 -3.10 + + + + + + + +40 +41 +42 +43 stat count Simulation-Based Bootstrap Distribution diff --git a/tests/figs/visualize/vis-sim-both-1.svg b/tests/figs/visualize/vis-sim-both-1.svg index c856ded9..4674a8f2 100644 --- a/tests/figs/visualize/vis-sim-both-1.svg +++ b/tests/figs/visualize/vis-sim-both-1.svg @@ -19,125 +19,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,23 +144,25 @@ 0 -5 -10 -15 +5 +10 +15 +20 - - - - - - - - --0.2 --0.1 -0.0 -0.1 -0.2 + + + + + + + + + +-1.00 +-0.75 +-0.50 +-0.25 +0.00 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/vis-sim-both-2.svg b/tests/figs/visualize/vis-sim-both-2.svg index ee41b11e..94bd9ec1 100644 --- a/tests/figs/visualize/vis-sim-both-2.svg +++ b/tests/figs/visualize/vis-sim-both-2.svg @@ -19,35 +19,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -64,16 +63,14 @@ - - - - - --0.2 --0.1 -0.0 -0.1 -0.2 + + + + +-1 +0 +1 +2 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/vis-sim-left-1.svg b/tests/figs/visualize/vis-sim-left-1.svg index 1b3c6f91..b758922f 100644 --- a/tests/figs/visualize/vis-sim-left-1.svg +++ b/tests/figs/visualize/vis-sim-left-1.svg @@ -19,123 +19,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,21 +143,25 @@ 0 -5 -10 -15 +5 +10 +15 +20 - - - - - - - -1.1 -1.2 -1.3 -1.4 + + + + + + + + + +0 +10 +20 +30 +40 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/vis-sim-none-1.svg b/tests/figs/visualize/vis-sim-none-1.svg index 6b218478..5debec48 100644 --- a/tests/figs/visualize/vis-sim-none-1.svg +++ b/tests/figs/visualize/vis-sim-none-1.svg @@ -19,21 +19,21 @@ - - - - - - - - + + + + + + + + - - - - - - + + + + + + @@ -41,23 +41,23 @@ 0 -5 -10 -15 +5 +10 +15 - - - - - - - - --0.2 --0.1 -0.0 -0.1 -0.2 + + + + + + + + +-0.10 +-0.05 +0.00 +0.05 +0.10 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/vis-sim-right-1.svg b/tests/figs/visualize/vis-sim-right-1.svg index 5bfa41a1..c0ffdc50 100644 --- a/tests/figs/visualize/vis-sim-right-1.svg +++ b/tests/figs/visualize/vis-sim-right-1.svg @@ -19,123 +19,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,19 +143,25 @@ 0 -5 -10 -15 +5 +10 +15 +20 - - - - + + + + + + - --0.3 -0.0 -0.3 + + +-0.10 +-0.05 +0.00 +0.05 +0.10 stat count Simulation-Based Null Distribution diff --git a/tests/figs/visualize/vis-theor-both-1.svg b/tests/figs/visualize/vis-theor-both-1.svg index 11c168ad..b8030397 100644 --- a/tests/figs/visualize/vis-theor-both-1.svg +++ b/tests/figs/visualize/vis-theor-both-1.svg @@ -19,111 +19,111 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -131,21 +131,21 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - + + + + + - --2 + +-2 0 -2 +2 t stat density Theoretical t Null Distribution diff --git a/tests/figs/visualize/vis-theor-both-2.svg b/tests/figs/visualize/vis-theor-both-2.svg index 70d48752..2c521b1d 100644 --- a/tests/figs/visualize/vis-theor-both-2.svg +++ b/tests/figs/visualize/vis-theor-both-2.svg @@ -20,9 +20,9 @@ - + - + @@ -174,6 +174,348 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/figs/visualize/vis-theor-left-1.svg b/tests/figs/visualize/vis-theor-left-1.svg index f4fdc04a..ba3be55f 100644 --- a/tests/figs/visualize/vis-theor-left-1.svg +++ b/tests/figs/visualize/vis-theor-left-1.svg @@ -19,159 +19,501 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -179,21 +521,21 @@ 0.0 -0.1 -0.2 -0.3 -0.4 +0.1 +0.2 +0.3 +0.4 - - - - - + + + + + - --2 + +-2 0 -2 +2 t stat density Theoretical t Null Distribution diff --git a/tests/figs/visualize/vis-theor-none-2.svg b/tests/figs/visualize/vis-theor-none-2.svg index ad48b100..e848862d 100644 --- a/tests/figs/visualize/vis-theor-none-2.svg +++ b/tests/figs/visualize/vis-theor-none-2.svg @@ -19,29 +19,29 @@ - + -0.0 -0.1 -0.2 -0.3 -0.4 - - - - - - +0.0 +0.1 +0.2 +0.3 +0.4 + + + + + + - --2 + +-2 0 -2 +2 t stat density Theoretical t Null Distribution diff --git a/tests/figs/visualize/vis-theor-none-3.svg b/tests/figs/visualize/vis-theor-none-3.svg index e9d2f338..7d58f680 100644 --- a/tests/figs/visualize/vis-theor-none-3.svg +++ b/tests/figs/visualize/vis-theor-none-3.svg @@ -19,31 +19,31 @@ - + -0.00 -0.25 -0.50 -0.75 +0.00 +0.25 +0.50 +0.75 1.00 - - - - - + + + + + - - - + + + 0 -2 -4 -6 +2 +4 +6 F stat density Theoretical F Null Distribution diff --git a/tests/figs/visualize/vis-theor-right-1.svg b/tests/figs/visualize/vis-theor-right-1.svg index db0fc2b3..a5d93f7e 100644 --- a/tests/figs/visualize/vis-theor-right-1.svg +++ b/tests/figs/visualize/vis-theor-right-1.svg @@ -19,159 +19,501 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -190,18 +532,12 @@ - - - - - - -0 -10 -20 -30 -40 -50 + + + +0 +5 +10 Chi-Square stat density Theoretical Chi-Square Null Distribution diff --git a/tests/testthat/helper-data.R b/tests/testthat/helper-data.R index f1936362..1f5fe761 100644 --- a/tests/testthat/helper-data.R +++ b/tests/testthat/helper-data.R @@ -1,19 +1,15 @@ set.seed(4242) -iris_df <- tibble::as_tibble(iris) +gss_tbl <- tibble::as_tibble(gss) %>% + dplyr::filter(!(is.na(sex) | is.na(college))) %>% + dplyr::mutate(partyid = as.character(partyid)) %>% + dplyr::filter(partyid %in% c("ind", "rep", "dem")) -iris_tbl <- iris %>% - tibble::as_tibble() %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5"), - Sepal.Width.Group = dplyr::if_else(Sepal.Width > 3, "large", "small") - ) - -iris_calc <- iris_tbl %>% - specify(Sepal.Length.Group ~ Sepal.Width.Group, success = "<=5") %>% +gss_calc <- gss_tbl %>% + specify(college ~ sex, success = "no degree") %>% hypothesize(null = "independence") %>% generate(reps = 1000) %>% - calculate(stat = "diff in props", order = c("large", "small")) + calculate(stat = "diff in props", order = c("female", "male")) mtcars_df <- mtcars %>% dplyr::mutate( @@ -21,25 +17,27 @@ mtcars_df <- mtcars %>% carb = factor(carb) ) -obs_diff <- iris_tbl %>% - specify(Sepal.Length.Group ~ Sepal.Width.Group, success = "<=5") %>% - calculate(stat = "diff in props", order = c("large", "small")) +obs_diff <- gss_tbl %>% + specify(college ~ sex, success = "no degree") %>% + calculate(stat = "diff in props", order = c("female", "male")) set.seed(2018) test_df <- tibble::tibble(stat = rnorm(100)) # Data for visualization tests -iris_permute <- iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% +gss_permute <- gss_tbl %>% + specify(college ~ sex, success = "no degree") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "z", order = c(">5", "<=5")) -iris_viz_sim <- iris_permute %>% visualize(method = "simulation") + calculate(stat = "z", order = c("female", "male")) + +gss_viz_sim <- gss_permute %>% visualize(method = "simulation") + # Warnings are about checking conditions for the theoretical method. -iris_viz_theor <- suppressWarnings( - iris_permute %>% visualize(method = "theoretical") +gss_viz_theor <- suppressWarnings( + gss_permute %>% visualize(method = "theoretical") ) -iris_viz_both <- suppressWarnings( - iris_permute %>% visualize(method = "both") +gss_viz_both <- suppressWarnings( + gss_permute %>% visualize(method = "both") ) diff --git a/tests/testthat/test-aliases.R b/tests/testthat/test-aliases.R index 705308f8..9aa8a116 100644 --- a/tests/testthat/test-aliases.R +++ b/tests/testthat/test-aliases.R @@ -1,11 +1,11 @@ context("aliases") test_that("aliases work", { - expect_gt( - iris_calc %>% + expect_equal( + gss_calc %>% get_pvalue(obs_stat = -0.2, direction = "right") %>% dplyr::pull(), - expected = 0.98 + expected = 1 ) expect_silent(test_df %>% get_ci()) @@ -13,10 +13,10 @@ test_that("aliases work", { test_that("old aliases produce warning", { expect_warning( - iris_calc %>% + gss_calc %>% p_value(obs_stat = -0.2, direction = "right") %>% dplyr::pull(), - expected = 0.98 + expected = 1 ) expect_warning(test_df %>% conf_int()) diff --git a/tests/testthat/test-calculate.R b/tests/testthat/test-calculate.R index 8a7887fa..da055165 100644 --- a/tests/testthat/test-calculate.R +++ b/tests/testthat/test-calculate.R @@ -8,338 +8,327 @@ test_that("x is a tibble", { test_that("stat argument is appropriate", { # stat is a string - expect_error(calculate(iris_df, stat = 3)) + expect_error(calculate(gss_tbl, stat = 3)) # stat is one of the implemented options - gen_iris_slope <- iris_df %>% - specify(Sepal.Length ~ Sepal.Width) %>% + gen_gss_slope <- gss_tbl %>% + specify(hours ~ age) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_error(calculate(gen_iris_slope, stat = "slopee")) - expect_error(calculate(gen_iris_slope, stat = "stdev")) - expect_error(calculate(gen_iris_slope, stat = "stat")) + expect_error(calculate(gen_gss_slope, stat = "slopee")) + expect_error(calculate(gen_gss_slope, stat = "stdev")) + expect_error(calculate(gen_gss_slope, stat = "stat")) }) test_that("response attribute has been set", { expect_error( - tibble::as_tibble(iris) %>% calculate(stat = "median") + tibble::as_tibble(gss) %>% calculate(stat = "median") ) }) test_that("variable chosen is of appropriate class (one var problems)", { # One sample chisq example - gen_iris1 <- iris %>% - specify(Species ~ NULL) %>% + gen_gss1 <- gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize( null = "point", - p = c("setosa" = .5, "versicolor" = .25, "virginica" = .25) + p = c("dem" = .5, "rep" = .25, "ind" = .25) ) %>% generate(reps = 10, type = "simulate") - expect_error(calculate(gen_iris1, stat = "mean")) + expect_error(calculate(gen_gss1, stat = "mean")) # One mean example - gen_iris_num <- iris %>% - specify(Sepal.Width ~ NULL) %>% - hypothesize(null = "point", mu = 3) %>% + gen_gss_num <- gss_tbl %>% + specify(hours ~ NULL) %>% + hypothesize(null = "point", mu = 40) %>% generate(reps = 10, type = "bootstrap") - expect_error(calculate(gen_iris_num, stat = "prop")) - expect_silent(calculate(gen_iris_num, stat = "mean")) - expect_error(calculate(gen_iris_num, stat = "median")) - expect_error(calculate(gen_iris_num, stat = "sd")) - - gen_iris_num2 <- iris %>% - specify(Sepal.Width ~ NULL) %>% - hypothesize(null = "point", med = 3) %>% + expect_error(calculate(gen_gss_num, stat = "prop")) + expect_silent(calculate(gen_gss_num, stat = "mean")) + expect_error(calculate(gen_gss_num, stat = "median")) + expect_error(calculate(gen_gss_num, stat = "sd")) + + gen_gss_num2 <- gss_tbl %>% + specify(hours ~ NULL) %>% + hypothesize(null = "point", med = 40) %>% generate(reps = 10, type = "bootstrap") - expect_error(calculate(gen_iris_num2, stat = "prop")) - expect_error(calculate(gen_iris_num2, stat = "mean")) - expect_silent(calculate(gen_iris_num2, stat = "median")) - expect_error(calculate(gen_iris_num2, stat = "sd")) + expect_error(calculate(gen_gss_num2, stat = "prop")) + expect_error(calculate(gen_gss_num2, stat = "mean")) + expect_silent(calculate(gen_gss_num2, stat = "median")) + expect_error(calculate(gen_gss_num2, stat = "sd")) - gen_iris_num3 <- iris %>% - specify(Sepal.Width ~ NULL) %>% + gen_gss_num3 <- gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", sigma = 0.6) %>% generate(reps = 10, type = "bootstrap") - expect_error(calculate(gen_iris_num3, stat = "prop")) - expect_error(calculate(gen_iris_num3, stat = "mean")) - expect_error(calculate(gen_iris_num3, stat = "median")) - expect_silent(calculate(gen_iris_num3, stat = "sd")) + expect_error(calculate(gen_gss_num3, stat = "prop")) + expect_error(calculate(gen_gss_num3, stat = "mean")) + expect_error(calculate(gen_gss_num3, stat = "median")) + expect_silent(calculate(gen_gss_num3, stat = "sd")) }) test_that("grouping (explanatory) variable is a factor (two var problems)", { - gen_iris2 <- iris %>% - specify(Sepal.Width ~ Sepal.Length) %>% + gen_gss2 <- gss_tbl %>% + specify(hours ~ age) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_error(calculate(gen_iris2, stat = "diff in means")) - expect_error(calculate(gen_iris2, stat = "diff in medians")) + expect_error(calculate(gen_gss2, stat = "diff in means")) + expect_error(calculate(gen_gss2, stat = "diff in medians")) # Since shifts to "Slope with t" ## Not implemented - # expect_silent(calculate(gen_iris2, stat = "t")) + # expect_silent(calculate(gen_gss2, stat = "t")) }) test_that("grouping (explanatory) variable is numeric (two var problems)", { - gen_iris2a <- iris %>% - specify(Species ~ Sepal.Length) %>% + gen_gss2a <- gss_tbl %>% + specify(partyid ~ hours) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_error(calculate(gen_iris2a, stat = "slope")) + expect_error(calculate(gen_gss2a, stat = "slope")) # Since shifts to "Slope with t" - expect_error(calculate(gen_iris2a, stat = "t")) - expect_error(calculate(gen_iris2a, stat = "diff in medians")) + expect_error(calculate(gen_gss2a, stat = "t")) + expect_error(calculate(gen_gss2a, stat = "diff in medians")) }) test_that("response variable is a factor (two var problems)", { - gen_iris3 <- iris %>% - specify(Sepal.Width ~ Species) %>% + gen_gss3 <- gss_tbl %>% + specify(hours ~ partyid) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_error(calculate(gen_iris3, stat = "Chisq")) + expect_error(calculate(gen_gss3, stat = "Chisq")) - # Species has more than 2 levels - gen_iris4 <- iris %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Sepal.Length.Group ~ Species, success = ">5") %>% + # explanatory has more than 2 levels + gen_gss4 <- gss_tbl %>% + specify(sex ~ partyid, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_error(calculate(gen_iris4, stat = "diff in props")) - expect_error(calculate(gen_iris4, stat = "ratio of props")) - expect_error(calculate(gen_iris4, stat = "odds ratio")) + expect_error(calculate(gen_gss4, stat = "diff in props")) + expect_error(calculate(gen_gss4, stat = "ratio of props")) + expect_error(calculate(gen_gss4, stat = "odds ratio")) - expect_error(calculate(gen_iris4, stat = "t")) + expect_error(calculate(gen_gss4, stat = "t")) # Check successful diff in props - gen_iris4a <- iris %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - dplyr::mutate( - Sepal.Width.Group = dplyr::if_else(Sepal.Width > 3, "large", "small") - ) %>% - specify(Sepal.Length.Group ~ Sepal.Width.Group, success = ">5") %>% + gen_gss4a <- gss_tbl %>% + specify(college ~ sex, success = "no degree") %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") expect_silent( - calculate(gen_iris4a, stat = "diff in props", order = c("large", "small")) + calculate(gen_gss4a, stat = "diff in props", order = c("female", "male")) ) expect_silent( - calculate(gen_iris4a, stat = "ratio of props", order = c("large", "small")) + calculate(gen_gss4a, stat = "ratio of props", order = c("female", "male")) ) expect_silent( - calculate(gen_iris4a, stat = "odds ratio", order = c("large", "small")) + calculate(gen_gss4a, stat = "odds ratio", order = c("female", "male")) ) expect_silent( - calculate(gen_iris4a, stat = "z", order = c("large", "small")) + calculate(gen_gss4a, stat = "z", order = c("female", "male")) ) - expect_warning(calculate(gen_iris4a, stat = "z")) + expect_warning(calculate(gen_gss4a, stat = "z")) }) -gen_iris5 <- iris %>% - specify(Species ~ Sepal.Width) %>% +gen_gss5 <- gss_tbl %>% + specify(partyid ~ hours) %>% generate(reps = 10, type = "bootstrap") test_that("response variable is numeric (two var problems)", { - expect_error(calculate(gen_iris5, stat = "F")) + expect_error(calculate(gen_gss5, stat = "F")) }) test_that("two sample mean-type problems are working", { - gen_iris5a <- iris %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Sepal.Width ~ Sepal.Length.Group) %>% + gen_gss5a <- gss_tbl %>% + specify(hours ~ college) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_warning(calculate(gen_iris5a, stat = "diff in means")) + expect_warning(calculate(gen_gss5a, stat = "diff in means")) expect_silent( - calculate(gen_iris5a, stat = "diff in means", order = c(">5", "<=5")) + calculate(gen_gss5a, + stat = "diff in means", + order = c("no degree", "degree")) ) - expect_warning(calculate(gen_iris5a, stat = "t")) - expect_silent(calculate(gen_iris5a, stat = "t", order = c(">5", "<=5"))) + expect_warning(calculate(gen_gss5a, stat = "t")) + expect_silent(calculate(gen_gss5a, stat = "t", + order = c("no degree", "degree"))) }) test_that("properties of tibble passed-in are correct", { - expect_is(gen_iris5, "grouped_df") - expect_equal(ncol(gen_iris5), 3) + expect_is(gen_gss5, "grouped_df") + expect_equal(ncol(gen_gss5), 3) - gen_iris6 <- iris %>% - specify(Sepal.Length ~ NULL) %>% + gen_gss6 <- gss_tbl %>% + specify(hours ~ NULL) %>% generate(reps = 10) - expect_equal(ncol(gen_iris6), 2) - expect_error(calculate(gen_iris6)) + expect_equal(ncol(gen_gss6), 2) + expect_error(calculate(gen_gss6)) }) test_that("order is working for diff in means", { - gen_iris7 <- iris %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Sepal.Width ~ Sepal.Length.Group) %>% + gen_gss7 <- gss_tbl %>% + specify(hours ~ college) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") expect_equal( - nrow(calculate(gen_iris7, stat = "diff in means", order = c(">5", "<=5"))), + nrow(calculate(gen_gss7, + stat = "diff in means", + order = c("no degree", "degree"))), 10 ) expect_equal( - ncol(calculate(gen_iris7, stat = "diff in means", order = c(">5", "<=5"))), + ncol(calculate(gen_gss7, + stat = "diff in means", + order = c("no degree", "degree"))), 2 ) }) test_that("chi-square matches chisq.test value", { - gen_iris8 <- iris %>% - dplyr::mutate( - Petal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Petal.Length.Group ~ Species, success = ">5") %>% + gen_gss8 <- gss_tbl %>% + specify(sex ~ partyid, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - infer_way <- calculate(gen_iris8, stat = "Chisq") + infer_way <- calculate(gen_gss8, stat = "Chisq") # chisq.test way - trad_way <- gen_iris8 %>% + suppressWarnings( + trad_way <- gen_gss8 %>% dplyr::group_by(replicate) %>% dplyr::do(broom::tidy( - stats::chisq.test(table(.$Petal.Length.Group, .$Species)) + stats::chisq.test(table(.$sex, .$partyid)) )) %>% dplyr::ungroup() %>% dplyr::select(replicate, stat = statistic) + ) # Equal not including attributes expect_equivalent(infer_way, trad_way) - gen_iris9 <- iris %>% - specify(Species ~ NULL) %>% + gen_gss9 <- gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize( null = "point", - p = c("setosa" = 1/3, "versicolor" = 1/3, "virginica" = 1/3) + p = c("dem" = 1/3, "rep" = 1/3, "ind" = 1/3) ) %>% generate(reps = 10, type = "simulate") - infer_way <- calculate(gen_iris9, stat = "Chisq") + infer_way <- calculate(gen_gss9, stat = "Chisq") # chisq.test way - trad_way <- gen_iris9 %>% + trad_way <- gen_gss9 %>% dplyr::group_by(replicate) %>% dplyr::do(broom::tidy( - stats::chisq.test(table(.$Species)) + stats::chisq.test(table(.$partyid)) )) %>% dplyr::select(replicate, stat = statistic) expect_equivalent(infer_way, trad_way) - gen_iris9a <- iris %>% - specify(Species ~ NULL) %>% + gen_gss9a <- gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize( null = "point", - p = c("setosa" = 0.8, "versicolor" = 0.1, "virginica" = 0.1) + p = c("dem" = 0.8, "rep" = 0.1, "ind" = 0.1) ) %>% generate(reps = 10, type = "simulate") - infer_way <- calculate(gen_iris9a, stat = "Chisq") + infer_way <- calculate(gen_gss9a, stat = "Chisq") # chisq.test way - trad_way <- gen_iris9a %>% + trad_way <- gen_gss9a %>% dplyr::group_by(replicate) %>% dplyr::do(broom::tidy( - stats::chisq.test(table(.$Species), p = c(0.8, 0.1, 0.1)) + stats::chisq.test(table(.$partyid), p = c(0.8, 0.1, 0.1)) )) %>% dplyr::select(replicate, stat = statistic) expect_equivalent(infer_way, trad_way) }) test_that("`order` is working", { - gen_iris10 <- iris %>% - dplyr::mutate( - Petal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Petal.Width ~ Petal.Length.Group) %>% + gen_gss_tbl10 <- gss_tbl %>% + specify(hours ~ college) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") expect_error( - calculate(gen_iris10, stat = "diff in means", order = c(TRUE, FALSE)) + calculate(gen_gss_tbl10, stat = "diff in means", order = c(TRUE, FALSE)) ) - gen_iris11 <- iris %>% - dplyr::mutate( - Petal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Petal.Width ~ Petal.Length.Group) %>% + gen_gss_tbl11 <- gss_tbl %>% + specify(hours ~ college) %>% generate(reps = 10, type = "bootstrap") expect_error( - calculate(gen_iris11, stat = "diff in medians", order = ">5") + calculate(gen_gss_tbl11, + stat = "diff in medians", + order = "no degree") ) expect_error( - calculate(gen_iris11, stat = "diff in medians", order = c(NA, ">5")) + calculate(gen_gss_tbl11, + stat = "diff in medians", + order = c(NA, "no degree")) ) expect_error( - calculate(gen_iris11, stat = "diff in medians", order = c(">5", "<=4")) + calculate(gen_gss_tbl11, + stat = "diff in medians", + order = c("no degree", "other")) ) expect_silent( - calculate(gen_iris11, stat = "diff in medians", order = c(">5", "<=5")) + calculate(gen_gss_tbl11, + stat = "diff in medians", + order = c("no degree", "degree")) ) expect_error( - calculate(gen_iris11, stat = "diff in means", order = c(">5", "<=4", ">4")) + calculate(gen_gss_tbl11, + stat = "diff in means", + order = c("no degree", "degree", "the last one")) ) # order not given - expect_warning(calculate(gen_iris11, stat = "diff in means"), + expect_warning(calculate(gen_gss_tbl11, stat = "diff in means"), "The statistic is based on a difference or ratio") }) -gen_iris12 <- iris %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) %>% - specify(Sepal.Length.Group ~ NULL, success = ">5") %>% +gen_gss_tbl12 <- gss_tbl %>% + specify(college ~ NULL, success = "no degree") %>% hypothesize(null = "point", p = 0.3) %>% generate(reps = 10, type = "simulate") test_that('success is working for stat = "prop"', { - expect_silent(gen_iris12 %>% calculate(stat = "prop")) - expect_silent(gen_iris12 %>% calculate(stat = "z")) + expect_silent(gen_gss_tbl12 %>% calculate(stat = "prop")) + expect_silent(gen_gss_tbl12 %>% calculate(stat = "z")) }) test_that("NULL response gives error", { - iris_improp <- tibble::as_tibble(iris) %>% - dplyr::select(Sepal.Width, Sepal.Length) + gss_tbl_improp <- tibble::as_tibble(gss_tbl) %>% + dplyr::select(hours, age) - expect_error(iris_improp %>% calculate(stat = "mean")) + expect_error(gss_tbl_improp %>% calculate(stat = "mean")) }) test_that("Permute F test works", { - gen_iris13 <- iris %>% - specify(Petal.Width ~ Species) %>% + gen_gss_tbl13 <- gss_tbl %>% + specify(hours ~ partyid) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_silent(calculate(gen_iris13, stat = "F")) + expect_silent(calculate(gen_gss_tbl13, stat = "F")) }) test_that("Permute slope/correlation test works", { - gen_iris14 <- iris %>% - specify(Petal.Width ~ Petal.Length) %>% + gen_gss_tbl14 <- gss_tbl %>% + specify(hours ~ age) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") - expect_silent(calculate(gen_iris14, stat = "slope")) - expect_silent(calculate(gen_iris14, stat = "correlation")) + expect_silent(calculate(gen_gss_tbl14, stat = "slope")) + expect_silent(calculate(gen_gss_tbl14, stat = "correlation")) }) test_that("order being given when not needed gives warning", { - gen_iris15 <- iris %>% - dplyr::mutate( - Petal.Length.Group = dplyr::if_else(Sepal.Length > 4, ">4", "<=4") - ) %>% - specify(Petal.Length.Group ~ Species, success = ">4") %>% + gen_gss_tbl15 <- gss_tbl %>% + specify(college ~ partyid, success = "no degree") %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") expect_warning( - calculate(gen_iris15, stat = "Chisq", order = c("setosa", "virginica")) + calculate(gen_gss_tbl15, stat = "Chisq", order = c("dem", "ind")) ) }) ## Breaks oldrel build. Commented out for now. # test_that("warning given if calculate without generate", { # expect_warning( -# iris %>% -# specify(Species ~ NULL) %>% +# gss_tbl %>% +# specify(partyid ~ NULL) %>% # hypothesize( # null = "point", -# p = c("setosa" = 0.4, "versicolor" = 0.4, "virginica" = 0.2) +# p = c("dem" = 0.4, "rep" = 0.4, "ind" = 0.2) # ) %>% # # generate(reps = 10, type = "simulate") %>% # calculate(stat = "Chisq") @@ -348,77 +337,79 @@ test_that("order being given when not needed gives warning", { test_that("specify() %>% calculate() works", { expect_silent( - iris_tbl %>% specify(Petal.Width ~ NULL) %>% calculate(stat = "mean") + gss_tbl %>% specify(hours ~ NULL) %>% calculate(stat = "mean") ) expect_error( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 4) %>% calculate(stat = "mean") ) expect_error( - iris_tbl %>% specify(Species ~ NULL) %>% calculate(stat = "Chisq") + gss_tbl %>% specify(partyid ~ NULL) %>% calculate(stat = "Chisq") ) }) test_that("One sample t hypothesis test is working", { expect_message( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 1) %>% generate(reps = 10) %>% calculate(stat = "t") ) expect_message( - iris_tbl %>% - specify(response = Petal.Width) %>% + gss_tbl %>% + specify(response = hours) %>% calculate(stat = "t"), "the t-test will assume a null hypothesis" ) - iris_tbl %>% - specify(response = Petal.Width) %>% + gss_tbl %>% + specify(response = hours) %>% calculate(stat = "t", mu = 1) }) test_that("specify done before calculate", { - iris_mean <- iris_tbl %>% - dplyr::select(stat = Sepal.Width) - expect_error(calculate(iris_mean, stat = "mean")) + gss_tbl_mean <- gss_tbl %>% + dplyr::select(stat = hours) + expect_error(calculate(gss_tbl_mean, stat = "mean")) - iris_prop <- iris_tbl %>% dplyr::select(Sepal.Length.Group) - attr(iris_prop, "response") <- "Sepal.Length.Group" - expect_error(calculate(iris_prop, stat = "prop")) - expect_error(calculate(iris_prop, stat = "count")) + gss_tbl_prop <- gss_tbl %>% dplyr::select(college) + attr(gss_tbl_prop, "response") <- "college" + expect_error(calculate(gss_tbl_prop, stat = "prop")) + expect_error(calculate(gss_tbl_prop, stat = "count")) }) test_that("chisq GoF has params specified for observed stat", { - no_params <- iris_df %>% specify(response = Species) + no_params <- gss_tbl %>% specify(response = partyid) expect_error(calculate(no_params, stat = "Chisq")) - params <- iris_df %>% - specify(response = Species) %>% + params <- gss_tbl %>% + specify(response = partyid) %>% hypothesize( null = "point", - p = c("setosa" = .5, "versicolor" = .25, "virginica" = .25) + p = c("dem" = .5, "rep" = .25, "ind" = .25) ) expect_silent(calculate(params, stat = "Chisq")) }) test_that("generate not done before calculate", { - iris_hyp <- iris_tbl %>% - specify(Sepal.Width ~ Sepal.Length.Group) %>% + gss_tbl_hyp <- gss_tbl %>% + specify(hours ~ college) %>% hypothesize(null = "independence") - attr(iris_hyp, "generate") <- TRUE - expect_warning(calculate(iris_hyp, stat = "t", order = c(">5", "<=5"))) + attr(gss_tbl_hyp, "generate") <- TRUE + expect_warning(calculate(gss_tbl_hyp, + stat = "t", + order = c("no degree", "degree"))) }) test_that("One sample t bootstrap is working", { expect_message( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% generate(reps = 10) %>% calculate(stat = "t") ) @@ -428,8 +419,8 @@ test_that("calculate doesn't depend on order of `p` (#122)", { calc_chisq <- function(p) { set.seed(111) - iris %>% - specify(Species ~ NULL) %>% + gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize(null = "point", p = p) %>% generate(reps = 500, type = "simulate") %>% calculate("Chisq") %>% @@ -438,8 +429,8 @@ test_that("calculate doesn't depend on order of `p` (#122)", { } expect_equal( - calc_chisq(c("versicolor" = 0.25, "setosa" = 0.5, "virginica" = 0.25)), - calc_chisq(c("virginica" = 0.25, "versicolor" = 0.25, "setosa" = 0.5)), + calc_chisq(c("rep" = 0.25, "dem" = 0.5, "ind" = 0.25)), + calc_chisq(c("ind" = 0.25, "rep" = 0.25, "dem" = 0.5)), tolerance = 1e-5 ) }) @@ -454,20 +445,20 @@ test_that("calc_impl_diff_f works", { test_that("calc_impl.sum works", { expect_equal( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% calculate(stat = "sum") %>% `[[`(1), - sum(iris_tbl$Petal.Width) + sum(gss_tbl$hours) ) - gen_iris16 <- iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gen_gss_tbl16 <- gss_tbl %>% + specify(hours ~ NULL) %>% generate(10) # Temporarily remove because of failing noLD test # expect_equal( - # gen_iris16 %>% calculate(stat = "sum"), - # gen_iris16 %>% dplyr::summarise(stat = sum(Petal.Width)), + # gen_gss_tbl16 %>% calculate(stat = "sum"), + # gen_gss_tbl16 %>% dplyr::summarise(stat = sum(hours)), # tolerance = .Machine$double.eps^0.25 # ) }) @@ -483,28 +474,28 @@ test_that("calc_impl_success_f works", { test_that("calc_impl.count works", { expect_equal( - iris_tbl %>% - specify(Sepal.Length.Group ~ NULL, success = ">5") %>% + gss_tbl %>% + specify(college ~ NULL, success = "no degree") %>% calculate(stat = "count") %>% `[[`(1), - sum(iris_tbl$Sepal.Length.Group == ">5") + sum(gss_tbl$college == "no degree") ) expect_equivalent( - gen_iris12 %>% calculate(stat = "count"), - gen_iris12 %>% dplyr::summarise(stat = sum(Sepal.Length.Group == ">5")) + gen_gss_tbl12 %>% calculate(stat = "count"), + gen_gss_tbl12 %>% dplyr::summarise(stat = sum(college == "no degree")) ) }) -gss_biased <- gss %>% +gss_biased <- gss_tbl %>% dplyr::filter(!(sex == "male" & college == "no degree" & age < 40)) gss_tbl <- table(gss_biased$sex, gss_biased$college) test_that("calc_impl.odds_ratio works", { - base_odds_ratio <- {(gss_tbl[1,1] * gss_tbl[2,2]) / - (gss_tbl[1,2] * gss_tbl[2,1])} + base_odds_ratio <- {(gss_tbl [1,1] * gss_tbl [2,2]) / + (gss_tbl [1,2] * gss_tbl [2,1])} expect_equal( gss_biased %>% @@ -516,8 +507,8 @@ test_that("calc_impl.odds_ratio works", { }) test_that("calc_impl.ratio_of_props works", { - base_ratio_of_props <- {(gss_tbl[1,2] / sum(gss_tbl[1,])) / - (gss_tbl[2,2] / sum(gss_tbl[2,]))} + base_ratio_of_props <- {(gss_tbl [1,2] / sum(gss_tbl [1,])) / + (gss_tbl [2,2] / sum(gss_tbl [2,]))} expect_equal( gss_biased %>% diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 918defe5..06553dd9 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -6,15 +6,15 @@ test_that("basics work", { expect_error(test_df %>% get_confidence_interval(level = 1.2)) expect_error(test_df %>% get_confidence_interval(point_estimate = "help")) - expect_silent(iris_calc %>% + expect_silent(gss_calc %>% get_confidence_interval(type = "se", point_estimate = 4)) - expect_silent(iris_calc %>% + expect_silent(gss_calc %>% get_confidence_interval(type = "se", point_estimate = obs_diff)) - expect_error(iris_calc %>% + expect_error(gss_calc %>% get_confidence_interval(type = "se", point_estimate = "error")) - expect_error(iris_calc %>% + expect_error(gss_calc %>% get_confidence_interval(type = "se")) }) diff --git a/tests/testthat/test-get_p_value.R b/tests/testthat/test-get_p_value.R index a76d2088..bdbedfd4 100644 --- a/tests/testthat/test-get_p_value.R +++ b/tests/testthat/test-get_p_value.R @@ -28,7 +28,9 @@ test_that("get_p_value works", { expect_equal( get_p_value(test_df, 4, "greater"), get_p_value(test_df, 4, "right") ) - expect_equal(get_p_value(test_df, 4, "less"), get_p_value(test_df, 4, "left")) + expect_equal( + get_p_value(test_df, 4, "less"), get_p_value(test_df, 4, "left") + ) expect_equal( get_p_value(test_df, 4, "two_sided"), get_p_value(test_df, 4, "both") ) @@ -41,12 +43,12 @@ test_that("get_p_value works", { }) test_that("theoretical p-value not supported error", { - obs_F <- iris_tbl %>% - specify(Sepal.Width ~ Species) %>% + obs_F <- gss_tbl %>% + specify(hours ~ partyid) %>% calculate(stat = "F") expect_error( - iris_tbl %>% - specify(Sepal.Width ~ Species) %>% + gss_tbl %>% + specify(hours ~ partyid) %>% hypothesize(null = "independence") %>% calculate(stat = "F") %>% get_p_value(obs_stat = obs_F, direction = "right") diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R index 118287bc..9dfad86d 100644 --- a/tests/testthat/test-print.R +++ b/tests/testthat/test-print.R @@ -2,8 +2,8 @@ context("print") test_that("print works", { expect_output(print( - iris %>% - specify(Sepal.Length ~ Sepal.Width) %>% + gss_tbl %>% + specify(age ~ hours) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") )) diff --git a/tests/testthat/test-shade_confidence_interval.R b/tests/testthat/test-shade_confidence_interval.R index ba2243ce..afba57ca 100644 --- a/tests/testthat/test-shade_confidence_interval.R +++ b/tests/testthat/test-shade_confidence_interval.R @@ -8,80 +8,80 @@ test_that("shade_confidence_interval works", { # Adding `shade_confidence_interval()` to simulation plot expect_doppelganger( "ci-sim-fill", - iris_viz_sim + shade_confidence_interval(c(-1, 1)) + gss_viz_sim + shade_confidence_interval(c(-1, 1)) ) expect_doppelganger( "ci-sim-nofill", - iris_viz_sim + shade_confidence_interval(c(-1, 1), fill = NULL) + gss_viz_sim + shade_confidence_interval(c(-1, 1), fill = NULL) ) # Adding `shade_confidence_interval()` to theoretical plot expect_doppelganger( "ci-theor-fill", - iris_viz_theor + shade_confidence_interval(c(-1, 1)) + gss_viz_theor + shade_confidence_interval(c(-1, 1)) ) expect_doppelganger( "ci-theor-nofill", - iris_viz_theor + shade_confidence_interval(c(-1, 1), fill = NULL) + gss_viz_theor + shade_confidence_interval(c(-1, 1), fill = NULL) ) # Adding `shade_confidence_interval()` to "both" plot expect_doppelganger( "ci-both-fill", - iris_viz_both + shade_confidence_interval(c(-1, 1)) + gss_viz_both + shade_confidence_interval(c(-1, 1)) ) expect_doppelganger( "ci-both-nofill", - iris_viz_both + shade_confidence_interval(c(-1, 1), fill = NULL) + gss_viz_both + shade_confidence_interval(c(-1, 1), fill = NULL) ) }) test_that("shade_confidence_interval accepts `NULL` as `endpoints`", { expect_doppelganger( "ci-null-endpoints", - iris_viz_sim + shade_confidence_interval(NULL) + gss_viz_sim + shade_confidence_interval(NULL) ) }) test_that("shade_confidence_interval uses extra aesthetic", { expect_doppelganger( "ci-extra-aes-1", - iris_viz_sim + shade_confidence_interval(c(-1, 1), alpha = 1) + gss_viz_sim + shade_confidence_interval(c(-1, 1), alpha = 1) ) expect_doppelganger( "ci-extra-aes-2", - iris_viz_sim + shade_confidence_interval(c(-1, 1), linetype = "dotted") + gss_viz_sim + shade_confidence_interval(c(-1, 1), linetype = "dotted") ) }) test_that("shade_confidence_interval throws errors and warnings", { - expect_warning(iris_viz_sim + shade_confidence_interval(c(1, 2, 3)), "2") + expect_warning(gss_viz_sim + shade_confidence_interval(c(1, 2, 3)), "2") expect_error( - iris_viz_sim + shade_confidence_interval(data.frame(x = 1)), + gss_viz_sim + shade_confidence_interval(data.frame(x = 1)), "1 x 2" ) expect_error( - iris_viz_sim + shade_confidence_interval(c(-1, 1), color = "x"), + gss_viz_sim + shade_confidence_interval(c(-1, 1), color = "x"), "color" ) expect_error( - iris_viz_sim + shade_confidence_interval(c(-1, 1), fill = "x"), + gss_viz_sim + shade_confidence_interval(c(-1, 1), fill = "x"), "color" ) expect_error( - iris_viz_sim %>% shade_confidence_interval(c(-1, 1)), + gss_viz_sim %>% shade_confidence_interval(c(-1, 1)), "\\`shade_confidence_interval\\(\\)\\` as a layer" ) expect_error( - iris_viz_sim %>% shade_confidence_interval(endpoints = c(-1, 1)), + gss_viz_sim %>% shade_confidence_interval(endpoints = c(-1, 1)), "\\`shade_confidence_interval\\(\\)\\` as a layer" ) expect_error( - iris_viz_sim %>% shade_ci(c(-1, 1)), + gss_viz_sim %>% shade_ci(c(-1, 1)), "\\`shade_ci\\(\\)\\` as a layer" ) expect_error( - iris_viz_sim %>% shade_ci(endpoints = c(-1, 1)), + gss_viz_sim %>% shade_ci(endpoints = c(-1, 1)), "\\`shade_ci\\(\\)\\` as a layer" ) }) diff --git a/tests/testthat/test-shade_p_value.R b/tests/testthat/test-shade_p_value.R index a715dc54..6c636e41 100644 --- a/tests/testthat/test-shade_p_value.R +++ b/tests/testthat/test-shade_p_value.R @@ -7,112 +7,112 @@ library(vdiffr) test_that("shade_p_value works", { # Adding `shade_p_value()` to simulation plot expect_doppelganger( - "pval-sim-right", iris_viz_sim + shade_p_value(1, "right") + "pval-sim-right", gss_viz_sim + shade_p_value(1, "right") ) - expect_doppelganger("pval-sim-left", iris_viz_sim + shade_p_value(1, "left")) - expect_doppelganger("pval-sim-both", iris_viz_sim + shade_p_value(1, "both")) - expect_doppelganger("pval-sim-null", iris_viz_sim + shade_p_value(1, NULL)) + expect_doppelganger("pval-sim-left", gss_viz_sim + shade_p_value(1, "left")) + expect_doppelganger("pval-sim-both", gss_viz_sim + shade_p_value(1, "both")) + expect_doppelganger("pval-sim-null", gss_viz_sim + shade_p_value(1, NULL)) expect_doppelganger( "pval-sim-corrupt", - expect_warning(iris_viz_sim + shade_p_value(1, "aaa"), "direction") + expect_warning(gss_viz_sim + shade_p_value(1, "aaa"), "direction") ) # Adding `shade_p_value()` to theoretical plot expect_doppelganger( - "pval-theor-right", iris_viz_theor + shade_p_value(1, "right") + "pval-theor-right", gss_viz_theor + shade_p_value(1, "right") ) expect_doppelganger( - "pval-theor-left", iris_viz_theor + shade_p_value(1, "left") + "pval-theor-left", gss_viz_theor + shade_p_value(1, "left") ) expect_doppelganger( - "pval-theor-both", iris_viz_theor + shade_p_value(1, "both") + "pval-theor-both", gss_viz_theor + shade_p_value(1, "both") ) expect_doppelganger( - "pval-theor-null", iris_viz_theor + shade_p_value(1, NULL) + "pval-theor-null", gss_viz_theor + shade_p_value(1, NULL) ) expect_doppelganger( "pval-theor-corrupt", - expect_warning(iris_viz_theor + shade_p_value(1, "aaa"), "direction") + expect_warning(gss_viz_theor + shade_p_value(1, "aaa"), "direction") ) # Adding `shade_p_value()` to "both" plot expect_doppelganger( - "pval-both-right", iris_viz_both + shade_p_value(1, "right") + "pval-both-right", gss_viz_both + shade_p_value(1, "right") ) expect_doppelganger( - "pval-both-left", iris_viz_both + shade_p_value(1, "left") + "pval-both-left", gss_viz_both + shade_p_value(1, "left") ) expect_doppelganger( - "pval-both-both", iris_viz_both + shade_p_value(1, "both") + "pval-both-both", gss_viz_both + shade_p_value(1, "both") ) expect_doppelganger( - "pval-both-null", iris_viz_both + shade_p_value(1, NULL) + "pval-both-null", gss_viz_both + shade_p_value(1, NULL) ) expect_doppelganger( "pval-both-corrupt", - expect_warning(iris_viz_both + shade_p_value(1, "aaa"), "direction") + expect_warning(gss_viz_both + shade_p_value(1, "aaa"), "direction") ) }) test_that("shade_p_value accepts synonyms for 'direction'", { expect_doppelganger( - "pval-direction-right", iris_viz_sim + shade_p_value(1, "greater") + "pval-direction-right", gss_viz_sim + shade_p_value(1, "greater") ) expect_doppelganger( - "pval-direction-left", iris_viz_sim + shade_p_value(1, "less") + "pval-direction-left", gss_viz_sim + shade_p_value(1, "less") ) # This currently results into the following {vdiffr} warning: # "Duplicated expectations: pval-direction-both, pval-direction-both" # However, having same figure here as expectation is exactly the goal of tests expect_doppelganger( - "pval-direction-both", iris_viz_sim + shade_p_value(1, "two_sided") + "pval-direction-both", gss_viz_sim + shade_p_value(1, "two_sided") ) expect_doppelganger( - "pval-direction-both", iris_viz_sim + shade_p_value(1, "two-sided") + "pval-direction-both", gss_viz_sim + shade_p_value(1, "two-sided") ) expect_doppelganger( - "pval-direction-both", iris_viz_sim + shade_p_value(1, "two sided") + "pval-direction-both", gss_viz_sim + shade_p_value(1, "two sided") ) }) test_that("shade_p_value uses extra aesthetic", { expect_doppelganger( "pval-extra-aes-1", - iris_viz_sim + shade_p_value(1, "two_sided", alpha = 1) + gss_viz_sim + shade_p_value(1, "two_sided", alpha = 1) ) expect_doppelganger( "pval-extra-aes-2", - iris_viz_sim + shade_p_value(1, "two_sided", linetype = "dotted") + gss_viz_sim + shade_p_value(1, "two_sided", linetype = "dotted") ) expect_doppelganger( "pval-extra-aes-3", - iris_viz_sim + shade_p_value(1, "two_sided", size = 4) + gss_viz_sim + shade_p_value(1, "two_sided", size = 4) ) }) test_that("shade_p_value accepts `NULL` as `obs_stat`", { expect_doppelganger( - "pval-null-obs_stat", iris_viz_sim + shade_p_value(NULL, "left") + "pval-null-obs_stat", gss_viz_sim + shade_p_value(NULL, "left") ) }) test_that("shade_p_value throws errors", { - expect_error(iris_viz_sim + shade_p_value("a", "right"), "numeric") - expect_error(iris_viz_sim + shade_p_value(1, 1), "character") - expect_error(iris_viz_sim + shade_p_value(1, "right", color = "x"), "color") - expect_error(iris_viz_sim + shade_p_value(1, "right", fill = "x"), "color") - expect_error(iris_viz_sim %>% shade_p_value(1, "right"), + expect_error(gss_viz_sim + shade_p_value("a", "right"), "numeric") + expect_error(gss_viz_sim + shade_p_value(1, 1), "character") + expect_error(gss_viz_sim + shade_p_value(1, "right", color = "x"), "color") + expect_error(gss_viz_sim + shade_p_value(1, "right", fill = "x"), "color") + expect_error(gss_viz_sim %>% shade_p_value(1, "right"), "\\`shade_p_value\\(\\)\\` as a layer") - expect_error(iris_viz_sim %>% shade_p_value(obs_stat = 1), + expect_error(gss_viz_sim %>% shade_p_value(obs_stat = 1), "\\`shade_p_value\\(\\)\\` as a layer") - expect_error(iris_viz_sim %>% shade_p_value(obs_stat = 1, + expect_error(gss_viz_sim %>% shade_p_value(obs_stat = 1, direction = "right"), "\\`shade_p_value\\(\\)\\` as a layer") - expect_error(iris_viz_sim %>% shade_pvalue(1, "right"), + expect_error(gss_viz_sim %>% shade_pvalue(1, "right"), "\\`shade_pvalue\\(\\)\\` as a layer") - expect_error(iris_viz_sim %>% shade_pvalue(obs_stat = 1), + expect_error(gss_viz_sim %>% shade_pvalue(obs_stat = 1), "\\`shade_pvalue\\(\\)\\` as a layer") - expect_error(iris_viz_sim %>% shade_pvalue(obs_stat = 1, + expect_error(gss_viz_sim %>% shade_pvalue(obs_stat = 1, direction = "right"), "\\`shade_pvalue\\(\\)\\` as a layer") diff --git a/tests/testthat/test-visualize.R b/tests/testthat/test-visualize.R index ece0552c..b56c85e8 100644 --- a/tests/testthat/test-visualize.R +++ b/tests/testthat/test-visualize.R @@ -5,58 +5,58 @@ library(vdiffr) set.seed(42) -Sepal.Width_resamp <- iris %>% - specify(Sepal.Width ~ NULL) %>% +hours_resamp <- gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", med = 3) %>% generate(reps = 10, type = "bootstrap") %>% calculate(stat = "median") -obs_slope <- lm(Sepal.Length ~ Sepal.Width, data = iris_tbl) %>% +obs_slope <- lm(age ~ hours, data = gss_tbl) %>% broom::tidy() %>% - dplyr::filter(term == "Sepal.Width") %>% + dplyr::filter(term == "hours") %>% dplyr::select(estimate) %>% dplyr::pull() -obs_diff <- iris_tbl %>% - group_by(Sepal.Length.Group) %>% - summarize(prop = mean(Sepal.Width.Group == ">5")) %>% +obs_diff <- gss_tbl %>% + group_by(college) %>% + summarize(prop = mean(college == "no degree")) %>% summarize(diff(prop)) %>% pull() obs_z <- sqrt( stats::prop.test( - x = table(iris_tbl$Sepal.Length.Group, iris_tbl$Sepal.Width.Group), - n = nrow(iris_tbl), + x = table(gss_tbl$college, gss_tbl$sex), + n = nrow(gss_tbl), alternative = "two.sided", correct = FALSE )$statistic ) -obs_diff_mean <- iris_tbl %>% - group_by(Sepal.Length.Group) %>% - summarize(mean_sepal_width = mean(Sepal.Width)) %>% +obs_diff_mean <- gss_tbl %>% + group_by(college) %>% + summarize(mean_sepal_width = mean(hours)) %>% summarize(diff(mean_sepal_width)) %>% pull() -obs_t <- iris_tbl %>% - t_stat(Sepal.Width ~ Sepal.Length.Group, order = c("<=5", ">5")) +obs_t <- gss_tbl %>% + t_stat(hours ~ college, order = c("no degree", "degree")) obs_F <- anova( - aov(formula = Sepal.Width ~ Species, data = iris_tbl) + aov(formula = hours ~ partyid, data = gss_tbl) )$`F value`[1] test_that("visualize basic tests", { - expect_doppelganger("visualize", visualize(Sepal.Width_resamp)) + expect_doppelganger("visualize", visualize(hours_resamp)) # visualise also works - expect_doppelganger("visualise", visualise(Sepal.Width_resamp)) + expect_doppelganger("visualise", visualise(hours_resamp)) - expect_error(Sepal.Width_resamp %>% visualize(bins = "yep")) + expect_error(hours_resamp %>% visualize(bins = "yep")) expect_doppelganger( "vis-sim-right-1", expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Sepal.Width) %>% + gss_tbl %>% + specify(age ~ hours) %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% calculate(stat = "slope") %>% @@ -67,22 +67,22 @@ test_that("visualize basic tests", { # obs_stat not specified expect_error( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "diff in props", order = c(">5", "<=5")) %>% + calculate(stat = "diff in props", order = c("no degree", "degree")) %>% visualize(direction = "both") ) expect_doppelganger( "vis-sim-both-1", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "diff in props", order = c(">5", "<=5")) %>% + calculate(stat = "diff in props", order = c("no degree", "degree")) %>% visualize(direction = "both", obs_stat = obs_diff), "deprecated" ) @@ -91,10 +91,10 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-none-1", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% - calculate(stat = "z", order = c(">5", "<=5")) %>% + calculate(stat = "z", order = c("no degree", "degree")) %>% visualize(method = "theoretical") ) ) @@ -102,11 +102,11 @@ test_that("visualize basic tests", { # diff in props and z on different scales expect_error( expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "diff in props", order = c(">5", "<=5")) %>% + calculate(stat = "diff in props", order = c("no degree", "degree")) %>% visualize(method = "both", direction = "both", obs_stat = obs_diff) ) ) @@ -114,11 +114,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-sim-none-1", expect_silent( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "diff in props", order = c(">5", "<=5")) %>% + calculate(stat = "diff in props", order = c("no degree", "degree")) %>% visualize() ) ) @@ -126,11 +126,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-both-1", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "z", order = c(">5", "<=5")) %>% + calculate(stat = "z", order = c("no degree", "degree")) %>% visualize(method = "both", direction = "both", obs_stat = obs_z) ) ) @@ -138,11 +138,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-both-2", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "z", order = c("<=5", ">5")) %>% + calculate(stat = "z", order = c("degree", "no degree")) %>% visualize(method = "both", direction = "both", obs_stat = -obs_z) ) ) @@ -150,11 +150,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-left-1", expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Sepal.Width.Group) %>% + gss_tbl %>% + specify(age ~ sex) %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "t", order = c("small", "large")) %>% + calculate(stat = "t", order = c("female", "male")) %>% visualize(method = "both", direction = "left", obs_stat = obs_t) ) ) @@ -162,11 +162,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-left-1", expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Sepal.Width.Group) %>% + gss_tbl %>% + specify(age ~ sex) %>% hypothesize(null = "independence") %>% # generate(reps = 100, type = "permute") %>% - calculate(stat = "t", order = c("small", "large")) %>% + calculate(stat = "t", order = c("female", "male")) %>% visualize(method = "theoretical", direction = "left", obs_stat = obs_t) ) ) @@ -174,8 +174,8 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-none-1", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 1) %>% generate(reps = 100) %>% calculate(stat = "t") %>% @@ -186,8 +186,8 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-none-2", expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Sepal.Length.Group) %>% + gss_tbl %>% + specify(age ~ college) %>% hypothesize(null = "independence") %>% visualize(method = "theoretical") ) @@ -196,8 +196,8 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-none-3", expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Species) %>% + gss_tbl %>% + specify(age ~ partyid) %>% hypothesize(null = "independence") %>% visualize(method = "theoretical") ) @@ -206,8 +206,8 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-right-1", expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Species) %>% + gss_tbl %>% + specify(age ~ partyid) %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% calculate(stat = "F") %>% @@ -218,11 +218,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-left-2", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl %>% + specify(sex ~ college, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "z", order = c(">5", "<=5")) %>% + calculate(stat = "z", order = c("no degree", "degree")) %>% visualize(method = "both", direction = "left", obs_stat = obs_z) ) ) @@ -230,8 +230,8 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-both-right-2", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Species, success = "large") %>% + gss_tbl %>% + specify(sex ~ partyid, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% calculate(stat = "Chisq") %>% @@ -242,22 +242,24 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-right-1", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Species, success = "large") %>% + gss_tbl %>% + specify(sex ~ partyid, success = "female") %>% hypothesize(null = "independence") %>% # calculate(stat = "Chisq") %>% - visualize(method = "theoretical", obs_stat = obs_F, direction = "right") + visualize(method = "theoretical", + obs_stat = obs_F, + direction = "right") ) ) expect_doppelganger( "vis-both-none-2", expect_warning( - iris_tbl %>% - specify(Species ~ NULL) %>% + gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize( null = "point", - p = c("setosa" = 0.4, "versicolor" = 0.4, "virginica" = 0.2) + p = c("dem" = 0.4, "rep" = 0.4, "ind" = 0.2) ) %>% generate(reps = 100, type = "simulate") %>% calculate(stat = "Chisq") %>% @@ -267,11 +269,11 @@ test_that("visualize basic tests", { # traditional instead of theoretical expect_error( - iris_tbl %>% - specify(Species ~ NULL) %>% + gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize( null = "point", - p = c("setosa" = 0.4, "versicolor" = 0.4, "virginica" = 0.2) + p = c("dem" = 0.4, "rep" = 0.4, "ind" = 0.2) ) %>% # generate(reps = 100, type = "simulate") %>% # calculate(stat = "Chisq") %>% @@ -281,11 +283,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-none-4", expect_warning( - iris_tbl %>% - specify(Species ~ NULL) %>% + gss_tbl %>% + specify(partyid ~ NULL) %>% hypothesize( null = "point", - p = c("setosa" = 0.4, "versicolor" = 0.4, "virginica" = 0.2) + p = c("dem" = 0.4, "rep" = 0.4, "ind" = 0.2) ) %>% # generate(reps = 100, type = "simulate") %>% # calculate(stat = "Chisq") %>% @@ -296,11 +298,11 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-sim-both-2", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ Sepal.Width.Group) %>% + gss_tbl %>% + specify(hours ~ sex) %>% hypothesize(null = "independence") %>% generate(reps = 10, type = "permute") %>% - calculate(stat = "diff in means", order = c("large", "small")) %>% + calculate(stat = "diff in means", order = c("female", "male")) %>% visualize(direction = "both", obs_stat = obs_diff_mean), "deprecated" ) @@ -309,25 +311,30 @@ test_that("visualize basic tests", { # Produces warning first for not checking conditions but would also error expect_error( expect_warning( - iris_tbl %>% - specify(Petal.Width ~ Sepal.Width.Group) %>% + gss_tbl %>% + specify(hours ~ sex) %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "diff in means", order = c("large", "small")) %>% - visualize(method = "both", direction = "both", obs_stat = obs_diff_mean) + calculate(stat = "diff in means", + order = c("female", "male")) %>% + visualize(method = "both", + direction = "both", + obs_stat = obs_diff_mean) ) ) expect_doppelganger( "vis-theor-both-1", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ Sepal.Width.Group) %>% + gss_tbl %>% + specify(hours ~ sex) %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% - calculate(stat = "diff in means", order = c("large", "small")) %>% + calculate(stat = "diff in means", order = c("female", "male")) %>% visualize( - method = "theoretical", direction = "both", obs_stat = obs_diff_mean + method = "theoretical", + direction = "both", + obs_stat = obs_diff_mean ) ) ) @@ -335,8 +342,8 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-theor-both-2", expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ NULL, success = "small") %>% + gss_tbl %>% + specify(sex ~ NULL, success = "female") %>% hypothesize(null = "point", p = 0.8) %>% # generate(reps = 100, type = "simulate") %>% # calculate(stat = "z") %>% @@ -351,12 +358,12 @@ test_that("visualize basic tests", { expect_doppelganger( "vis-sim-left-1", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 1.3) %>% generate(reps = 100, type = "bootstrap") %>% calculate(stat = "mean") %>% - visualize(direction = "left", obs_stat = mean(iris$Petal.Width)), + visualize(direction = "left", obs_stat = mean(gss_tbl$hours)), "deprecated" ) ) @@ -367,14 +374,14 @@ test_that("mirror_obs_stat works", { }) test_that("obs_stat as a data.frame works", { - mean_petal_width <- iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + mean_petal_width <- gss_tbl %>% + specify(hours ~ NULL) %>% calculate(stat = "mean") expect_doppelganger( "df-obs_stat-1", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 4) %>% generate(reps = 100, type = "bootstrap") %>% calculate(stat = "mean") %>% @@ -387,8 +394,8 @@ test_that("obs_stat as a data.frame works", { expect_doppelganger( "df-obs_stat-2", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 4) %>% generate(reps = 100, type = "bootstrap") %>% calculate(stat = "mean") %>% @@ -403,8 +410,8 @@ test_that('method = "both" behaves nicely', { # 'to `visualize(method = "both")`' # ) expect_error( - iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + gss_tbl %>% + specify(hours ~ NULL) %>% hypothesize(null = "point", mu = 4) %>% generate(reps = 100, type = "bootstrap") %>% # calculate(stat = "mean") %>% @@ -414,11 +421,11 @@ test_that('method = "both" behaves nicely', { expect_doppelganger( "method-both", expect_warning( - iris_tbl %>% - specify(Petal.Width ~ Sepal.Length.Group) %>% + gss_tbl %>% + specify(hours ~ college) %>% hypothesize(null = "point", mu = 4) %>% generate(reps = 10, type = "bootstrap") %>% - calculate(stat = "t", order = c(">5", "<=5")) %>% + calculate(stat = "t", order = c("no degree", "degree")) %>% visualize(method = "both") ) ) @@ -426,32 +433,32 @@ test_that('method = "both" behaves nicely', { test_that("Traditional right-tailed tests have warning if not right-tailed", { expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Species, success = "large") %>% + gss_tbl %>% + specify(sex ~ partyid, success = "female") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% calculate(stat = "Chisq") %>% visualize(method = "both", obs_stat = 2, direction = "left") ) expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Species) %>% + gss_tbl %>% + specify(age ~ partyid) %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% calculate(stat = "F") %>% visualize(method = "both", obs_stat = 2, direction = "two_sided") ) expect_warning( - iris_tbl %>% - specify(Sepal.Width.Group ~ Species, success = "large") %>% + gss_tbl %>% + specify(sex ~ partyid, success = "female") %>% hypothesize(null = "independence") %>% # generate(reps = 100, type = "permute") %>% calculate(stat = "Chisq") %>% visualize(method = "theoretical", obs_stat = 2, direction = "left") ) expect_warning( - iris_tbl %>% - specify(Sepal.Length ~ Species) %>% + gss_tbl %>% + specify(age ~ partyid) %>% hypothesize(null = "independence") %>% # generate(reps = 100, type = "permute") %>% calculate(stat = "F") %>% @@ -460,47 +467,47 @@ test_that("Traditional right-tailed tests have warning if not right-tailed", { }) test_that("confidence interval plots are working", { - iris_boot <- iris_tbl %>% - specify(Sepal.Width.Group ~ Sepal.Length.Group, success = "large") %>% + gss_tbl_boot <- gss_tbl %>% + specify(sex ~ college, success = "female") %>% generate(reps = 100) %>% - calculate(stat = "diff in props", order = c(">5", "<=5")) + calculate(stat = "diff in props", order = c("no degree", "degree")) df_error <- tibble::tibble(col1 = rnorm(5), col2 = rnorm(5)) vec_error <- 1:10 - perc_ci <- iris_boot %>% get_ci() + perc_ci <- gss_tbl_boot %>% get_ci() - expect_error(iris_boot %>% visualize(endpoints = df_error)) + expect_error(gss_tbl_boot %>% visualize(endpoints = df_error)) - expect_warning(iris_boot %>% visualize(endpoints = vec_error)) + expect_warning(gss_tbl_boot %>% visualize(endpoints = vec_error)) expect_doppelganger( "ci-vis", expect_warning( - iris_boot %>% visualize(endpoints = perc_ci, direction = "between"), + gss_tbl_boot %>% visualize(endpoints = perc_ci, direction = "between"), "deprecated" ) ) - expect_warning(iris_boot %>% visualize(obs_stat = 3, endpoints = perc_ci)) + expect_warning(gss_tbl_boot %>% visualize(obs_stat = 3, endpoints = perc_ci)) }) test_that("title adapts to not hypothesis testing workflow", { set.seed(100) - iris_boot_tbl <- iris_tbl %>% - specify(response = Sepal.Width) %>% + gss_tbl_boot_tbl <- gss_tbl %>% + specify(response = hours) %>% generate(reps = 100, type = "bootstrap") expect_doppelganger( "vis-no-hypothesize-sim", - iris_boot_tbl %>% + gss_tbl_boot_tbl %>% calculate(stat = "mean") %>% visualize() ) expect_doppelganger( "vis-no-hypothesize-both", expect_warning( - iris_boot_tbl %>% + gss_tbl_boot_tbl %>% calculate(stat = "t") %>% visualize(method = "both") ) @@ -522,8 +529,8 @@ test_that("warn_right_tail_test works", { }) test_that("visualize warns about removing `NaN`", { - dist <- iris_boot_tbl <- iris_tbl %>% - specify(response = Sepal.Width) %>% + dist <- gss_tbl_boot_tbl <- gss_tbl %>% + specify(response = hours) %>% generate(reps = 10, type = "bootstrap") %>% calculate("mean") diff --git a/tests/testthat/test-wrappers.R b/tests/testthat/test-wrappers.R index 5ea2e719..9530932b 100644 --- a/tests/testthat/test-wrappers.R +++ b/tests/testthat/test-wrappers.R @@ -1,30 +1,21 @@ context("wrappers") -iris2 <- iris %>% - dplyr::filter(Species != "setosa") %>% - droplevels(.$Species) - -iris3 <- iris %>% - dplyr::mutate( - Sepal.Length.Group = dplyr::if_else(Sepal.Length > 5, ">5", "<=5") - ) - test_that("t_test works", { # Two Sample - expect_warning(iris2 %>% t_test(Sepal.Width ~ Species)) + expect_warning(gss_tbl %>% t_test(hours ~ sex)) expect_error( - iris2 %>% t_test(response = "Sepal.Width", explanatory = "Species") + gss_tbl %>% t_test(response = "hours", explanatory = "sex") ) - new_way <- t_test(iris2, - Sepal.Width ~ Species, - order = c("versicolor", "virginica")) - new_way_alt <- t_test(iris2, - response = Sepal.Width, - explanatory = Species, - order = c("versicolor", "virginica")) - old_way <- t.test(Sepal.Width ~ Species, data = iris2) %>% + new_way <- t_test(gss_tbl, + hours ~ sex, + order = c("male", "female")) + new_way_alt <- t_test(gss_tbl, + response = hours, + explanatory = sex, + order = c("male", "female")) + old_way <- t.test(hours ~ sex, data = gss_tbl) %>% broom::glance() %>% dplyr::select(statistic, t_df = parameter, p_value = p.value, alternative, lower_ci = conf.low, upper_ci = conf.high) @@ -33,18 +24,18 @@ test_that("t_test works", { expect_equal(new_way, old_way, tolerance = 1e-5) # check that the order argument changes output - new_way2 <- t_test(iris2, - Sepal.Width ~ Species, - order = c("virginica", "versicolor")) + new_way2 <- t_test(gss_tbl, + hours ~ sex, + order = c("female", "male")) expect_equal(new_way[["lower_ci"]], -new_way2[["upper_ci"]]) expect_equal(new_way[["statistic"]], -new_way2[["statistic"]]) # One Sample - new_way <- iris2 %>% - t_test(Sepal.Width ~ NULL, mu = 0) - new_way_alt <- iris2 %>% - t_test(response = Sepal.Width, mu = 0) - old_way <- t.test(x = iris2$Sepal.Width, mu = 0) %>% + new_way <- gss_tbl %>% + t_test(hours ~ NULL, mu = 0) + new_way_alt <- gss_tbl %>% + t_test(response = hours, mu = 0) + old_way <- t.test(x = gss_tbl$hours, mu = 0) %>% broom::glance() %>% dplyr::select(statistic, t_df = parameter, p_value = p.value, alternative, lower_ci = conf.low, upper_ci = conf.high) @@ -54,14 +45,14 @@ test_that("t_test works", { }) test_that("chisq_test works", { - # Independence - expect_silent(iris3 %>% - chisq_test(Sepal.Length.Group ~ Species)) - new_way <- iris3 %>% - chisq_test(Sepal.Length.Group ~ Species) - new_way_alt <- iris3 %>% - chisq_test(response = Sepal.Length.Group, explanatory = Species) - old_way <- chisq.test(x = table(iris3$Species, iris3$Sepal.Length.Group)) %>% + # maleependence + expect_silent(gss_tbl %>% + chisq_test(college ~ partyid)) + new_way <- gss_tbl %>% + chisq_test(college ~ partyid) + new_way_alt <- gss_tbl %>% + chisq_test(response = college, explanatory = partyid) + old_way <- chisq.test(x = table(gss_tbl$partyid, gss_tbl$college)) %>% broom::glance() %>% dplyr::select(statistic, chisq_df = parameter, p_value = p.value) @@ -70,13 +61,13 @@ test_that("chisq_test works", { #expect_equal(new_way, old_way, tolerance = .Machine$double.eps^0.25) # Goodness of Fit - expect_silent(iris3 %>% - chisq_test(response = Species, p = c(.3, .4, .3))) - new_way <- iris3 %>% - chisq_test(Species ~ NULL, p = c(.3, .4, .3)) - new_way_alt <- iris3 %>% - chisq_test(response = Species, p = c(.3, .4, .3)) - old_way <- chisq.test(x = table(iris3$Species), p = c(.3, .4, .3)) %>% + expect_silent(gss_tbl %>% + chisq_test(response = partyid, p = c(.3, .4, .3))) + new_way <- gss_tbl %>% + chisq_test(partyid ~ NULL, p = c(.3, .4, .3)) + new_way_alt <- gss_tbl %>% + chisq_test(response = partyid, p = c(.3, .4, .3)) + old_way <- chisq.test(x = table(gss_tbl$partyid), p = c(.3, .4, .3)) %>% broom::glance() %>% dplyr::select(statistic, chisq_df = parameter, p_value = p.value) @@ -84,100 +75,100 @@ test_that("chisq_test works", { expect_equal(new_way, old_way, tolerance = 1e-5) # check that function errors out when response is numeric - expect_error(chisq_test(x = iris2, response = Sepal.Length, explanatory = Species)) + expect_error(chisq_test(x = gss_tbl, response = age, explanatory = partyid)) # check that function errors out when explanatory is numeric - expect_error(chisq_test(x = iris2, response = Species, explanatory = Sepal.Length)) + expect_error(chisq_test(x = gss_tbl, response = partyid, explanatory = age)) }) test_that("_stat functions work", { - # Test of independence - expect_silent(iris3 %>% chisq_stat(Sepal.Length.Group ~ Species)) - another_way <- iris3 %>% - chisq_test(Sepal.Length.Group ~ Species) %>% + # Test of maleependence + expect_silent(gss_tbl %>% chisq_stat(college ~ partyid)) + another_way <- gss_tbl %>% + chisq_test(college ~ partyid) %>% dplyr::select(statistic) - obs_stat_way <- iris3 %>% chisq_stat(Sepal.Length.Group ~ Species) + obs_stat_way <- gss_tbl %>% chisq_stat(college ~ partyid) one_more <- chisq.test( - table(iris3$Species, iris3$Sepal.Length.Group) + table(gss_tbl$partyid, gss_tbl$college) )$statistic expect_equivalent(dplyr::pull(another_way), obs_stat_way) expect_equivalent(one_more, obs_stat_way) # Goodness of Fit - new_way <- iris3 %>% - chisq_test(Species ~ NULL) %>% + new_way <- gss_tbl %>% + chisq_test(partyid ~ NULL) %>% dplyr::select(statistic) - obs_stat_way <- iris3 %>% - chisq_stat(Species ~ NULL) - obs_stat_way_alt <- iris3 %>% - chisq_stat(response = Species) + obs_stat_way <- gss_tbl %>% + chisq_stat(partyid ~ NULL) + obs_stat_way_alt <- gss_tbl %>% + chisq_stat(response = partyid) expect_equivalent(dplyr::pull(new_way), obs_stat_way) expect_equivalent(dplyr::pull(new_way), obs_stat_way_alt) # robust to the named vector - unordered_p <- iris3 %>% - chisq_test(response = Species, p = c(.2, .3, .5)) - ordered_p <- iris3 %>% - chisq_test(response = Species, p = c(virginica = .5, versicolor = .3, setosa = .2)) + unordered_p <- gss_tbl %>% + chisq_test(response = partyid, p = c(.2, .3, .5)) + ordered_p <- gss_tbl %>% + chisq_test(response = partyid, p = c(ind = .2, rep = .3, dem = .5)) expect_equivalent(unordered_p, ordered_p) # Two sample t expect_silent( - iris2 %>% t_stat( - Sepal.Width ~ Species, order = c("virginica", "versicolor") + gss_tbl %>% t_stat( + hours ~ sex, order = c("male", "female") ) ) - another_way <- iris2 %>% - t_test(Sepal.Width ~ Species, order = c("virginica", "versicolor")) %>% + another_way <- gss_tbl %>% + t_test(hours ~ sex, order = c("male", "female")) %>% dplyr::select(statistic) %>% pull() - obs_stat_way <- iris2 %>% - t_stat(Sepal.Width ~ Species, order = c("virginica", "versicolor")) - obs_stat_way_alt <- iris2 %>% - t_stat(response = Sepal.Width, - explanatory = Species, - order = c("virginica", "versicolor")) + obs_stat_way <- gss_tbl %>% + t_stat(hours ~ sex, order = c("male", "female")) + obs_stat_way_alt <- gss_tbl %>% + t_stat(response = hours, + explanatory = sex, + order = c("male", "female")) expect_equivalent(another_way, obs_stat_way) expect_equivalent(another_way, obs_stat_way_alt) # One sample t - expect_silent(iris2 %>% t_stat(Sepal.Width ~ NULL)) - another_way <- iris2 %>% - t_test(Sepal.Width ~ NULL) %>% + expect_silent(gss_tbl %>% t_stat(hours ~ NULL)) + another_way <- gss_tbl %>% + t_test(hours ~ NULL) %>% dplyr::select(statistic) %>% pull() - obs_stat_way <- iris2 %>% - t_stat(Sepal.Width ~ NULL) - obs_stat_way_alt <- iris2 %>% - t_stat(response = Sepal.Width) + obs_stat_way <- gss_tbl %>% + t_stat(hours ~ NULL) + obs_stat_way_alt <- gss_tbl %>% + t_stat(response = hours) expect_equivalent(another_way, obs_stat_way) expect_equivalent(another_way, obs_stat_way_alt) - expect_error(chisq_stat(x = iris2, response = Sepal.Length, explanatory = Species)) - expect_error(chisq_stat(x = iris2, response = Species, explanatory = Sepal.Length)) + expect_error(chisq_stat(x = gss_tbl, response = age, explanatory = sex)) + expect_error(chisq_stat(x = gss_tbl, response = sex, explanatory = age)) }) test_that("conf_int argument works", { expect_equal( names( - iris2 %>% - t_test(Sepal.Width ~ Species, - order = c("virginica", "versicolor"), conf_int = FALSE) + gss_tbl %>% + t_test(hours ~ sex, + order = c("male", "female"), conf_int = FALSE) ), c("statistic", "t_df", "p_value", "alternative"), tolerance = 1e-5 ) expect_equal( names( - iris2 %>% + gss_tbl %>% t_test( - Sepal.Width ~ Species, order = c("virginica", "versicolor"), + hours ~ sex, order = c("male", "female"), conf_int = TRUE ) ), @@ -185,54 +176,57 @@ test_that("conf_int argument works", { tolerance = 1e-5 ) - ci_test <- iris2 %>% + ci_test <- gss_tbl %>% t_test( - Sepal.Width ~ Species, order = c("versicolor", "virginica"), + hours ~ sex, order = c("male", "female"), conf_int = TRUE, conf_level = 0.9 ) old_way <- t.test( - formula = Sepal.Width ~ Species, data = iris2, conf.level = 0.9 + formula = hours ~ sex, data = gss_tbl, conf.level = 0.9 )[["conf.int"]] expect_equal(ci_test$lower_ci[1], old_way[1], tolerance = 1e-5) expect_equal(ci_test$upper_ci[1], old_way[2], tolerance = 1e-5) expect_error( - iris2 %>% + gss_tbl %>% t_test( - Petal.Width ~ Species, order = c("versicolor", "virginica"), + hours ~ sex, order = c("female", "male"), conf_int = TRUE, conf_level = 1.1 ) ) # Check that var.equal produces different results - # Thanks for finding this @EllaKaye! - iris_small <- iris2 %>% slice(1:6, 90:100) + # Thanks for fmaleing this @EllaKaye! + gss_tbl_small <- gss_tbl %>% slice(1:6, 90:100) - no_var_equal <- iris_small %>% - t_stat(Petal.Width ~ Species, order = c("versicolor", "virginica")) + no_var_equal <- gss_tbl_small %>% + t_stat(hours ~ sex, order = c("female", "male")) - var_equal <- iris_small %>% + var_equal <- gss_tbl_small %>% t_stat( - Petal.Width ~ Species, order = c("versicolor", "virginica"), + hours ~ sex, order = c("female", "male"), var.equal = TRUE ) expect_false(no_var_equal == var_equal) - shortcut_no_var_equal <- iris_small %>% - specify(Petal.Width ~ Species) %>% - calculate(stat = "t", order = c("versicolor", "virginica")) + shortcut_no_var_equal <- gss_tbl_small %>% + specify(hours ~ sex) %>% + calculate(stat = "t", order = c("female", "male")) - shortcut_var_equal <- iris_small %>% - specify(Petal.Width ~ Species) %>% + shortcut_var_equal <- gss_tbl_small %>% + specify(hours ~ sex) %>% calculate( - stat = "t", order = c("versicolor", "virginica"), + stat = "t", order = c("female", "male"), var.equal = TRUE ) expect_false(shortcut_no_var_equal == shortcut_var_equal) }) # generate some data to test the prop.test wrapper -df <- data.frame(resp = c(rep("c", 450), rep("d", 50), rep("c", 400), rep("d", 100)), +df <- data.frame(resp = c(rep("c", 450), + rep("d", 50), + rep("c", 400), + rep("d", 100)), exp = rep(c("a", "b"), each = 500)) sum_df <- table(df) From bddd4641a98149e98dfc059f118fe1ed6314bc3a Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 21 Jun 2020 12:38:01 +0300 Subject: [PATCH 02/28] Style 'get_confidence_interval.R'. --- R/get_confidence_interval.R | 61 ++++++++++++++++++++-------------- man/get_confidence_interval.Rd | 12 ++++--- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/R/get_confidence_interval.R b/R/get_confidence_interval.R index 3142a525..88f0d9c2 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -20,6 +20,7 @@ #' #' @return A 1 x 2 tibble with values corresponding to lower and upper values in #' the confidence interval. +#' #' @section Aliases: #' `get_ci()` is an alias of `get_confidence_interval()`. #' `conf_int()` is a deprecated alias of `get_confidence_interval()`. @@ -43,11 +44,13 @@ #' # finding the null distribution #' calculate(stat = "mean") %>% # # calculate the confidence interval around the point estimate -#' get_confidence_interval(point_estimate = point_estimate, -#' # at the 95% confidence level -#' level = .95, -#' # using the standard error method -#' type = "se") +#' get_confidence_interval( +#' point_estimate = point_estimate, +#' # at the 95% confidence level +#' level = 0.95, +#' # using the standard error method +#' type = "se" +#' ) #' #' # More in-depth explanation of how to use the infer package #' \dontrun{ @@ -57,59 +60,67 @@ #' @name get_confidence_interval #' @export get_confidence_interval <- function(x, level = 0.95, type = "percentile", - point_estimate = NULL){ - + point_estimate = NULL) { check_ci_args(x, level, type, point_estimate) - if(type == "percentile") { - ci_vec <- stats::quantile(x[["stat"]], - probs = c((1 - level) / 2, level + (1 - level) / 2)) - + if (type == "percentile") { + ci_vec <- stats::quantile( + x[["stat"]], + probs = c((1 - level) / 2, level + (1 - level) / 2) + ) + ci <- tibble::tibble(ci_vec[1], ci_vec[2]) names(ci) <- names(ci_vec) } else { point_estimate <- check_obs_stat(point_estimate) multiplier <- stats::qnorm(1 - (1 - level) / 2) + ci <- tibble::tibble( lower = point_estimate - multiplier * stats::sd(x[["stat"]]), - upper = point_estimate + multiplier * stats::sd(x[["stat"]])) + upper = point_estimate + multiplier * stats::sd(x[["stat"]]) + ) } - return(ci) + ci } #' @rdname get_confidence_interval #' @export get_ci <- function(x, level = 0.95, type = "percentile", - point_estimate = NULL) { + point_estimate = NULL) { get_confidence_interval( x, level = level, type = type, point_estimate = point_estimate ) } check_ci_args <- function(x, level, type, point_estimate){ - - if(!is.null(point_estimate)){ - if(!is.data.frame(point_estimate)) + if (!is.null(point_estimate)) { + if (!is.data.frame(point_estimate)) { check_type(point_estimate, is.numeric) - else + } else { check_type(point_estimate, is.data.frame) + } } check_type(x, is.data.frame) check_type(level, is.numeric) - if(level <= 0 || level >= 1){ + + if ((level <= 0) || (level >= 1)) { stop_glue("The value of `level` must be between 0 and 1 non-inclusive.") } - if(!(type %in% c("percentile", "se"))){ + if (!(type %in% c("percentile", "se"))) { stop_glue('The options for `type` are "percentile" or "se".') } - if(type == "se" && is.null(point_estimate)) - stop_glue('A numeric value needs to be given for `point_estimate` ', - 'for `type = "se"') + if ((type == "se") && is.null(point_estimate)) { + stop_glue( + 'A numeric value needs to be given for `point_estimate` ', + 'for `type = "se"' + ) + } - if(type == "se" && is.vector(point_estimate)) - check_type(point_estimate, is.numeric) + if ((type == "se") && is.vector(point_estimate)) { + check_type(point_estimate, is.numeric) + } } diff --git a/man/get_confidence_interval.Rd b/man/get_confidence_interval.Rd index 7392d66b..9c4da4e6 100644 --- a/man/get_confidence_interval.Rd +++ b/man/get_confidence_interval.Rd @@ -63,11 +63,13 @@ gss \%>\% generate(reps = 1000, type = "bootstrap") \%>\% # finding the null distribution calculate(stat = "mean") \%>\% - get_confidence_interval(point_estimate = point_estimate, - # at the 95\% confidence level - level = .95, - # using the standard error method - type = "se") + get_confidence_interval( + point_estimate = point_estimate, + # at the 95\% confidence level + level = 0.95, + # using the standard error method + type = "se" + ) # More in-depth explanation of how to use the infer package \dontrun{ From 2c47bdd21241821a2856a29e1a2137d85947c772 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 21 Jun 2020 13:31:29 +0300 Subject: [PATCH 03/28] Update `get_confidence_interval()` tests. --- tests/testthat/test-get_confidence_interval.R | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 06553dd9..99f3c387 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -1,20 +1,54 @@ context("conf_int") -test_that("basics work", { - expect_silent(test_df %>% get_confidence_interval()) - expect_error(test_df %>% get_confidence_interval(type = "other")) - expect_error(test_df %>% get_confidence_interval(level = 1.2)) - expect_error(test_df %>% get_confidence_interval(point_estimate = "help")) +test_that("get_confidence_interval works", { + perc_basic_out <- tibble::tibble( + `2.5%` = quantile(test_df[["stat"]], 0.025), + `97.5%` = quantile(test_df[["stat"]], 0.975) + ) + expect_equal(test_df %>% get_confidence_interval(), perc_basic_out) + + # Type "percentile" + expect_equal( + test_df %>% get_confidence_interval(type = "percentile"), perc_basic_out + ) + expect_equal( + test_df %>% get_confidence_interval(level = 0.5, type = "percentile"), + tibble::tibble( + `25%` = quantile(test_df[["stat"]], 0.25), + `75%` = quantile(test_df[["stat"]], 0.75) + ) + ) + + # Type "se" + point <- mean(test_df[["stat"]]) + expect_equal( + test_df %>% get_confidence_interval(type = "se", point_estimate = point), + tibble::tibble(lower = -1.965, upper = 2.008), + tolerance = 1e-3 + ) + expect_equal( + test_df %>% + get_confidence_interval(level = 0.5, type = "se", point_estimate = point), + tibble::tibble(lower = -0.662, upper = 0.705), + tolerance = 1e-3 + ) +}) - expect_silent(gss_calc %>% - get_confidence_interval(type = "se", - point_estimate = 4)) - expect_silent(gss_calc %>% - get_confidence_interval(type = "se", - point_estimate = obs_diff)) - expect_error(gss_calc %>% - get_confidence_interval(type = "se", - point_estimate = "error")) - expect_error(gss_calc %>% - get_confidence_interval(type = "se")) +test_that("get_confidence_interval checks input", { + expect_error(test_df %>% get_confidence_interval(type = "other"), "`type`") + expect_error(test_df %>% get_confidence_interval(level = 1.2), "`level`") + + expect_error( + test_df %>% get_confidence_interval(point_estimate = "a"), + "`point_estimate`" + ) + expect_error( + gss_calc %>% get_confidence_interval(type = "se", point_estimate = "a"), + "`point_estimate`" + ) + + expect_error( + gss_calc %>% get_confidence_interval(type = "se"), + '`point_estimate`.*type = "se"' + ) }) From b1374ef2fa49fcca23c8c52801619e8af9484fe1 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 21 Jun 2020 13:42:06 +0300 Subject: [PATCH 04/28] Refactor `get_confidence_interval()`. --- R/get_confidence_interval.R | 46 +++++++++---------- tests/testthat/test-get_confidence_interval.R | 31 ++++++++++--- 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/R/get_confidence_interval.R b/R/get_confidence_interval.R index 88f0d9c2..562c7802 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -62,26 +62,12 @@ get_confidence_interval <- function(x, level = 0.95, type = "percentile", point_estimate = NULL) { check_ci_args(x, level, type, point_estimate) - - if (type == "percentile") { - ci_vec <- stats::quantile( - x[["stat"]], - probs = c((1 - level) / 2, level + (1 - level) / 2) - ) - - ci <- tibble::tibble(ci_vec[1], ci_vec[2]) - names(ci) <- names(ci_vec) - } else { - point_estimate <- check_obs_stat(point_estimate) - multiplier <- stats::qnorm(1 - (1 - level) / 2) - - ci <- tibble::tibble( - lower = point_estimate - multiplier * stats::sd(x[["stat"]]), - upper = point_estimate + multiplier * stats::sd(x[["stat"]]) - ) - } - - ci + + switch( + type, + percentile = ci_percentile(x, level), + se = ci_se(x, level, point_estimate) + ) } #' @rdname get_confidence_interval @@ -93,12 +79,28 @@ get_ci <- function(x, level = 0.95, type = "percentile", ) } +ci_percentile <- function(x, level) { + ci_vec <- stats::quantile(x[["stat"]], probs = (1 + c(-level, level)) / 2) + + tibble::as_tibble(as.list(ci_vec)) +} + +ci_se <- function(x, level, point_estimate) { + point_estimate <- check_obs_stat(point_estimate) + + multiplier <- stats::qnorm((1 + level) / 2) + ci_vec <- point_estimate + c(-multiplier, multiplier) * stats::sd(x[["stat"]]) + + tibble::tibble(lower = ci_vec[[1]], upper = ci_vec[[2]]) +} + check_ci_args <- function(x, level, type, point_estimate){ if (!is.null(point_estimate)) { if (!is.data.frame(point_estimate)) { check_type(point_estimate, is.numeric) } else { check_type(point_estimate, is.data.frame) + check_type(point_estimate[[1]][[1]], is.numeric) } } check_type(x, is.data.frame) @@ -118,9 +120,5 @@ check_ci_args <- function(x, level, type, point_estimate){ 'for `type = "se"' ) } - - if ((type == "se") && is.vector(point_estimate)) { - check_type(point_estimate, is.numeric) - } } diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 99f3c387..164571c1 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -2,8 +2,8 @@ context("conf_int") test_that("get_confidence_interval works", { perc_basic_out <- tibble::tibble( - `2.5%` = quantile(test_df[["stat"]], 0.025), - `97.5%` = quantile(test_df[["stat"]], 0.975) + `2.5%` = unname(quantile(test_df[["stat"]], 0.025)), + `97.5%` = unname(quantile(test_df[["stat"]], 0.975)) ) expect_equal(test_df %>% get_confidence_interval(), perc_basic_out) @@ -14,16 +14,17 @@ test_that("get_confidence_interval works", { expect_equal( test_df %>% get_confidence_interval(level = 0.5, type = "percentile"), tibble::tibble( - `25%` = quantile(test_df[["stat"]], 0.25), - `75%` = quantile(test_df[["stat"]], 0.75) + `25%` = unname(quantile(test_df[["stat"]], 0.25)), + `75%` = unname(quantile(test_df[["stat"]], 0.75)) ) ) # Type "se" point <- mean(test_df[["stat"]]) + se_basic_out <- tibble::tibble(lower = -1.965, upper = 2.008) expect_equal( test_df %>% get_confidence_interval(type = "se", point_estimate = point), - tibble::tibble(lower = -1.965, upper = 2.008), + se_basic_out, tolerance = 1e-3 ) expect_equal( @@ -32,6 +33,15 @@ test_that("get_confidence_interval works", { tibble::tibble(lower = -0.662, upper = 0.705), tolerance = 1e-3 ) + ## Check that data frame input is processed correctly + expect_equal( + test_df %>% + get_confidence_interval( + type = "se", point_estimate = data.frame(p = point) + ), + se_basic_out, + tolerance = 1e-3 + ) }) test_that("get_confidence_interval checks input", { @@ -43,12 +53,19 @@ test_that("get_confidence_interval checks input", { "`point_estimate`" ) expect_error( - gss_calc %>% get_confidence_interval(type = "se", point_estimate = "a"), + test_df %>% get_confidence_interval(type = "se", point_estimate = "a"), "`point_estimate`" ) + expect_error( + test_df %>% + get_confidence_interval( + type = "se", point_estimate = data.frame(p = "a") + ), + "`point_estimate\\[\\[1\\]\\]\\[\\[1\\]\\]`" + ) expect_error( - gss_calc %>% get_confidence_interval(type = "se"), + test_df %>% get_confidence_interval(type = "se"), '`point_estimate`.*type = "se"' ) }) From 5d0275fa3f1b145ef413c170262c7ff37d88fddf Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 21 Jun 2020 15:09:16 +0300 Subject: [PATCH 05/28] Implement bias-corrected confidence interval following suggestions in PR #237. --- R/get_confidence_interval.R | 27 ++++++++++--- tests/testthat/test-get_confidence_interval.R | 39 +++++++++++++++++-- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/R/get_confidence_interval.R b/R/get_confidence_interval.R index 562c7802..2d6439cd 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -66,7 +66,8 @@ get_confidence_interval <- function(x, level = 0.95, type = "percentile", switch( type, percentile = ci_percentile(x, level), - se = ci_se(x, level, point_estimate) + se = ci_se(x, level, point_estimate), + `bias-corrected` = ci_bias_corrected(x, level, point_estimate) ) } @@ -94,6 +95,20 @@ ci_se <- function(x, level, point_estimate) { tibble::tibble(lower = ci_vec[[1]], upper = ci_vec[[2]]) } +ci_bias_corrected <- function(x, level, point_estimate) { + point_estimate <- check_obs_stat(point_estimate) + + p <- mean(x[["stat"]] <= point_estimate) + z0 <- stats::qnorm(p) + # z_alpha_2 is z_(alpha/2) + z_alpha_2 <- stats::qnorm((1 + c(-level, level)) / 2) + new_probs <- stats::pnorm(2*z0 + z_alpha_2) + + ci_vec <- stats::quantile(x[["stat"]], probs = new_probs) + + tibble::tibble(lower = ci_vec[[1]], upper = ci_vec[[2]]) +} + check_ci_args <- function(x, level, type, point_estimate){ if (!is.null(point_estimate)) { if (!is.data.frame(point_estimate)) { @@ -110,14 +125,16 @@ check_ci_args <- function(x, level, type, point_estimate){ stop_glue("The value of `level` must be between 0 and 1 non-inclusive.") } - if (!(type %in% c("percentile", "se"))) { - stop_glue('The options for `type` are "percentile" or "se".') + if (!(type %in% c("percentile", "se", "bias-corrected"))) { + stop_glue( + 'The options for `type` are "percentile", "se", or "bias-corrected".' + ) } - if ((type == "se") && is.null(point_estimate)) { + if ((type %in% c("se", "bias-corrected")) && is.null(point_estimate)) { stop_glue( 'A numeric value needs to be given for `point_estimate` ', - 'for `type = "se"' + 'for `type` "se" or "bias-corrected".' ) } } diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 164571c1..264f3e81 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -1,10 +1,13 @@ context("conf_int") test_that("get_confidence_interval works", { + point <- mean(test_df[["stat"]]) + perc_basic_out <- tibble::tibble( `2.5%` = unname(quantile(test_df[["stat"]], 0.025)), `97.5%` = unname(quantile(test_df[["stat"]], 0.975)) ) + expect_equal(test_df %>% get_confidence_interval(), perc_basic_out) # Type "percentile" @@ -20,8 +23,8 @@ test_that("get_confidence_interval works", { ) # Type "se" - point <- mean(test_df[["stat"]]) se_basic_out <- tibble::tibble(lower = -1.965, upper = 2.008) + expect_equal( test_df %>% get_confidence_interval(type = "se", point_estimate = point), se_basic_out, @@ -42,6 +45,33 @@ test_that("get_confidence_interval works", { se_basic_out, tolerance = 1e-3 ) + + # Type "bias-corrected" + bias_basic_out <- tibble::tibble(lower = -1.692, upper = 2.276) + + expect_equal( + test_df %>% + get_confidence_interval(type = "bias-corrected", point_estimate = point), + bias_basic_out, + tolerance = 1e-3 + ) + expect_equal( + test_df %>% + get_confidence_interval( + level = 0.5, type = "bias-corrected", point_estimate = point + ), + tibble::tibble(lower = -0.594, upper = 0.815), + tolerance = 1e-3 + ) + ## Check that data frame input is processed correctly + expect_equal( + test_df %>% + get_confidence_interval( + type = "bias-corrected", point_estimate = data.frame(p = point) + ), + bias_basic_out, + tolerance = 1e-3 + ) }) test_that("get_confidence_interval checks input", { @@ -65,7 +95,10 @@ test_that("get_confidence_interval checks input", { ) expect_error( - test_df %>% get_confidence_interval(type = "se"), - '`point_estimate`.*type = "se"' + test_df %>% get_confidence_interval(type = "se"), '`point_estimate`.*"se"' + ) + expect_error( + test_df %>% get_confidence_interval(type = "bias-corrected"), + '`point_estimate`.*"bias-corrected"' ) }) From e89d1402ab0880d4882ff36b61fdb7913a28b78b Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 21 Jun 2020 15:13:01 +0300 Subject: [PATCH 06/28] Document `type = "bias-corrected"` option of `get_confidence_interval()`. --- R/get_confidence_interval.R | 5 +++-- man/get_confidence_interval.Rd | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/get_confidence_interval.R b/R/get_confidence_interval.R index 2d6439cd..28856cb0 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -14,9 +14,10 @@ #' Default value is 0.95. #' @param type A string giving which method should be used for creating the #' confidence interval. The default is `"percentile"` with `"se"` -#' corresponding to (multiplier * standard error) as the other option. +#' corresponding to (multiplier * standard error) and `"bias-corrected"` for +#' bias-corrected interval as other options. #' @param point_estimate A numeric value or a 1x1 data frame set to `NULL` by -#' default. Needed to be provided if `type = "se"`. +#' default. Needed to be provided if `type` is `"se"` or `"bias-corrected"`. #' #' @return A 1 x 2 tibble with values corresponding to lower and upper values in #' the confidence interval. diff --git a/man/get_confidence_interval.Rd b/man/get_confidence_interval.Rd index 9c4da4e6..999f2612 100644 --- a/man/get_confidence_interval.Rd +++ b/man/get_confidence_interval.Rd @@ -24,10 +24,11 @@ Default value is 0.95.} \item{type}{A string giving which method should be used for creating the confidence interval. The default is \code{"percentile"} with \code{"se"} -corresponding to (multiplier * standard error) as the other option.} +corresponding to (multiplier * standard error) and \code{"bias-corrected"} for +bias-corrected interval as other options.} \item{point_estimate}{A numeric value or a 1x1 data frame set to \code{NULL} by -default. Needed to be provided if \code{type = "se"}.} +default. Needed to be provided if \code{type} is \code{"se"} or \code{"bias-corrected"}.} } \value{ A 1 x 2 tibble with values corresponding to lower and upper values in From d1b80618692d6d0527659dd740685a68ef3b4c0c Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 21 Jun 2020 15:13:41 +0300 Subject: [PATCH 07/28] Run `usethis::use_dev_version()`. --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f13c58e3..14b59b30 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: infer Type: Package Title: Tidy Statistical Inference -Version: 0.5.2 +Version: 0.5.2.9000 Authors@R: c( person("Andrew", "Bray", email = "abray@reed.edu", role = c("aut", "cre")), person("Chester", "Ismay", email = "chester.ismay@gmail.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 6c811572..0568842c 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# infer (development version) + # infer 0.5.2 - Warn the user when a p-value of 0 is reported (#257, #273) From 8bdf68989d375c3034c3ca09d9215ad44d1b39cf Mon Sep 17 00:00:00 2001 From: echasnovski Date: Mon, 22 Jun 2020 21:04:03 +0300 Subject: [PATCH 08/28] Update `get_confidence_interval()` to message if no `level` was explicitly supplied. --- R/get_confidence_interval.R | 5 ++ tests/testthat/test-get_confidence_interval.R | 73 ++++++++++++------- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/R/get_confidence_interval.R b/R/get_confidence_interval.R index 28856cb0..be8f07e8 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -64,6 +64,11 @@ get_confidence_interval <- function(x, level = 0.95, type = "percentile", point_estimate = NULL) { check_ci_args(x, level, type, point_estimate) + # Inform if no `level` was explicitly supplied + if (!("level" %in% rlang::call_args_names(match.call()))) { + message_glue("Using `level = {level}` to compute confidence interval.") + } + switch( type, percentile = ci_percentile(x, level), diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 264f3e81..6f48eadf 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -8,11 +8,18 @@ test_that("get_confidence_interval works", { `97.5%` = unname(quantile(test_df[["stat"]], 0.975)) ) - expect_equal(test_df %>% get_confidence_interval(), perc_basic_out) + # Default usage + expect_message( + expect_equal(test_df %>% get_confidence_interval(), perc_basic_out), + "Using `level = 0.95`" + ) # Type "percentile" - expect_equal( - test_df %>% get_confidence_interval(type = "percentile"), perc_basic_out + expect_message( + expect_equal( + test_df %>% get_confidence_interval(type = "percentile"), perc_basic_out + ), + "Using `level = 0.95`" ) expect_equal( test_df %>% get_confidence_interval(level = 0.5, type = "percentile"), @@ -25,10 +32,13 @@ test_that("get_confidence_interval works", { # Type "se" se_basic_out <- tibble::tibble(lower = -1.965, upper = 2.008) - expect_equal( - test_df %>% get_confidence_interval(type = "se", point_estimate = point), - se_basic_out, - tolerance = 1e-3 + expect_message( + expect_equal( + test_df %>% get_confidence_interval(type = "se", point_estimate = point), + se_basic_out, + tolerance = 1e-3 + ), + "Using `level = 0.95`" ) expect_equal( test_df %>% @@ -37,23 +47,31 @@ test_that("get_confidence_interval works", { tolerance = 1e-3 ) ## Check that data frame input is processed correctly - expect_equal( - test_df %>% - get_confidence_interval( - type = "se", point_estimate = data.frame(p = point) - ), - se_basic_out, - tolerance = 1e-3 + expect_message( + expect_equal( + test_df %>% + get_confidence_interval( + type = "se", point_estimate = data.frame(p = point) + ), + se_basic_out, + tolerance = 1e-3 + ), + "Using `level = 0.95`" ) # Type "bias-corrected" bias_basic_out <- tibble::tibble(lower = -1.692, upper = 2.276) - expect_equal( - test_df %>% - get_confidence_interval(type = "bias-corrected", point_estimate = point), - bias_basic_out, - tolerance = 1e-3 + expect_message( + expect_equal( + test_df %>% + get_confidence_interval( + type = "bias-corrected", point_estimate = point + ), + bias_basic_out, + tolerance = 1e-3 + ), + "Using `level = 0.95`" ) expect_equal( test_df %>% @@ -64,13 +82,16 @@ test_that("get_confidence_interval works", { tolerance = 1e-3 ) ## Check that data frame input is processed correctly - expect_equal( - test_df %>% - get_confidence_interval( - type = "bias-corrected", point_estimate = data.frame(p = point) - ), - bias_basic_out, - tolerance = 1e-3 + expect_message( + expect_equal( + test_df %>% + get_confidence_interval( + type = "bias-corrected", point_estimate = data.frame(p = point) + ), + bias_basic_out, + tolerance = 1e-3 + ), + "Using `level = 0.95`" ) }) From 00e1b78a83bdb092fbd7466d598b1b43ff8b36b7 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Mon, 22 Jun 2020 21:13:04 +0300 Subject: [PATCH 09/28] Refactor `get_confidence_interval()` tests. --- tests/testthat/test-get_confidence_interval.R | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 6f48eadf..92dd62ef 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -1,26 +1,27 @@ -context("conf_int") +context("get_confidence_interval") -test_that("get_confidence_interval works", { - point <- mean(test_df[["stat"]]) - - perc_basic_out <- tibble::tibble( - `2.5%` = unname(quantile(test_df[["stat"]], 0.025)), - `97.5%` = unname(quantile(test_df[["stat"]], 0.975)) - ) - - # Default usage +point <- mean(test_df[["stat"]]) + +perc_def_out <- tibble::tibble( + `2.5%` = unname(quantile(test_df[["stat"]], 0.025)), + `97.5%` = unname(quantile(test_df[["stat"]], 0.975)) +) + +test_that("get_confidence_interval works with defaults", { expect_message( - expect_equal(test_df %>% get_confidence_interval(), perc_basic_out), + expect_equal(test_df %>% get_confidence_interval(), perc_def_out), "Using `level = 0.95`" ) - - # Type "percentile" +}) + +test_that("get_confidence_interval works with `type = 'percentile'`", { expect_message( expect_equal( - test_df %>% get_confidence_interval(type = "percentile"), perc_basic_out + test_df %>% get_confidence_interval(type = "percentile"), perc_def_out ), "Using `level = 0.95`" ) + expect_equal( test_df %>% get_confidence_interval(level = 0.5, type = "percentile"), tibble::tibble( @@ -28,51 +29,39 @@ test_that("get_confidence_interval works", { `75%` = unname(quantile(test_df[["stat"]], 0.75)) ) ) +}) - # Type "se" - se_basic_out <- tibble::tibble(lower = -1.965, upper = 2.008) - +test_that("get_confidence_interval works with `type = 'se'`", { expect_message( expect_equal( test_df %>% get_confidence_interval(type = "se", point_estimate = point), - se_basic_out, + tibble::tibble(lower = -1.965, upper = 2.008), tolerance = 1e-3 ), "Using `level = 0.95`" ) + expect_equal( test_df %>% get_confidence_interval(level = 0.5, type = "se", point_estimate = point), tibble::tibble(lower = -0.662, upper = 0.705), tolerance = 1e-3 ) - ## Check that data frame input is processed correctly - expect_message( - expect_equal( - test_df %>% - get_confidence_interval( - type = "se", point_estimate = data.frame(p = point) - ), - se_basic_out, - tolerance = 1e-3 - ), - "Using `level = 0.95`" - ) - - # Type "bias-corrected" - bias_basic_out <- tibble::tibble(lower = -1.692, upper = 2.276) - +}) + +test_that("get_confidence_interval works with `type = 'bias-corrected'`", { expect_message( expect_equal( test_df %>% get_confidence_interval( type = "bias-corrected", point_estimate = point ), - bias_basic_out, + tibble::tibble(lower = -1.692, upper = 2.276), tolerance = 1e-3 ), "Using `level = 0.95`" ) + expect_equal( test_df %>% get_confidence_interval( @@ -81,18 +70,29 @@ test_that("get_confidence_interval works", { tibble::tibble(lower = -0.594, upper = 0.815), tolerance = 1e-3 ) - ## Check that data frame input is processed correctly - expect_message( - expect_equal( - test_df %>% - get_confidence_interval( - type = "bias-corrected", point_estimate = data.frame(p = point) - ), - bias_basic_out, - tolerance = 1e-3 - ), - "Using `level = 0.95`" +}) + +test_that("get_confidence_interval supports data frame `point_estimate`", { + point_df <- data.frame(p = point) + + expect_equal( + test_df %>% get_confidence_interval(type = "se", point_estimate = point), + test_df %>% get_confidence_interval(type = "se", point_estimate = point_df) ) + expect_equal( + test_df %>% + get_confidence_interval(type = "bias-corrected", point_estimate = point), + test_df %>% + get_confidence_interval( + type = "bias-corrected", point_estimate = point_df + ) + ) +}) + +test_that("get_confidence_interval messages with no explicit `level`", { + expect_message(get_confidence_interval(test_df), "Using `level = 0.95`") + expect_silent(get_confidence_interval(test_df, level = 0.95)) + expect_silent(get_confidence_interval(test_df, 0.95)) }) test_that("get_confidence_interval checks input", { From d938c64b140755083a5f0a950ed4994ab92744f3 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Mon, 22 Jun 2020 21:22:44 +0300 Subject: [PATCH 10/28] Update `get_confidence_interval()` to use consistent column names in output. Fixes #317. --- R/get_confidence_interval.R | 13 ++++++++----- man/get_confidence_interval.Rd | 4 ++-- tests/testthat/test-get_confidence_interval.R | 16 ++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/R/get_confidence_interval.R b/R/get_confidence_interval.R index be8f07e8..a0e55f67 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -19,8 +19,8 @@ #' @param point_estimate A numeric value or a 1x1 data frame set to `NULL` by #' default. Needed to be provided if `type` is `"se"` or `"bias-corrected"`. #' -#' @return A 1 x 2 tibble with values corresponding to lower and upper values in -#' the confidence interval. +#' @return A 1 x 2 tibble with 'lower_ci' and 'upper_ci' columns. Values +#' correspond to lower and upper bounds of the confidence interval. #' #' @section Aliases: #' `get_ci()` is an alias of `get_confidence_interval()`. @@ -89,7 +89,7 @@ get_ci <- function(x, level = 0.95, type = "percentile", ci_percentile <- function(x, level) { ci_vec <- stats::quantile(x[["stat"]], probs = (1 + c(-level, level)) / 2) - tibble::as_tibble(as.list(ci_vec)) + make_ci_df(ci_vec) } ci_se <- function(x, level, point_estimate) { @@ -98,7 +98,7 @@ ci_se <- function(x, level, point_estimate) { multiplier <- stats::qnorm((1 + level) / 2) ci_vec <- point_estimate + c(-multiplier, multiplier) * stats::sd(x[["stat"]]) - tibble::tibble(lower = ci_vec[[1]], upper = ci_vec[[2]]) + make_ci_df(ci_vec) } ci_bias_corrected <- function(x, level, point_estimate) { @@ -112,7 +112,7 @@ ci_bias_corrected <- function(x, level, point_estimate) { ci_vec <- stats::quantile(x[["stat"]], probs = new_probs) - tibble::tibble(lower = ci_vec[[1]], upper = ci_vec[[2]]) + make_ci_df(ci_vec) } check_ci_args <- function(x, level, type, point_estimate){ @@ -145,3 +145,6 @@ check_ci_args <- function(x, level, type, point_estimate){ } } +make_ci_df <- function(ci_vec) { + tibble::tibble(lower_ci = ci_vec[[1]], upper_ci = ci_vec[[2]]) +} diff --git a/man/get_confidence_interval.Rd b/man/get_confidence_interval.Rd index 999f2612..f534b35f 100644 --- a/man/get_confidence_interval.Rd +++ b/man/get_confidence_interval.Rd @@ -31,8 +31,8 @@ bias-corrected interval as other options.} default. Needed to be provided if \code{type} is \code{"se"} or \code{"bias-corrected"}.} } \value{ -A 1 x 2 tibble with values corresponding to lower and upper values in -the confidence interval. +A 1 x 2 tibble with 'lower_ci' and 'upper_ci' columns. Values +correspond to lower and upper bounds of the confidence interval. } \description{ Compute a confidence interval around a summary statistic. Only diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index 92dd62ef..e6bf98ba 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -3,8 +3,8 @@ context("get_confidence_interval") point <- mean(test_df[["stat"]]) perc_def_out <- tibble::tibble( - `2.5%` = unname(quantile(test_df[["stat"]], 0.025)), - `97.5%` = unname(quantile(test_df[["stat"]], 0.975)) + lower_ci = unname(quantile(test_df[["stat"]], 0.025)), + upper_ci = unname(quantile(test_df[["stat"]], 0.975)) ) test_that("get_confidence_interval works with defaults", { @@ -25,8 +25,8 @@ test_that("get_confidence_interval works with `type = 'percentile'`", { expect_equal( test_df %>% get_confidence_interval(level = 0.5, type = "percentile"), tibble::tibble( - `25%` = unname(quantile(test_df[["stat"]], 0.25)), - `75%` = unname(quantile(test_df[["stat"]], 0.75)) + lower_ci = unname(quantile(test_df[["stat"]], 0.25)), + upper_ci = unname(quantile(test_df[["stat"]], 0.75)) ) ) }) @@ -35,7 +35,7 @@ test_that("get_confidence_interval works with `type = 'se'`", { expect_message( expect_equal( test_df %>% get_confidence_interval(type = "se", point_estimate = point), - tibble::tibble(lower = -1.965, upper = 2.008), + tibble::tibble(lower_ci = -1.965, upper_ci = 2.008), tolerance = 1e-3 ), "Using `level = 0.95`" @@ -44,7 +44,7 @@ test_that("get_confidence_interval works with `type = 'se'`", { expect_equal( test_df %>% get_confidence_interval(level = 0.5, type = "se", point_estimate = point), - tibble::tibble(lower = -0.662, upper = 0.705), + tibble::tibble(lower_ci = -0.662, upper_ci = 0.705), tolerance = 1e-3 ) }) @@ -56,7 +56,7 @@ test_that("get_confidence_interval works with `type = 'bias-corrected'`", { get_confidence_interval( type = "bias-corrected", point_estimate = point ), - tibble::tibble(lower = -1.692, upper = 2.276), + tibble::tibble(lower_ci = -1.692, upper_ci = 2.276), tolerance = 1e-3 ), "Using `level = 0.95`" @@ -67,7 +67,7 @@ test_that("get_confidence_interval works with `type = 'bias-corrected'`", { get_confidence_interval( level = 0.5, type = "bias-corrected", point_estimate = point ), - tibble::tibble(lower = -0.594, upper = 0.815), + tibble::tibble(lower_ci = -0.594, upper_ci = 0.815), tolerance = 1e-3 ) }) From 5601d7620820b9c8474e5d6d405d949316460071 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Mon, 22 Jun 2020 21:35:14 +0300 Subject: [PATCH 11/28] Update 'NEWS.md'. --- NEWS.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NEWS.md b/NEWS.md index 0568842c..88ce6b95 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,15 @@ # infer (development version) +## Breaking changes + +- `get_confidence_interval()` now uses consistent column names ('lower_ci' and 'upper_ci') in output (#317). + +## New functionality + +- Implement new type `"bias-corrected"` for `get_confidence_interval()` to produce bias-corrected confidence intervals (#237, #318). Thanks to @davidbaniadam for initial implementation. + +## Other + # infer 0.5.2 - Warn the user when a p-value of 0 is reported (#257, #273) From 0ee9449c8fc21749271b264a570e3fe60144a153 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 28 Jun 2020 11:27:43 +0300 Subject: [PATCH 12/28] Update 'check-standard' Github Action to use release versions of R. --- .github/workflows/check-standard.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-standard.yaml b/.github/workflows/check-standard.yaml index a91742b0..dc2228e7 100644 --- a/.github/workflows/check-standard.yaml +++ b/.github/workflows/check-standard.yaml @@ -20,10 +20,10 @@ jobs: fail-fast: false matrix: config: - - {os: windows-latest, r: '3.6'} - - {os: macOS-latest, r: '3.6'} + - {os: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} - {os: macOS-latest, r: 'devel'} - - {os: ubuntu-16.04, r: '3.6', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: 'release', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true From c0aa801ec280a23bdb90710def79cd0901768cd3 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Mon, 29 Jun 2020 07:17:57 -0700 Subject: [PATCH 13/28] update conduct, tidymodels resources --- CONDUCT.md | 141 +++++++++++++++++++++++++++++++++++++++++++++-------- README.Rmd | 5 +- README.md | 35 ++++++++----- 3 files changed, 147 insertions(+), 34 deletions(-) diff --git a/CONDUCT.md b/CONDUCT.md index 066b7960..b36903fa 100644 --- a/CONDUCT.md +++ b/CONDUCT.md @@ -1,25 +1,128 @@ -# Contributor Code of Conduct +# Contributor Covenant Code of Conduct -As contributors and maintainers of this project, we pledge to respect all people who -contribute through reporting issues, posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project a harassment-free experience for -everyone, regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity and +orientation. -Examples of unacceptable behavior by participants include the use of sexual language or -imagery, derogatory comments or personal attacks, trolling, public or private harassment, -insults, or other unprofessional conduct. +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. -Project maintainers have the right and responsibility to remove, edit, or reject comments, -commits, code, wiki edits, issues, and other contributions that are not aligned to this -Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed -from the project team. +## Our Standards -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by -opening an issue or contacting one or more of the project maintainers. +Examples of behavior that contributes to a positive environment for our +community include: -This Code of Conduct is adapted from the Contributor Covenant -(http://contributor-covenant.org), version 1.0.0, available at -http://contributor-covenant.org/version/1/0/0/. +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, +and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall +community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or +advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email +address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a +professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards +of acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies +when an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at [INSERT CONTACT +METHOD]. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, +available at https://www.contributor-covenant.org/version/2/0/ +code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at https:// +www.contributor-covenant.org/translations. diff --git a/README.Rmd b/README.Rmd index ce7c3055..38190dfa 100755 --- a/README.Rmd +++ b/README.Rmd @@ -64,8 +64,9 @@ To see documentation for the experimental version of `infer`, the `pkgdown` site ------------------------------------------------------------------------ -We welcome others helping us make this package as user-friendly and efficient as possible. Please review -our [contributing](https://github.com/tidymodels/infer/blob/master/CONTRIBUTING.md) and [conduct](https://github.com/tidymodels/infer/blob/master/CONDUCT.md) guidelines. Please see the open [issues](https://github.com/tidymodels/infer/issues) for more specific fixes/additions needing attention. By participating in this project you agree to abide by its terms. +We welcome others helping us make this package as user-friendly and efficient as possible. Please review our [contributing](https://github.com/tidymodels/infer/blob/master/CONTRIBUTING.md) and [conduct](https://github.com/tidymodels/infer/blob/master/CONDUCT.md) guidelines. By participating in this project you agree to abide by its terms. + +For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://rstd.io/tidymodels-community). If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/tune/issues). Either way, learn how to create and share a [reprex](https://rstd.io/reprex) (a minimal, reproducible example), to clearly communicate about your code. Check out further details on [contributing guidelines for tidymodels packages](https://www.tidymodels.org/contribute/) and [how to get help](https://www.tidymodels.org/help/). ### Examples diff --git a/README.md b/README.md index 342b5011..6dbce4e6 100755 --- a/README.md +++ b/README.md @@ -75,10 +75,19 @@ efficient as possible. Please review our [contributing](https://github.com/tidymodels/infer/blob/master/CONTRIBUTING.md) and [conduct](https://github.com/tidymodels/infer/blob/master/CONDUCT.md) -guidelines. Please see the open -[issues](https://github.com/tidymodels/infer/issues) for more specific -fixes/additions needing attention. By participating in this project you -agree to abide by its terms. +guidelines. By participating in this project you agree to abide by its +terms. + +For questions and discussions about tidymodels packages, modeling, and +machine learning, please [post on RStudio +Community](https://rstd.io/tidymodels-community). If you think you have +encountered a bug, please [submit an +issue](https://github.com/tidymodels/tune/issues). Either way, learn how +to create and share a [reprex](https://rstd.io/reprex) (a minimal, +reproducible example), to clearly communicate about your code. Check out +further details on [contributing guidelines for tidymodels +packages](https://www.tidymodels.org/contribute/) and [how to get +help](https://www.tidymodels.org/help/). ### Examples @@ -98,18 +107,18 @@ data(gss) str(gss) ``` - ## Classes 'tbl_df', 'tbl' and 'data.frame': 500 obs. of 11 variables: - ## $ year : num 2014 1994 1998 1996 1994 ... - ## $ age : num 36 34 24 42 31 32 48 36 30 33 ... + ## tibble [500 × 11] (S3: tbl_df/tbl/data.frame) + ## $ year : num [1:500] 2014 1994 1998 1996 1994 ... + ## $ age : num [1:500] 36 34 24 42 31 32 48 36 30 33 ... ## $ sex : Factor w/ 2 levels "male","female": 1 2 1 1 1 2 2 2 2 2 ... ## $ college: Factor w/ 2 levels "no degree","degree": 2 1 2 1 2 1 1 2 2 1 ... ## $ partyid: Factor w/ 5 levels "dem","ind","rep",..: 2 3 2 2 3 3 1 2 3 1 ... - ## $ hompop : num 3 4 1 4 2 4 2 1 5 2 ... - ## $ hours : num 50 31 40 40 40 53 32 20 40 40 ... + ## $ hompop : num [1:500] 3 4 1 4 2 4 2 1 5 2 ... + ## $ hours : num [1:500] 50 31 40 40 40 53 32 20 40 40 ... ## $ income : Ord.factor w/ 12 levels "lt $1000"<"$1000 to 2999"<..: 12 11 12 12 12 12 12 12 12 10 ... ## $ class : Factor w/ 6 levels "lower class",..: 3 2 2 2 3 3 2 3 3 2 ... ## $ finrela: Factor w/ 6 levels "far below average",..: 2 2 2 4 4 3 2 4 3 1 ... - ## $ weight : num 0.896 1.083 0.55 1.086 1.083 ... + ## $ weight : num [1:500] 0.896 1.083 0.55 1.086 1.083 ... As an example, we’ll run an analysis of variance on `age` and `partyid`, testing whether the age of a respondent is independent of their @@ -153,10 +162,10 @@ null_distn %>% ## # A tibble: 1 x 1 ## p_value ## - ## 1 0.056 + ## 1 0.055 -Note that the formula and non-formula interfaces (i.e. `age ~ partyid` -vs. `response = age, explanatory = partyid`) work for all implemented +Note that the formula and non-formula interfaces (i.e. `age ~ partyid` +vs. `response = age, explanatory = partyid`) work for all implemented inference procedures in `infer`. Use whatever is more natural for you. If you will be doing modeling using functions like `lm()` and `glm()`, though, we recommend you begin to use the formula `y ~ x` notation as From 164524d10d59aab82b1126c448c54fbbf4a6c8d1 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Mon, 29 Jun 2020 07:22:51 -0700 Subject: [PATCH 14/28] fix issues link --- README.Rmd | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.Rmd b/README.Rmd index 38190dfa..a7928728 100755 --- a/README.Rmd +++ b/README.Rmd @@ -66,7 +66,7 @@ To see documentation for the experimental version of `infer`, the `pkgdown` site We welcome others helping us make this package as user-friendly and efficient as possible. Please review our [contributing](https://github.com/tidymodels/infer/blob/master/CONTRIBUTING.md) and [conduct](https://github.com/tidymodels/infer/blob/master/CONDUCT.md) guidelines. By participating in this project you agree to abide by its terms. -For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://rstd.io/tidymodels-community). If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/tune/issues). Either way, learn how to create and share a [reprex](https://rstd.io/reprex) (a minimal, reproducible example), to clearly communicate about your code. Check out further details on [contributing guidelines for tidymodels packages](https://www.tidymodels.org/contribute/) and [how to get help](https://www.tidymodels.org/help/). +For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://rstd.io/tidymodels-community). If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/infer/issues). Either way, learn how to create and share a [reprex](https://rstd.io/reprex) (a minimal, reproducible example), to clearly communicate about your code. Check out further details on [contributing guidelines for tidymodels packages](https://www.tidymodels.org/contribute/) and [how to get help](https://www.tidymodels.org/help/). ### Examples diff --git a/README.md b/README.md index 6dbce4e6..ad8a8c63 100755 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://rstd.io/tidymodels-community). If you think you have encountered a bug, please [submit an -issue](https://github.com/tidymodels/tune/issues). Either way, learn how +issue](https://github.com/tidymodels/infer/issues). Either way, learn how to create and share a [reprex](https://rstd.io/reprex) (a minimal, reproducible example), to clearly communicate about your code. Check out further details on [contributing guidelines for tidymodels From cf92acea662e08a6ea2075d1c353cda5fc440f29 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Tue, 30 Jun 2020 15:24:40 -0700 Subject: [PATCH 15/28] fill in blank contact method Listing community leaders responsible for enforcement as authors. :-) --- CONDUCT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONDUCT.md b/CONDUCT.md index b36903fa..9c695e85 100644 --- a/CONDUCT.md +++ b/CONDUCT.md @@ -59,8 +59,8 @@ representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at [INSERT CONTACT -METHOD]. All complaints will be reviewed and investigated promptly and fairly. +reported to the community leaders responsible for enforcement listed as package +authors. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. From eaf93a4fbf8647c081f3677fa3b64b824e64951e Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Tue, 30 Jun 2020 15:58:44 -0700 Subject: [PATCH 16/28] noLD fixes --- R/utils.R | 3 +- tests/testthat/helper-data.R | 2 + tests/testthat/test-aliases.R | 3 +- tests/testthat/test-calculate.R | 23 +++++------ tests/testthat/test-get_confidence_interval.R | 6 ++- tests/testthat/test-get_p_value.R | 38 ++++++++++++------- tests/testthat/test-hypothesize.R | 2 +- tests/testthat/test-wrappers.R | 5 +-- 8 files changed, 49 insertions(+), 33 deletions(-) diff --git a/R/utils.R b/R/utils.R index 338ce187..2e96ed99 100644 --- a/R/utils.R +++ b/R/utils.R @@ -343,6 +343,7 @@ sanitize_hypothesis_params_point <- function(dots, x) { } sanitize_hypothesis_params_proportion <- function(p, x) { + eps <- if (capabilities("long.double")) {sqrt(.Machine$double.eps)} else {0.01} if(anyNA(p)) { stop_glue('`p` should not contain missing values.') } @@ -359,7 +360,7 @@ sanitize_hypothesis_params_proportion <- function(p, x) { p <- c(p, 1 - p) names(p) <- get_success_then_response_levels(x) } else { - if (sum(p) != 1) { + if (sum(p) < 1 - eps | sum(p) > 1 + eps) { stop_glue( "Make sure the hypothesized values for the `p` parameters sum to 1. ", "Please try again." diff --git a/tests/testthat/helper-data.R b/tests/testthat/helper-data.R index 1f5fe761..663ff5a9 100644 --- a/tests/testthat/helper-data.R +++ b/tests/testthat/helper-data.R @@ -1,5 +1,7 @@ set.seed(4242) +eps <- if (capabilities("long.double")) {sqrt(.Machine$double.eps)} else {0.01} + gss_tbl <- tibble::as_tibble(gss) %>% dplyr::filter(!(is.na(sex) | is.na(college))) %>% dplyr::mutate(partyid = as.character(partyid)) %>% diff --git a/tests/testthat/test-aliases.R b/tests/testthat/test-aliases.R index 9aa8a116..85390578 100644 --- a/tests/testthat/test-aliases.R +++ b/tests/testthat/test-aliases.R @@ -5,7 +5,8 @@ test_that("aliases work", { gss_calc %>% get_pvalue(obs_stat = -0.2, direction = "right") %>% dplyr::pull(), - expected = 1 + expected = 1, + tolerance = eps ) expect_silent(test_df %>% get_ci()) diff --git a/tests/testthat/test-calculate.R b/tests/testthat/test-calculate.R index da055165..46eb96a3 100644 --- a/tests/testthat/test-calculate.R +++ b/tests/testthat/test-calculate.R @@ -431,7 +431,7 @@ test_that("calculate doesn't depend on order of `p` (#122)", { expect_equal( calc_chisq(c("rep" = 0.25, "dem" = 0.5, "ind" = 0.25)), calc_chisq(c("ind" = 0.25, "rep" = 0.25, "dem" = 0.5)), - tolerance = 1e-5 + tolerance = eps ) }) @@ -449,18 +449,18 @@ test_that("calc_impl.sum works", { specify(hours ~ NULL) %>% calculate(stat = "sum") %>% `[[`(1), - sum(gss_tbl$hours) + sum(gss_tbl$hours), + tolerance = eps ) gen_gss_tbl16 <- gss_tbl %>% specify(hours ~ NULL) %>% generate(10) -# Temporarily remove because of failing noLD test - # expect_equal( - # gen_gss_tbl16 %>% calculate(stat = "sum"), - # gen_gss_tbl16 %>% dplyr::summarise(stat = sum(hours)), - # tolerance = .Machine$double.eps^0.25 - # ) + + expect_equivalent( + gen_gss_tbl16 %>% calculate(stat = "sum"), + gen_gss_tbl16 %>% dplyr::summarise(stat = sum(hours)) + ) }) test_that("calc_impl_success_f works", { @@ -478,7 +478,8 @@ test_that("calc_impl.count works", { specify(college ~ NULL, success = "no degree") %>% calculate(stat = "count") %>% `[[`(1), - sum(gss_tbl$college == "no degree") + sum(gss_tbl$college == "no degree"), + tolerance = eps ) expect_equivalent( @@ -503,7 +504,7 @@ test_that("calc_impl.odds_ratio works", { calculate(stat = "odds ratio", order = c("female", "male")) %>% dplyr::pull(), expected = base_odds_ratio, - tolerance = .001) + tolerance = eps) }) test_that("calc_impl.ratio_of_props works", { @@ -516,7 +517,7 @@ test_that("calc_impl.ratio_of_props works", { calculate(stat = "ratio of props", order = c("male", "female")) %>% dplyr::pull(), expected = base_ratio_of_props, - tolerance = .001) + tolerance = eps) }) diff --git a/tests/testthat/test-get_confidence_interval.R b/tests/testthat/test-get_confidence_interval.R index e6bf98ba..dbe3e410 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -77,7 +77,8 @@ test_that("get_confidence_interval supports data frame `point_estimate`", { expect_equal( test_df %>% get_confidence_interval(type = "se", point_estimate = point), - test_df %>% get_confidence_interval(type = "se", point_estimate = point_df) + test_df %>% get_confidence_interval(type = "se", point_estimate = point_df), + tolerance = eps ) expect_equal( test_df %>% @@ -85,7 +86,8 @@ test_that("get_confidence_interval supports data frame `point_estimate`", { test_df %>% get_confidence_interval( type = "bias-corrected", point_estimate = point_df - ) + ), + tolerance = eps ) }) diff --git a/tests/testthat/test-get_p_value.R b/tests/testthat/test-get_p_value.R index bdbedfd4..26b2afc4 100644 --- a/tests/testthat/test-get_p_value.R +++ b/tests/testthat/test-get_p_value.R @@ -12,33 +12,43 @@ test_that("direction is appropriate", { }) test_that("get_p_value works", { - expect_equal(get_p_value(test_df, 4, "right")[[1]][1], 5/20) - expect_equal(get_p_value(test_df, 4, "left")[[1]][1], 17/20) - expect_equal(get_p_value(test_df, 4, "both")[[1]][1], 10/20) + expect_equal(get_p_value(test_df, 4, "right")[[1]][1], 5/20, tolerance = eps) + expect_equal(get_p_value(test_df, 4, "left")[[1]][1], 17/20, tolerance = eps) + expect_equal(get_p_value(test_df, 4, "both")[[1]][1], 10/20, tolerance = eps) - expect_equal(get_p_value(test_df, 0, "right")[[1]][1], 14/20) - expect_equal(get_p_value(test_df, 0, "left")[[1]][1], 12/20) + expect_equal(get_p_value(test_df, 0, "right")[[1]][1], 14/20, tolerance = eps) + expect_equal(get_p_value(test_df, 0, "left")[[1]][1], 12/20, tolerance = eps) # This is also a check for not returning value more than 1 - expect_equal(get_p_value(test_df, 0, "both")[[1]][1], 1) + expect_equal(get_p_value(test_df, 0, "both")[[1]][1], 1, tolerance = eps) - expect_equal(get_p_value(test_df, -3.999, "right")[[1]][1], 16/20) - expect_equal(get_p_value(test_df, -3.999, "left")[[1]][1], 4/20) - expect_equal(get_p_value(test_df, -3.999, "both")[[1]][1], 8/20) + expect_equal(get_p_value(test_df, -3.999, "right")[[1]][1], 16/20, tolerance = eps) + expect_equal(get_p_value(test_df, -3.999, "left")[[1]][1], 4/20, tolerance = eps) + expect_equal(get_p_value(test_df, -3.999, "both")[[1]][1], 8/20, tolerance = eps) expect_equal( - get_p_value(test_df, 4, "greater"), get_p_value(test_df, 4, "right") + get_p_value(test_df, 4, "greater"), + get_p_value(test_df, 4, "right"), + tolerance = eps ) expect_equal( - get_p_value(test_df, 4, "less"), get_p_value(test_df, 4, "left") + get_p_value(test_df, 4, "less"), + get_p_value(test_df, 4, "left"), + tolerance = eps ) expect_equal( - get_p_value(test_df, 4, "two_sided"), get_p_value(test_df, 4, "both") + get_p_value(test_df, 4, "two_sided"), + get_p_value(test_df, 4, "both"), + tolerance = eps ) expect_equal( - get_p_value(test_df, 4, "two-sided"), get_p_value(test_df, 4, "both") + get_p_value(test_df, 4, "two-sided"), + get_p_value(test_df, 4, "both"), + tolerance = eps ) expect_equal( - get_p_value(test_df, 4, "two sided"), get_p_value(test_df, 4, "both") + get_p_value(test_df, 4, "two sided"), + get_p_value(test_df, 4, "both"), + tolerance = eps ) }) diff --git a/tests/testthat/test-hypothesize.R b/tests/testthat/test-hypothesize.R index 1a1bbada..2c5c0585 100644 --- a/tests/testthat/test-hypothesize.R +++ b/tests/testthat/test-hypothesize.R @@ -150,7 +150,7 @@ test_that( expect_error( mtcars_df %>% specify(response = vs, success = "1") %>% - hypothesize(null = "point", p = c("0" = 0.5, "1" = 0.5 + .Machine$double.eps)), + hypothesize(null = "point", p = c("0" = 0.5, "1" = 0.5 + (eps *2))), "Make sure the hypothesized values for the `p` parameters sum to 1. Please try again." ) }) diff --git a/tests/testthat/test-wrappers.R b/tests/testthat/test-wrappers.R index 9530932b..cf6e3aaf 100644 --- a/tests/testthat/test-wrappers.R +++ b/tests/testthat/test-wrappers.R @@ -56,9 +56,8 @@ test_that("chisq_test works", { broom::glance() %>% dplyr::select(statistic, chisq_df = parameter, p_value = p.value) - expect_equal(new_way, new_way_alt, tolerance = .Machine$double.eps^0.25) - #temporary remove because of failing noLD - #expect_equal(new_way, old_way, tolerance = .Machine$double.eps^0.25) + expect_equal(new_way, new_way_alt, tolerance = eps) + expect_equal(new_way, old_way, tolerance = eps) # Goodness of Fit expect_silent(gss_tbl %>% From cd645e6d679041894a81672b63d9c81e17c93766 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Tue, 30 Jun 2020 16:32:06 -0700 Subject: [PATCH 17/28] 0.5.3 updates --- NEWS.md | 7 +++++-- cran-comments.md | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 88ce6b95..1233f623 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,9 @@ -# infer (development version) +# infer 0.5.3 ## Breaking changes -- `get_confidence_interval()` now uses consistent column names ('lower_ci' and 'upper_ci') in output (#317). +- `get_confidence_interval()` now uses column names ('lower_ci' and 'upper_ci') +in output that are consistent with other infer functionality (#317). ## New functionality @@ -10,6 +11,8 @@ ## Other +- Fix CRAN check failures related to long double errors. + # infer 0.5.2 - Warn the user when a p-value of 0 is reported (#257, #273) diff --git a/cran-comments.md b/cran-comments.md index a0ea0bf5..4f8474b0 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,7 @@ ## Test environments * local OS X install, R 4.0.0 * ubuntu 16.04 (on travis-ci), oldrel, release, devel -* win-builder (release, devel) +* win-builder (devel) * rhub: debian-gcc-devel-nold ## R CMD check results @@ -10,4 +10,5 @@ ## Reverse dependencies -There is one reverse dependency: moderndive. No problems found. +We checked five reverse dependencies, two of which are on CRAN, with the +remainder on bioconductor, and found no new issues. From 5295258cde7860f139587c5b9a814db946e2a831 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Fri, 3 Jul 2020 11:48:33 -0700 Subject: [PATCH 18/28] bump R version depends The vignettes now store .Rdata with serialize version 3. --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 14b59b30..abaa7fdd 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,7 @@ Imports: grDevices, purrr Depends: - R (>= 3.1.2) + R (>= 3.5.0) Suggests: broom, devtools (>= 1.12.0), From 3141649fe8cfb07f7bed810fa1d79692e3d5311d Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Fri, 3 Jul 2020 11:56:32 -0700 Subject: [PATCH 19/28] release prep --- DESCRIPTION | 2 +- NEWS.md | 4 +++- cran-comments.md | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index abaa7fdd..2392d135 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,5 +48,5 @@ URL: https://github.com/tidymodels/infer, https://infer.netlify.com/ BugReports: https://github.com/tidymodels/infer/issues Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.0.9000 +RoxygenNote: 7.1.1 VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index 1233f623..abc8a1f7 100755 --- a/NEWS.md +++ b/NEWS.md @@ -7,7 +7,9 @@ in output that are consistent with other infer functionality (#317). ## New functionality -- Implement new type `"bias-corrected"` for `get_confidence_interval()` to produce bias-corrected confidence intervals (#237, #318). Thanks to @davidbaniadam for initial implementation. +- `get_confidence_interval()` can now produce bias-corrected confidence intervals +by setting `type = "bias-corrected"`. Thanks to @davidbaniadam for the +initial implementation (#237, #318)! ## Other diff --git a/cran-comments.md b/cran-comments.md index 4f8474b0..93d37a95 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,5 +1,5 @@ ## Test environments -* local OS X install, R 4.0.0 +* local OS X install, R 4.0.2 * ubuntu 16.04 (on travis-ci), oldrel, release, devel * win-builder (devel) * rhub: debian-gcc-devel-nold @@ -11,4 +11,4 @@ ## Reverse dependencies We checked five reverse dependencies, two of which are on CRAN, with the -remainder on bioconductor, and found no new issues. +remaining on bioconductor, and found no new issues. From 6f3ec19641e19bb4ad1b5f503495319f50166edf Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Fri, 3 Jul 2020 12:10:55 -0700 Subject: [PATCH 20/28] bump ggplot2 version for travis devel check --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2392d135..860fc64c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ Imports: methods, tibble, rlang (>= 0.2.0), - ggplot2, + ggplot2 (>= 3.3.2), magrittr, glue (>= 1.3.0), grDevices, From af2dab4b563bb502a50e07c83f88743f89664de5 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Fri, 3 Jul 2020 13:39:07 -0700 Subject: [PATCH 21/28] bump version, update testing environments Skipping vdiffr tests on R-devel due to a vdiffr issue with r-devel (see r-lib/vdiffr 86) --- .travis.yml | 2 ++ DESCRIPTION | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf85d7f3..9b76f402 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ matrix: env: VDIFFR_RUN_TESTS=false - r: release - r: devel + # ...or devel, re: r-lib/vdiffr#86 + env: VDIFFR_RUN_TESTS=false warnings_are_errors: true sudo: required diff --git a/DESCRIPTION b/DESCRIPTION index 860fc64c..164af6d7 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: infer Type: Package Title: Tidy Statistical Inference -Version: 0.5.2.9000 +Version: 0.5.3 Authors@R: c( person("Andrew", "Bray", email = "abray@reed.edu", role = c("aut", "cre")), person("Chester", "Ismay", email = "chester.ismay@gmail.com", role = "aut"), @@ -26,7 +26,7 @@ Imports: methods, tibble, rlang (>= 0.2.0), - ggplot2 (>= 3.3.2), + ggplot2, magrittr, glue (>= 1.3.0), grDevices, From f46ebf925aac52a5d04d31ae3a7a594ef65dd0aa Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Sun, 5 Jul 2020 13:38:22 -0700 Subject: [PATCH 22/28] skip vdiffr tests on r-devel Due to an unaddressed issue (86) with vdiffr. --- tests/testthat/test-shade_confidence_interval.R | 8 ++++++++ tests/testthat/test-shade_p_value.R | 12 ++++++++++++ tests/testthat/test-visualize.R | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/tests/testthat/test-shade_confidence_interval.R b/tests/testthat/test-shade_confidence_interval.R index afba57ca..c6852917 100644 --- a/tests/testthat/test-shade_confidence_interval.R +++ b/tests/testthat/test-shade_confidence_interval.R @@ -5,6 +5,8 @@ library(vdiffr) # shade_confidence_interval ----------------------------------------------- test_that("shade_confidence_interval works", { + skip_if(getRversion() < 4.1) + # Adding `shade_confidence_interval()` to simulation plot expect_doppelganger( "ci-sim-fill", @@ -37,6 +39,8 @@ test_that("shade_confidence_interval works", { }) test_that("shade_confidence_interval accepts `NULL` as `endpoints`", { + skip_if(getRversion() < 4.1) + expect_doppelganger( "ci-null-endpoints", gss_viz_sim + shade_confidence_interval(NULL) @@ -44,6 +48,8 @@ test_that("shade_confidence_interval accepts `NULL` as `endpoints`", { }) test_that("shade_confidence_interval uses extra aesthetic", { + skip_if(getRversion() < 4.1) + expect_doppelganger( "ci-extra-aes-1", gss_viz_sim + shade_confidence_interval(c(-1, 1), alpha = 1) @@ -55,6 +61,8 @@ test_that("shade_confidence_interval uses extra aesthetic", { }) test_that("shade_confidence_interval throws errors and warnings", { + skip_if(getRversion() < 4.1) + expect_warning(gss_viz_sim + shade_confidence_interval(c(1, 2, 3)), "2") expect_error( gss_viz_sim + shade_confidence_interval(data.frame(x = 1)), diff --git a/tests/testthat/test-shade_p_value.R b/tests/testthat/test-shade_p_value.R index 6c636e41..c99f90e8 100644 --- a/tests/testthat/test-shade_p_value.R +++ b/tests/testthat/test-shade_p_value.R @@ -5,6 +5,8 @@ library(vdiffr) # shade_p_value ----------------------------------------------------------- test_that("shade_p_value works", { + skip_if(getRversion() < 4.1) + # Adding `shade_p_value()` to simulation plot expect_doppelganger( "pval-sim-right", gss_viz_sim + shade_p_value(1, "right") @@ -55,6 +57,8 @@ test_that("shade_p_value works", { }) test_that("shade_p_value accepts synonyms for 'direction'", { + skip_if(getRversion() < 4.1) + expect_doppelganger( "pval-direction-right", gss_viz_sim + shade_p_value(1, "greater") ) @@ -76,6 +80,8 @@ test_that("shade_p_value accepts synonyms for 'direction'", { }) test_that("shade_p_value uses extra aesthetic", { + skip_if(getRversion() < 4.1) + expect_doppelganger( "pval-extra-aes-1", gss_viz_sim + shade_p_value(1, "two_sided", alpha = 1) @@ -91,12 +97,16 @@ test_that("shade_p_value uses extra aesthetic", { }) test_that("shade_p_value accepts `NULL` as `obs_stat`", { + skip_if(getRversion() < 4.1) + expect_doppelganger( "pval-null-obs_stat", gss_viz_sim + shade_p_value(NULL, "left") ) }) test_that("shade_p_value throws errors", { + skip_if(getRversion() < 4.1) + expect_error(gss_viz_sim + shade_p_value("a", "right"), "numeric") expect_error(gss_viz_sim + shade_p_value(1, 1), "character") expect_error(gss_viz_sim + shade_p_value(1, "right", color = "x"), "color") @@ -121,6 +131,8 @@ test_that("shade_p_value throws errors", { # norm_direction ---------------------------------------------------------- test_that("norm_direction works", { + skip_if(getRversion() < 4.1) + expect_equal(norm_direction("left"), "left") expect_equal(norm_direction("less"), "left") expect_equal(norm_direction("right"), "right") diff --git a/tests/testthat/test-visualize.R b/tests/testthat/test-visualize.R index b56c85e8..5ddd3855 100644 --- a/tests/testthat/test-visualize.R +++ b/tests/testthat/test-visualize.R @@ -46,6 +46,8 @@ obs_F <- anova( )$`F value`[1] test_that("visualize basic tests", { + skip_if(getRversion() < 4.1) + expect_doppelganger("visualize", visualize(hours_resamp)) # visualise also works @@ -370,10 +372,14 @@ test_that("visualize basic tests", { }) test_that("mirror_obs_stat works", { + skip_if(getRversion() < 4.1) + expect_equal(mirror_obs_stat(1:10, 4), c(`60%` = 6.4)) }) test_that("obs_stat as a data.frame works", { + skip_if(getRversion() < 4.1) + mean_petal_width <- gss_tbl %>% specify(hours ~ NULL) %>% calculate(stat = "mean") @@ -405,6 +411,7 @@ test_that("obs_stat as a data.frame works", { }) test_that('method = "both" behaves nicely', { + skip_if(getRversion() < 4.1) # stop_glue( # '`generate()` and `calculate()` are both required to be done prior ', # 'to `visualize(method = "both")`' @@ -432,6 +439,8 @@ test_that('method = "both" behaves nicely', { }) test_that("Traditional right-tailed tests have warning if not right-tailed", { + skip_if(getRversion() < 4.1) + expect_warning( gss_tbl %>% specify(sex ~ partyid, success = "female") %>% @@ -467,6 +476,8 @@ test_that("Traditional right-tailed tests have warning if not right-tailed", { }) test_that("confidence interval plots are working", { + skip_if(getRversion() < 4.1) + gss_tbl_boot <- gss_tbl %>% specify(sex ~ college, success = "female") %>% generate(reps = 100) %>% @@ -493,6 +504,8 @@ test_that("confidence interval plots are working", { }) test_that("title adapts to not hypothesis testing workflow", { + skip_if(getRversion() < 4.1) + set.seed(100) gss_tbl_boot_tbl <- gss_tbl %>% specify(response = hours) %>% @@ -515,6 +528,8 @@ test_that("title adapts to not hypothesis testing workflow", { }) test_that("warn_right_tail_test works", { + skip_if(getRversion() < 4.1) + expect_warn_right_tail <- function(stat_name) { warn_regex <- paste0(stat_name, ".*right-tailed") @@ -529,6 +544,8 @@ test_that("warn_right_tail_test works", { }) test_that("visualize warns about removing `NaN`", { + skip_if(getRversion() < 4.1) + dist <- gss_tbl_boot_tbl <- gss_tbl %>% specify(response = hours) %>% generate(reps = 10, type = "bootstrap") %>% From 041425759714df27f42825d7324b014e005f4288 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Sun, 5 Jul 2020 19:01:07 -0700 Subject: [PATCH 23/28] submit to CRAN! --- CRAN-RELEASE | 2 ++ cran-comments.md | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 CRAN-RELEASE diff --git a/CRAN-RELEASE b/CRAN-RELEASE new file mode 100644 index 00000000..37450483 --- /dev/null +++ b/CRAN-RELEASE @@ -0,0 +1,2 @@ +This package was submitted to CRAN on 2020-07-05. +Once it is accepted, delete this file and tag the release (commit f46ebf925a). diff --git a/cran-comments.md b/cran-comments.md index 93d37a95..ea15bdba 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,7 @@ +## infer 0.5.3 + +This release fixes failing CRAN checks related to long-double support. + ## Test environments * local OS X install, R 4.0.2 * ubuntu 16.04 (on travis-ci), oldrel, release, devel From c43b68df614d007314c14c433c8c55851732988d Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Mon, 6 Jul 2020 09:32:45 -0700 Subject: [PATCH 24/28] update skip conditions Also removes the VDIFFR_RUN_TESTS config from the CI devel settings to make sure the skip conditions work as expected. --- .travis.yml | 2 -- .../testthat/test-shade_confidence_interval.R | 8 ++++---- tests/testthat/test-shade_p_value.R | 12 ++++++------ tests/testthat/test-visualize.R | 18 +++++++++--------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b76f402..cf85d7f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,6 @@ matrix: env: VDIFFR_RUN_TESTS=false - r: release - r: devel - # ...or devel, re: r-lib/vdiffr#86 - env: VDIFFR_RUN_TESTS=false warnings_are_errors: true sudo: required diff --git a/tests/testthat/test-shade_confidence_interval.R b/tests/testthat/test-shade_confidence_interval.R index c6852917..11fc8c9e 100644 --- a/tests/testthat/test-shade_confidence_interval.R +++ b/tests/testthat/test-shade_confidence_interval.R @@ -5,7 +5,7 @@ library(vdiffr) # shade_confidence_interval ----------------------------------------------- test_that("shade_confidence_interval works", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") # Adding `shade_confidence_interval()` to simulation plot expect_doppelganger( @@ -39,7 +39,7 @@ test_that("shade_confidence_interval works", { }) test_that("shade_confidence_interval accepts `NULL` as `endpoints`", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_doppelganger( "ci-null-endpoints", @@ -48,7 +48,7 @@ test_that("shade_confidence_interval accepts `NULL` as `endpoints`", { }) test_that("shade_confidence_interval uses extra aesthetic", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_doppelganger( "ci-extra-aes-1", @@ -61,7 +61,7 @@ test_that("shade_confidence_interval uses extra aesthetic", { }) test_that("shade_confidence_interval throws errors and warnings", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_warning(gss_viz_sim + shade_confidence_interval(c(1, 2, 3)), "2") expect_error( diff --git a/tests/testthat/test-shade_p_value.R b/tests/testthat/test-shade_p_value.R index c99f90e8..b5f575b3 100644 --- a/tests/testthat/test-shade_p_value.R +++ b/tests/testthat/test-shade_p_value.R @@ -5,7 +5,7 @@ library(vdiffr) # shade_p_value ----------------------------------------------------------- test_that("shade_p_value works", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") # Adding `shade_p_value()` to simulation plot expect_doppelganger( @@ -57,7 +57,7 @@ test_that("shade_p_value works", { }) test_that("shade_p_value accepts synonyms for 'direction'", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_doppelganger( "pval-direction-right", gss_viz_sim + shade_p_value(1, "greater") @@ -80,7 +80,7 @@ test_that("shade_p_value accepts synonyms for 'direction'", { }) test_that("shade_p_value uses extra aesthetic", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_doppelganger( "pval-extra-aes-1", @@ -97,7 +97,7 @@ test_that("shade_p_value uses extra aesthetic", { }) test_that("shade_p_value accepts `NULL` as `obs_stat`", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_doppelganger( "pval-null-obs_stat", gss_viz_sim + shade_p_value(NULL, "left") @@ -105,7 +105,7 @@ test_that("shade_p_value accepts `NULL` as `obs_stat`", { }) test_that("shade_p_value throws errors", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_error(gss_viz_sim + shade_p_value("a", "right"), "numeric") expect_error(gss_viz_sim + shade_p_value(1, 1), "character") @@ -131,7 +131,7 @@ test_that("shade_p_value throws errors", { # norm_direction ---------------------------------------------------------- test_that("norm_direction works", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_equal(norm_direction("left"), "left") expect_equal(norm_direction("less"), "left") diff --git a/tests/testthat/test-visualize.R b/tests/testthat/test-visualize.R index 5ddd3855..d96ba85a 100644 --- a/tests/testthat/test-visualize.R +++ b/tests/testthat/test-visualize.R @@ -46,7 +46,7 @@ obs_F <- anova( )$`F value`[1] test_that("visualize basic tests", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_doppelganger("visualize", visualize(hours_resamp)) @@ -372,13 +372,13 @@ test_that("visualize basic tests", { }) test_that("mirror_obs_stat works", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_equal(mirror_obs_stat(1:10, 4), c(`60%` = 6.4)) }) test_that("obs_stat as a data.frame works", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") mean_petal_width <- gss_tbl %>% specify(hours ~ NULL) %>% @@ -411,7 +411,7 @@ test_that("obs_stat as a data.frame works", { }) test_that('method = "both" behaves nicely', { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") # stop_glue( # '`generate()` and `calculate()` are both required to be done prior ', # 'to `visualize(method = "both")`' @@ -439,7 +439,7 @@ test_that('method = "both" behaves nicely', { }) test_that("Traditional right-tailed tests have warning if not right-tailed", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_warning( gss_tbl %>% @@ -476,7 +476,7 @@ test_that("Traditional right-tailed tests have warning if not right-tailed", { }) test_that("confidence interval plots are working", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") gss_tbl_boot <- gss_tbl %>% specify(sex ~ college, success = "female") %>% @@ -504,7 +504,7 @@ test_that("confidence interval plots are working", { }) test_that("title adapts to not hypothesis testing workflow", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") set.seed(100) gss_tbl_boot_tbl <- gss_tbl %>% @@ -528,7 +528,7 @@ test_that("title adapts to not hypothesis testing workflow", { }) test_that("warn_right_tail_test works", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") expect_warn_right_tail <- function(stat_name) { warn_regex <- paste0(stat_name, ".*right-tailed") @@ -544,7 +544,7 @@ test_that("warn_right_tail_test works", { }) test_that("visualize warns about removing `NaN`", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() > "4.0.2") dist <- gss_tbl_boot_tbl <- gss_tbl %>% specify(response = hours) %>% From c981e669036c06bb07ac03c274eb50038551d5ef Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Mon, 6 Jul 2020 09:46:14 -0700 Subject: [PATCH 25/28] submit to cran! --- CRAN-RELEASE | 4 ++-- cran-comments.md | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CRAN-RELEASE b/CRAN-RELEASE index 37450483..850ef9f2 100644 --- a/CRAN-RELEASE +++ b/CRAN-RELEASE @@ -1,2 +1,2 @@ -This package was submitted to CRAN on 2020-07-05. -Once it is accepted, delete this file and tag the release (commit f46ebf925a). +This package was submitted to CRAN on 2020-07-06. +Once it is accepted, delete this file and tag the release (commit c43b68df61). diff --git a/cran-comments.md b/cran-comments.md index ea15bdba..1aec456e 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,8 @@ ## infer 0.5.3 -This release fixes failing CRAN checks related to long-double support. +This release fixes failing CRAN checks related to long-double support. This +submission is a resubmission following an automated pretest failure +related to visual testing failures on the most recent R-devel version. ## Test environments * local OS X install, R 4.0.2 From 94a33eb258907955c5fc718277374b33733259c9 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Mon, 6 Jul 2020 18:25:38 -0700 Subject: [PATCH 26/28] explicitly suggest fs --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 164af6d7..34137b3a 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,7 +43,8 @@ Suggests: stringr, testthat, covr, - vdiffr + vdiffr, + fs URL: https://github.com/tidymodels/infer, https://infer.netlify.com/ BugReports: https://github.com/tidymodels/infer/issues From a14539a4f9d226cf42c1dcc27299cc3167cf39f5 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Tue, 7 Jul 2020 09:44:19 -0700 Subject: [PATCH 27/28] submit to cran! --- CRAN-RELEASE | 4 ++-- cran-comments.md | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CRAN-RELEASE b/CRAN-RELEASE index 850ef9f2..56c5a0a3 100644 --- a/CRAN-RELEASE +++ b/CRAN-RELEASE @@ -1,2 +1,2 @@ -This package was submitted to CRAN on 2020-07-06. -Once it is accepted, delete this file and tag the release (commit c43b68df61). +This package was submitted to CRAN on 2020-07-07. +Once it is accepted, delete this file and tag the release (commit 94a33eb258). diff --git a/cran-comments.md b/cran-comments.md index 1aec456e..cfd718d5 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,11 @@ ## infer 0.5.3 This release fixes failing CRAN checks related to long-double support. This -submission is a resubmission following an automated pretest failure -related to visual testing failures on the most recent R-devel version. +submission is a resubmission following an automated pretest failure due to +a warning resulting from the newly released sf package. + +The previous submission was also a resubmission following an automated pretest +failure related to visual testing failures on the most recent R-devel version. ## Test environments * local OS X install, R 4.0.2 From 583421829c339eb0bca5576cd1edfd3ce4f574c6 Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Wed, 15 Jul 2020 09:51:42 -0700 Subject: [PATCH 28/28] 0.5.3 on CRAN! --- CRAN-RELEASE | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 CRAN-RELEASE diff --git a/CRAN-RELEASE b/CRAN-RELEASE deleted file mode 100644 index 56c5a0a3..00000000 --- a/CRAN-RELEASE +++ /dev/null @@ -1,2 +0,0 @@ -This package was submitted to CRAN on 2020-07-07. -Once it is accepted, delete this file and tag the release (commit 94a33eb258).