From 0157227533747af63fa7e57471194f29fc9ca9b8 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 1 Jun 2021 18:30:02 +0000 Subject: [PATCH] version 3.1.6 --- DESCRIPTION | 10 ++--- MD5 | 12 +++--- NEWS.md | 6 +++ R/helpers.R | 18 ++++----- R/pairwise_comparisons.R | 76 +++++++++++++++++++------------------ README.md | 21 ++++++---- man/pairwise_comparisons.Rd | 20 ++++++++-- 7 files changed, 93 insertions(+), 70 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 701f909..cb1b010 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: pairwiseComparisons Title: Multiple Pairwise Comparison Tests -Version: 3.1.5 +Version: 3.1.6 Authors@R: person(given = "Indrajeet", family = "Patil", @@ -21,8 +21,8 @@ URL: https://indrajeetpatil.github.io/pairwiseComparisons/, https://github.com/IndrajeetPatil/pairwiseComparisons BugReports: https://github.com/IndrajeetPatil/pairwiseComparisons/issues Depends: R (>= 3.6.0) -Imports: BayesFactor, dplyr, insight (>= 0.13.2), ipmisc, parameters - (>= 0.13.0), PMCMRplus, purrr, rlang, stats, WRS2 +Imports: BayesFactor, dplyr, insight (>= 0.14.1), ipmisc, parameters + (>= 0.14.0), PMCMRplus, purrr, rlang, stats, WRS2 (>= 1.1-1) Suggests: knitr, rmarkdown, spelling, testthat Encoding: UTF-8 Language: en-US @@ -31,8 +31,8 @@ RoxygenNote: 7.1.1.9001 Config/testthat/edition: 3 Config/testthat/parallel: true NeedsCompilation: no -Packaged: 2021-04-27 19:56:55 UTC; patil +Packaged: 2021-06-01 18:59:05 UTC; patil Author: Indrajeet Patil [cre, aut, cph] (, @patilindrajeets) Repository: CRAN -Date/Publication: 2021-04-27 20:30:02 UTC +Date/Publication: 2021-06-01 19:30:02 UTC diff --git a/MD5 b/MD5 index e33ed72..96a4c65 100644 --- a/MD5 +++ b/MD5 @@ -1,13 +1,13 @@ -6a18e352d9e7cd948be120c5cad8a9b5 *DESCRIPTION +79e44abfb2179979e1b4b9e6e827a1cc *DESCRIPTION 13126da2bad169ecfe01da3858042b62 *LICENSE 8f3ff8616f27753eb2f99de2c22651ab *NAMESPACE -37a507b4b641be4609ef013b05934f6b *NEWS.md +0efaf046cc2d88b23969e52ecef3bf14 *NEWS.md e159c89f70bd1346ac96d934fead7650 *R/data.R fc2a6efd2abe22c37d72745bceb27e15 *R/global_vars.R -cbca5e474f8e9f71c4387ecee5542233 *R/helpers.R -5d0f5f1753a9fdef3e5928f01b0e4174 *R/pairwise_comparisons.R +a3fa937dc9ef5f179189a3a8f15a2080 *R/helpers.R +27333a9d7a6747963cf3599e91c0db4b *R/pairwise_comparisons.R 3466adb4e21bde4a3b8e0ec9a4a6e609 *R/reexports.R -6f21915363252df9f3da79c06a68fd0f *README.md +5be0d56401e45a5e015cbfdcc1443521 *README.md 60e0e78acc2c42531f52352f480329c2 *data/bugs_long.rdata 91069babfae39db7b08f35ede31084f2 *data/movies_long.rdata 54a342a94ac6e4232913e999a95d4e94 *data/movies_wide.rdata @@ -29,7 +29,7 @@ c3978703d8f40f2679795335715e98f4 *man/figures/lifecycle-experimental.svg 6255c1a466c7dc9cd2a52692be34bf93 *man/movies_wide.Rd 13938dce6baedd253f81a8f4ffaeca07 *man/p_adjust_text.Rd 69a3280df6dc95060c245b44708be994 *man/pairwise_caption.Rd -18fdfbe07ac9b33f1692c37eddc4b844 *man/pairwise_comparisons.Rd +d8aedfbcd16a34f2ea51bda525c9a0d6 *man/pairwise_comparisons.Rd ccd436efc6a3de78bac2165798cf3b8e *man/reexports.Rd 50f330eeca8db092d6807e04457bd06d *tests/spelling.R 27ea038f6a1f6b418b4fecf225d1693e *tests/testthat.R diff --git a/NEWS.md b/NEWS.md index 5d62929..2289537 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# pairwiseComparisons 3.1.6 + + - Maintenance and internal changes. + + - Improvements to docs. + # pairwiseComparisons 3.1.5 - To avoid confusion among users, the trimming level for all functions is now diff --git a/R/helpers.R b/R/helpers.R index 435f2f7..d8b0ad0 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -3,7 +3,7 @@ tidy_model_parameters <- function(model, ...) { parameters::model_parameters(model, verbose = FALSE, ...) %>% - parameters::standardize_names(data = ., style = "broom") + parameters::standardize_names(style = "broom") } #' @importFrom BayesFactor ttestBF @@ -18,7 +18,6 @@ bf_ttest <- function(data, x, y, paired = FALSE, bf.prior = 0.707, ...) { # have a proper cleanup with NA removal data %<>% ipmisc::long_to_wide_converter( - data = ., x = {{ x }}, y = {{ y }}, paired = paired, @@ -30,14 +29,13 @@ bf_ttest <- function(data, x, y, paired = FALSE, bf.prior = 0.707, ...) { if (isFALSE(paired)) bf.args <- list(formula = rlang::new_formula(y, x)) # creating a BayesFactor object - bf_object <- - rlang::exec( - .fn = BayesFactor::ttestBF, - rscale = bf.prior, - paired = paired, - data = as.data.frame(data), - !!!bf.args - ) + bf_object <- rlang::exec( + .fn = BayesFactor::ttestBF, + rscale = bf.prior, + paired = paired, + data = as.data.frame(data), + !!!bf.args + ) # extracting Bayes Factors and other details dplyr::filter(tidy_model_parameters(bf_object), !is.na(bayes.factor)) %>% diff --git a/R/pairwise_comparisons.R b/R/pairwise_comparisons.R index 1f911c0..dadeaa2 100644 --- a/R/pairwise_comparisons.R +++ b/R/pairwise_comparisons.R @@ -24,10 +24,15 @@ #' `FALSE`. #' @param k Number of digits after decimal point (should be an integer) #' (Default: `k = 2L`). +#' @param bf.prior A number between `0.5` and `2` (default `0.707`), the prior +#' width to use in calculating Bayes factors and posterior estimates. In +#' addition to numeric arguments, several named values are also recognized: +#' `"medium"`, `"wide"`, and `"ultrawide"`, corresponding to *r* scale values +#' of 1/2, sqrt(2)/2, and 1, respectively. In case of an ANOVA, this value +#' corresponds to scale for fixed effects. #' @param ... Additional arguments passed to other methods. #' @inheritParams stats::t.test #' @inheritParams WRS2::rmmcp -#' @inheritParams tidyBF::bf_ttest #' #' @return A tibble dataframe containing two columns corresponding to group #' levels being compared with each other (`group1` and `group2`) and `p.value` @@ -234,23 +239,22 @@ pairwise_comparisons <- function(data, # running the appropriate test if (type != "robust") { - df <- - suppressWarnings(rlang::exec( - .fn = .f, - # Dunn, Games-Howell, Student test - x = y_vec, - g = x_vec, - # Durbin-Conover test - groups = x_vec, - blocks = g_vec, - # Student - paired = paired, - # common - na.action = na.omit, - p.adjust.method = "none", - # problematic for other methods - !!!.f.args - )) %>% + df <- suppressWarnings(rlang::exec( + .fn = .f, + # Dunn, Games-Howell, Student test + x = y_vec, + g = x_vec, + # Durbin-Conover test + groups = x_vec, + blocks = g_vec, + # Student + paired = paired, + # common + na.action = na.omit, + p.adjust.method = "none", + # problematic for other methods + !!!.f.args + )) %>% tidy_model_parameters(.) %>% dplyr::rename(group2 = group1, group1 = group2) } @@ -268,8 +272,7 @@ pairwise_comparisons <- function(data, } # cleaning the raw object and getting it in the right format - df <- - eval(rlang::call2(.ns = .ns, .fn = .fn, tr = tr, !!!.f.args)) %>% + df <- eval(rlang::call2(.ns = .ns, .fn = .fn, tr = tr, !!!.f.args)) %>% tidy_model_parameters(.) # test details @@ -280,23 +283,22 @@ pairwise_comparisons <- function(data, if (type == "bayes") { # combining results into a single dataframe and returning it - df_tidy <- - purrr::map_dfr( - # creating a list of dataframes with subsections of data - .x = purrr::map2( - .x = as.character(df$group1), - .y = as.character(df$group2), - .f = function(a, b) droplevels(dplyr::filter(df_int, {{ x }} %in% c(a, b))) - ), - # internal function to carry out BF t-test - .f = ~ bf_ttest( - data = .x, - x = {{ x }}, - y = {{ y }}, - paired = paired, - bf.prior = bf.prior - ) - ) %>% + df_tidy <- purrr::map_dfr( + # creating a list of dataframes with subsections of data + .x = purrr::map2( + .x = as.character(df$group1), + .y = as.character(df$group2), + .f = function(a, b) droplevels(dplyr::filter(df_int, {{ x }} %in% c(a, b))) + ), + # internal function to carry out BF t-test + .f = ~ bf_ttest( + data = .x, + x = {{ x }}, + y = {{ y }}, + paired = paired, + bf.prior = bf.prior + ) + ) %>% dplyr::rowwise() %>% dplyr::mutate(label = paste0("list(~log[e](BF['01'])==", format_value(-log_e_bf10, k), ")")) %>% dplyr::ungroup() %>% diff --git a/README.md b/README.md index 72d1b10..194e062 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,19 @@ # `pairwiseComparisons`: Multiple Pairwise Comparison Tests -| Package | Status | Usage | GitHub | References | -|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [![CRAN\_Release\_Badge](http://www.r-pkg.org/badges/version-ago/pairwiseComparisons)](https://CRAN.R-project.org/package=pairwiseComparisons) | [![Travis Build Status](https://travis-ci.org/IndrajeetPatil/pairwiseComparisons.svg?branch=master)](https://travis-ci.org/IndrajeetPatil/pairwiseComparisons) | [![Daily downloads badge](https://cranlogs.r-pkg.org/badges/last-day/pairwiseComparisons?color=blue)](https://CRAN.R-project.org/package=pairwiseComparisons) | [![GitHub version](https://img.shields.io/badge/GitHub-3.1.5-orange.svg?style=flat-square)](https://github.com/IndrajeetPatil/pairwiseComparisons/) | [![Website](https://img.shields.io/badge/website-pairwiseComparisons-orange.svg?colorB=E91E63)](https://indrajeetpatil.github.io/pairwiseComparisons/) | -| [![CRAN Checks](https://cranchecks.info/badges/summary/pairwiseComparisons)](https://cran.r-project.org/web/checks/check_results_pairwiseComparisons.html) | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/IndrajeetPatil/pairwiseComparisons?branch=master&svg=true)](https://ci.appveyor.com/project/IndrajeetPatil/pairwiseComparisons) | [![Weekly downloads badge](https://cranlogs.r-pkg.org/badges/last-week/pairwiseComparisons?color=blue)](https://CRAN.R-project.org/package=pairwiseComparisons) | [![Forks](https://img.shields.io/badge/forks-5-blue.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/) | [![Rdoc](https://www.rdocumentation.org/badges/version/pairwiseComparisons)](https://www.rdocumentation.org/packages/pairwiseComparisons) | -| [![minimal R version](https://img.shields.io/badge/R%3E%3D-3.6.0-6666ff.svg)](https://cran.r-project.org/) | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) | [![Monthly downloads badge](https://cranlogs.r-pkg.org/badges/last-month/pairwiseComparisons?color=blue)](https://CRAN.R-project.org/package=pairwiseComparisons) | [![Github Issues](https://img.shields.io/badge/issues-1-red.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/issues) | [![vignettes](https://img.shields.io/badge/vignettes-3.1.0-orange.svg?colorB=FF5722)](https://github.com/IndrajeetPatil/pairwiseComparisons/blob/master/README.md) | -| [![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/IndrajeetPatil/pairwiseComparisons.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons) | [![Coverage Status](https://coveralls.io/repos/github/IndrajeetPatil/pairwiseComparisons/badge.svg?branch=master)](https://coveralls.io/github/IndrajeetPatil/pairwiseComparisons?branch=master) | [![Total downloads badge](https://cranlogs.r-pkg.org/badges/grand-total/pairwiseComparisons?color=blue)](https://CRAN.R-project.org/package=pairwiseComparisons) | [![Github Stars](https://img.shields.io/github/stars/IndrajeetPatil/pairwiseComparisons.svg?style=social&label=Github)](https://github.com/IndrajeetPatil/pairwiseComparisons) | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2074621.svg)](https://doi.org/10.5281/zenodo.2074621) | -| [![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) | [![Codecov test coverage](https://codecov.io/gh/IndrajeetPatil/pairwiseComparisons/branch/master/graph/badge.svg)](https://codecov.io/gh/IndrajeetPatil/pairwiseComparisons?branch=master) | [![pkgdown](https://github.com/IndrajeetPatil/pairwiseComparisons/workflows/pkgdown/badge.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/actions) | [![Last-changedate](https://img.shields.io/badge/last%20change-2021--04--27-yellowgreen.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/commits/master) | [![GitHub last commit](https://img.shields.io/github/last-commit/IndrajeetPatil/pairwiseComparisons.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/commits/master) | -| [![status](https://tinyverse.netlify.com/badge/pairwiseComparisons)](https://CRAN.R-project.org/package=pairwiseComparisons) | [![R build status](https://github.com/IndrajeetPatil/pairwiseComparisons/workflows/R-CMD-check/badge.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons) | [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/pairwiseComparisons/community) | [![Project Status](http://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) | [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/IndrajeetPatil/pairwiseComparisons/issues) | +[![CRAN\_Release\_Badge](https://www.r-pkg.org/badges/version-ago/pairwiseComparisons)](https://CRAN.R-project.org/package=pairwiseComparisons) +[![CRAN +Checks](https://cranchecks.info/badges/summary/pairwiseComparisons)](https://cran.r-project.org/web/checks/check_results_pairwiseComparisons.html) +[![Travis Build +Status](https://travis-ci.org/IndrajeetPatil/pairwiseComparisons.svg?branch=master)](https://travis-ci.org/IndrajeetPatil/pairwiseComparisons) +[![AppVeyor Build +Status](https://ci.appveyor.com/api/projects/status/github/IndrajeetPatil/pairwiseComparisons?branch=master&svg=true)](https://ci.appveyor.com/project/IndrajeetPatil/pairwiseComparisons) +[![pkgdown](https://github.com/IndrajeetPatil/pairwiseComparisons/workflows/pkgdown/badge.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/actions) +[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) +[![Daily downloads +badge](https://cranlogs.r-pkg.org/badges/last-day/pairwiseComparisons?color=blue)](https://CRAN.R-project.org/package=pairwiseComparisons) +[![Total downloads +badge](https://cranlogs.r-pkg.org/badges/grand-total/pairwiseComparisons?color=blue)](https://CRAN.R-project.org/package=pairwiseComparisons) # Introduction diff --git a/man/pairwise_comparisons.Rd b/man/pairwise_comparisons.Rd index d8b90d0..c290cc2 100644 --- a/man/pairwise_comparisons.Rd +++ b/man/pairwise_comparisons.Rd @@ -24,18 +24,26 @@ pairwise_comparisons( be taken. Other data types (e.g., matrix,table, array, etc.) will \strong{not} be accepted.} -\item{x}{The grouping (or independent) variable from the dataframe \code{data}.} +\item{x}{The grouping (or independent) variable from the dataframe \code{data}. In +case of a repeated measures or within-subjects design, if \code{subject.id} +argument is not available or not explicitly specified, the function assumes +that the data has already been sorted by such an id by the user and creates +an internal identifier. So if your data is \strong{not} sorted, the results +\emph{can} be inaccurate when there are more than two levels in \code{x} and there +are \code{NA}s present. The data is expected to be sorted by user in +subject-1,subject-2, ..., pattern.} \item{y}{The response (or outcome or dependent) variable from the dataframe \code{data}.} -\item{subject.id}{Relevant in case of repeated measures or within-subjects +\item{subject.id}{Relevant in case of a repeated measures or within-subjects design (\code{paired = TRUE}, i.e.), it specifies the subject or repeated measures identifier. \strong{Important}: Note that if this argument is \code{NULL} (which is the default), the function assumes that the data has already been sorted by such an id by the user and creates an internal identifier. So if your data is \strong{not} sorted and you leave this argument unspecified, the -results can be inaccurate.} +results \emph{can} be inaccurate when there are more than two levels in \code{x} and +there are \code{NA}s present.} \item{type}{Type of statistic expected (\code{"parametric"} or \code{"nonparametric"} or \code{"robust"} or \code{"bayes"}).Corresponding abbreviations are also accepted: @@ -58,7 +66,11 @@ try to play around with the value of \code{tr}, which is by default set to \code{0.2}. Lowering the value might help.} \item{bf.prior}{A number between \code{0.5} and \code{2} (default \code{0.707}), the prior -width to use in calculating Bayes factors.} +width to use in calculating Bayes factors and posterior estimates. In +addition to numeric arguments, several named values are also recognized: +\code{"medium"}, \code{"wide"}, and \code{"ultrawide"}, corresponding to \emph{r} scale values +of 1/2, sqrt(2)/2, and 1, respectively. In case of an ANOVA, this value +corresponds to scale for fixed effects.} \item{p.adjust.method}{Adjustment method for \emph{p}-values for multiple comparisons. Possible methods are: \code{"holm"} (default), \code{"hochberg"},