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 diff --git a/CONDUCT.md b/CONDUCT.md index 066b7960..9c695e85 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 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. + +## 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/DESCRIPTION b/DESCRIPTION index f13c58e3..34137b3a 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: infer Type: Package Title: Tidy Statistical Inference -Version: 0.5.2 +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"), @@ -32,7 +32,7 @@ Imports: grDevices, purrr Depends: - R (>= 3.1.2) + R (>= 3.5.0) Suggests: broom, devtools (>= 1.12.0), @@ -43,10 +43,11 @@ Suggests: stringr, testthat, covr, - vdiffr + vdiffr, + fs 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 6c811572..abc8a1f7 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,20 @@ +# infer 0.5.3 + +## Breaking changes + +- `get_confidence_interval()` now uses column names ('lower_ci' and 'upper_ci') +in output that are consistent with other infer functionality (#317). + +## New functionality + +- `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 + +- 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/R/get_confidence_interval.R b/R/get_confidence_interval.R index 3142a525..a0e55f67 100644 --- a/R/get_confidence_interval.R +++ b/R/get_confidence_interval.R @@ -14,12 +14,14 @@ #' 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 'lower_ci' and 'upper_ci' columns. Values +#' correspond to lower and upper bounds of the confidence interval. #' -#' @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 +45,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 +61,90 @@ #' @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)) - - 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"]])) + + # 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.") } - - return(ci) + + switch( + type, + percentile = ci_percentile(x, level), + se = ci_se(x, level, point_estimate), + `bias-corrected` = ci_bias_corrected(x, level, point_estimate) + ) } #' @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){ +ci_percentile <- function(x, level) { + ci_vec <- stats::quantile(x[["stat"]], probs = (1 + c(-level, level)) / 2) + + make_ci_df(ci_vec) +} - if(!is.null(point_estimate)){ - if(!is.data.frame(point_estimate)) +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"]]) + + make_ci_df(ci_vec) +} + +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) + + make_ci_df(ci_vec) +} + +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 + } else { check_type(point_estimate, is.data.frame) + check_type(point_estimate[[1]][[1]], is.numeric) + } } 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"))){ - 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)) - 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 %in% c("se", "bias-corrected")) && is.null(point_estimate)) { + stop_glue( + 'A numeric value needs to be given for `point_estimate` ', + 'for `type` "se" or "bias-corrected".' + ) + } } +make_ci_df <- function(ci_vec) { + tibble::tibble(lower_ci = ci_vec[[1]], upper_ci = ci_vec[[2]]) +} 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/README.Rmd b/README.Rmd index ce7c3055..a7928728 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/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 342b5011..ad8a8c63 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/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 @@ -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 diff --git a/cran-comments.md b/cran-comments.md index a0ea0bf5..cfd718d5 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,16 @@ +## 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 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.0 +* local OS X install, R 4.0.2 * 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 +19,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 +remaining on bioconductor, and found no new issues. diff --git a/man/get_confidence_interval.Rd b/man/get_confidence_interval.Rd index 7392d66b..f534b35f 100644 --- a/man/get_confidence_interval.Rd +++ b/man/get_confidence_interval.Rd @@ -24,14 +24,15 @@ 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 -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 @@ -63,11 +64,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{ 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..663ff5a9 100644 --- a/tests/testthat/helper-data.R +++ b/tests/testthat/helper-data.R @@ -1,19 +1,17 @@ set.seed(4242) -iris_df <- tibble::as_tibble(iris) +eps <- if (capabilities("long.double")) {sqrt(.Machine$double.eps)} else {0.01} -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") - ) +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_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 +19,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..85390578 100644 --- a/tests/testthat/test-aliases.R +++ b/tests/testthat/test-aliases.R @@ -1,11 +1,12 @@ 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, + tolerance = eps ) expect_silent(test_df %>% get_ci()) @@ -13,10 +14,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..46eb96a3 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,9 +429,9 @@ 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)), - tolerance = 1e-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 = eps ) }) @@ -454,22 +445,22 @@ 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), + tolerance = eps ) - 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)), - # 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", { @@ -483,28 +474,29 @@ 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"), + tolerance = eps ) 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 %>% @@ -512,12 +504,12 @@ 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", { - 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 %>% @@ -525,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 918defe5..dbe3e410 100644 --- a/tests/testthat/test-get_confidence_interval.R +++ b/tests/testthat/test-get_confidence_interval.R @@ -1,20 +1,127 @@ -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")) - - expect_silent(iris_calc %>% - get_confidence_interval(type = "se", - point_estimate = 4)) - expect_silent(iris_calc %>% - get_confidence_interval(type = "se", - point_estimate = obs_diff)) - expect_error(iris_calc %>% - get_confidence_interval(type = "se", - point_estimate = "error")) - expect_error(iris_calc %>% - get_confidence_interval(type = "se")) +context("get_confidence_interval") + +point <- mean(test_df[["stat"]]) + +perc_def_out <- tibble::tibble( + 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", { + expect_message( + expect_equal(test_df %>% get_confidence_interval(), perc_def_out), + "Using `level = 0.95`" + ) +}) + +test_that("get_confidence_interval works with `type = 'percentile'`", { + expect_message( + expect_equal( + 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( + lower_ci = unname(quantile(test_df[["stat"]], 0.25)), + upper_ci = unname(quantile(test_df[["stat"]], 0.75)) + ) + ) +}) + +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_ci = -1.965, upper_ci = 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_ci = -0.662, upper_ci = 0.705), + tolerance = 1e-3 + ) +}) + +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 + ), + tibble::tibble(lower_ci = -1.692, upper_ci = 2.276), + tolerance = 1e-3 + ), + "Using `level = 0.95`" + ) + + expect_equal( + test_df %>% + get_confidence_interval( + level = 0.5, type = "bias-corrected", point_estimate = point + ), + tibble::tibble(lower_ci = -0.594, upper_ci = 0.815), + tolerance = 1e-3 + ) +}) + +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), + tolerance = eps + ) + 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 + ), + tolerance = eps + ) +}) + +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", { + 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( + 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( + test_df %>% get_confidence_interval(type = "se"), '`point_estimate`.*"se"' + ) + expect_error( + test_df %>% get_confidence_interval(type = "bias-corrected"), + '`point_estimate`.*"bias-corrected"' + ) }) diff --git a/tests/testthat/test-get_p_value.R b/tests/testthat/test-get_p_value.R index a76d2088..26b2afc4 100644 --- a/tests/testthat/test-get_p_value.R +++ b/tests/testthat/test-get_p_value.R @@ -12,41 +12,53 @@ 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")) expect_equal( - get_p_value(test_df, 4, "two_sided"), get_p_value(test_df, 4, "both") + 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"), + tolerance = eps ) }) 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-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-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..11fc8c9e 100644 --- a/tests/testthat/test-shade_confidence_interval.R +++ b/tests/testthat/test-shade_confidence_interval.R @@ -5,83 +5,91 @@ library(vdiffr) # shade_confidence_interval ----------------------------------------------- test_that("shade_confidence_interval works", { + skip_if(getRversion() > "4.0.2") + # 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`", { + skip_if(getRversion() > "4.0.2") + 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", { + skip_if(getRversion() > "4.0.2") + 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") + skip_if(getRversion() > "4.0.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..b5f575b3 100644 --- a/tests/testthat/test-shade_p_value.R +++ b/tests/testthat/test-shade_p_value.R @@ -5,114 +5,124 @@ library(vdiffr) # shade_p_value ----------------------------------------------------------- test_that("shade_p_value works", { + skip_if(getRversion() > "4.0.2") + # 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'", { + skip_if(getRversion() > "4.0.2") + 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", { + skip_if(getRversion() > "4.0.2") + 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`", { + skip_if(getRversion() > "4.0.2") + 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"), + 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") + 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") @@ -121,6 +131,8 @@ test_that("shade_p_value throws errors", { # norm_direction ---------------------------------------------------------- test_that("norm_direction works", { + skip_if(getRversion() > "4.0.2") + 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 ece0552c..d96ba85a 100644 --- a/tests/testthat/test-visualize.R +++ b/tests/testthat/test-visualize.R @@ -5,58 +5,60 @@ 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)) + skip_if(getRversion() > "4.0.2") + + 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 +69,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 +93,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 +104,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 +116,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 +128,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 +140,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 +152,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 +164,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 +176,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 +188,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 +198,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 +208,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 +220,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 +232,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 +244,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 +271,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 +285,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 +300,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 +313,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 +344,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,30 +360,34 @@ 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" ) ) }) test_that("mirror_obs_stat works", { + 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", { - mean_petal_width <- iris_tbl %>% - specify(Petal.Width ~ NULL) %>% + skip_if(getRversion() > "4.0.2") + + 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 +400,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") %>% @@ -398,13 +411,14 @@ test_that("obs_stat as a data.frame works", { }) test_that('method = "both" behaves nicely', { + skip_if(getRversion() > "4.0.2") # stop_glue( # '`generate()` and `calculate()` are both required to be done prior ', # '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,44 +428,46 @@ 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") ) ) }) test_that("Traditional right-tailed tests have warning if not right-tailed", { + skip_if(getRversion() > "4.0.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") %>% 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 +476,51 @@ 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") %>% + skip_if(getRversion() > "4.0.2") + + 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", { + skip_if(getRversion() > "4.0.2") + 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") ) @@ -508,6 +528,8 @@ test_that("title adapts to not hypothesis testing workflow", { }) test_that("warn_right_tail_test works", { + skip_if(getRversion() > "4.0.2") + expect_warn_right_tail <- function(stat_name) { warn_regex <- paste0(stat_name, ".*right-tailed") @@ -522,8 +544,10 @@ test_that("warn_right_tail_test works", { }) test_that("visualize warns about removing `NaN`", { - dist <- iris_boot_tbl <- iris_tbl %>% - specify(response = Sepal.Width) %>% + skip_if(getRversion() > "4.0.2") + + 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..cf6e3aaf 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,29 +45,28 @@ 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) - 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(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 +74,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 +175,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)