{"id":13857572,"url":"https://github.com/IndrajeetPatil/pairwiseComparisons","last_synced_at":"2025-07-13T21:33:19.032Z","repository":{"id":48556264,"uuid":"203628108","full_name":"IndrajeetPatil/pairwiseComparisons","owner":"IndrajeetPatil","description":"Pairwise comparison tests for one-way designs 🔬📝","archived":true,"fork":false,"pushed_at":"2022-03-23T22:07:18.000Z","size":6419,"stargazers_count":45,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-06T03:04:08.631Z","etag":null,"topics":["bayes-factor","pairwise-comparison-tests","parametric","robust","statistics"],"latest_commit_sha":null,"homepage":"https://indrajeetpatil.github.io/pairwiseComparisons/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IndrajeetPatil.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS.txt","security":null,"support":null}},"created_at":"2019-08-21T16:58:17.000Z","updated_at":"2024-07-12T04:21:39.000Z","dependencies_parsed_at":"2022-08-25T00:21:33.072Z","dependency_job_id":null,"html_url":"https://github.com/IndrajeetPatil/pairwiseComparisons","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndrajeetPatil%2FpairwiseComparisons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndrajeetPatil%2FpairwiseComparisons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndrajeetPatil%2FpairwiseComparisons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndrajeetPatil%2FpairwiseComparisons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IndrajeetPatil","download_url":"https://codeload.github.com/IndrajeetPatil/pairwiseComparisons/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225920406,"owners_count":17545484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayes-factor","pairwise-comparison-tests","parametric","robust","statistics"],"created_at":"2024-08-05T03:01:40.916Z","updated_at":"2024-11-22T15:30:58.058Z","avatar_url":"https://github.com/IndrajeetPatil.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n  \u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\n# pretty printing for the tibble\noptions(\n  tibble.width = Inf,\n  pillar.bold = TRUE,\n  pillar.neg = TRUE,\n  pillar.subtle_num = TRUE,\n  pillar.min_chars = Inf\n)\n\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  dpi = 300,\n  out.width = \"100%\",\n  comment = \"#\u003e\",\n  warning = FALSE,\n  message = FALSE,\n  fig.path = \"man/figures/README-\"\n)\n```\n\n# `{pairwiseComparisons}`: Multiple Pairwise Comparison Tests\n\n[![lifecycle](https://img.shields.io/badge/lifecycle-retired-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![R build status](https://github.com/IndrajeetPatil/pairwiseComparisons/workflows/R-CMD-check/badge.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons)\n[![pkgdown](https://github.com/IndrajeetPatil/pairwiseComparisons/workflows/pkgdown/badge.svg)](https://github.com/IndrajeetPatil/pairwiseComparisons/actions)\n\n# Introduction \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"240\" /\u003e\n\n[`{pairwiseComparisons}`](https://indrajeetpatil.github.io/pairwiseComparisons/)\nprovides a tidy data friendly way to carry out pairwise comparison tests.\n\nIt currently supports *post hoc* multiple pairwise comparisons tests for both\nbetween-subjects and within-subjects one-way analysis of variance designs. For\nboth of these designs, parametric, non-parametric, robust, and Bayesian\nstatistical tests are available.\n\n# Installation\n\nType | Source | Command\n---|---|---\nRelease | CRAN | `install.packages(\"pairwiseComparisons\")`\nDevelopment | GitHub | `remotes::install_github(\"IndrajeetPatil/pairwiseComparisons\")`\n\nLinux users may encounter some installation problems. In particular, the\n`{pairwiseComparisons}` package depends on the `PMCMRplus` package.\n\n```\nERROR: dependencies ‘gmp’, ‘Rmpfr’ are not available for package ‘PMCMRplus’\nERROR: dependency ‘pairwiseComparisons’ is not available for package ‘ggstatsplot’\n```\n\nThis means that your operating system lacks `gmp` and `Rmpfr` libraries.\n\nIf you use `Ubuntu`, you can install these dependencies:\n\n```\nsudo apt-get install libgmp3-dev\nsudo apt-get install libmpfr-dev\n```\n\nThe following `README` file briefly describes the installation procedure:\n\u003chttps://CRAN.R-project.org/package=PMCMRplus/readme/README.html\u003e\n\n# Summary of types of statistical analyses\n\nFollowing table contains a brief summary of the currently supported pairwise\ncomparison tests-\n\n## Between-subjects design\n\nType | Equal variance? | Test | *p*-value adjustment? | Function used\n----------- | --- | ------------------------- | --- | -----\nParametric | No | Games-Howell test | ✅ | `stats::pairwise.t.test`\nParametric | Yes | Student's *t*-test | ✅ | `PMCMRplus::gamesHowellTest`\nNon-parametric | No | Dunn test | ✅ | `PMCMRplus::kwAllPairsDunnTest`\nRobust | No | Yuen's trimmed means test | ✅ | `WRS2::lincon`\nBayesian | `NA` | Student's *t*-test | `NA` | `BayesFactor::ttestBF`\n\n## Within-subjects design\n\nType | Test | *p*-value adjustment? | Function used\n----------- | ---------------------------- | --- | -----\nParametric | Student's *t*-test | ✅ | `stats::pairwise.t.test`\nNon-parametric | Durbin-Conover test | ✅ | `PMCMRplus::durbinAllPairsTest` \nRobust | Yuen's trimmed means test | ✅ | `WRS2::rmmcp`\nBayesian | Student's *t*-test | `NA` | `BayesFactor::ttestBF`\n\n# Examples\n\nHere we will see specific examples of how to use this function for different\ntypes of\n\n  - designs (between or within subjects)\n  - statistics (parametric, non-parametric, robust, Bayesian)\n  - *p*-value adjustment methods\n\n## Between-subjects design\n\n```{r}\n# for reproducibility\nset.seed(123)\nlibrary(pairwiseComparisons)\nlibrary(statsExpressions) # for data\n\n# parametric\n# if `var.equal = TRUE`, then Student's *t*-test will be run\npairwise_comparisons(\n  data = ggplot2::msleep,\n  x = vore,\n  y = brainwt,\n  type = \"parametric\",\n  var.equal = TRUE,\n  paired = FALSE,\n  p.adjust.method = \"bonferroni\"\n)\n\n# if `var.equal = FALSE`, then Games-Howell test will be run\npairwise_comparisons(\n  data = ggplot2::msleep,\n  x = vore,\n  y = brainwt,\n  type = \"parametric\",\n  var.equal = FALSE,\n  paired = FALSE,\n  p.adjust.method = \"bonferroni\"\n)\n\n# non-parametric\npairwise_comparisons(\n  data = ggplot2::msleep,\n  x = vore,\n  y = brainwt,\n  type = \"nonparametric\",\n  paired = FALSE,\n  p.adjust.method = \"none\"\n)\n\n# robust\npairwise_comparisons(\n  data = ggplot2::msleep,\n  x = vore,\n  y = brainwt,\n  type = \"robust\",\n  paired = FALSE,\n  p.adjust.method = \"fdr\"\n)\n\n# Bayesian\npairwise_comparisons(\n  data = ggplot2::msleep,\n  x = vore,\n  y = brainwt,\n  type = \"bayes\",\n  paired = FALSE\n)\n```\n\n\n## Within-subjects design\n\n```{r}\n# for reproducibility\nset.seed(123)\n\n# parametric\npairwise_comparisons(\n  data = bugs_long,\n  x = condition,\n  y = desire,\n  subject.id = subject,\n  type = \"parametric\",\n  paired = TRUE,\n  p.adjust.method = \"BH\"\n)\n\n# non-parametric\npairwise_comparisons(\n  data = bugs_long,\n  x = condition,\n  y = desire,\n  subject.id = subject,\n  type = \"nonparametric\",\n  paired = TRUE,\n  p.adjust.method = \"BY\"\n)\n\n# robust\npairwise_comparisons(\n  data = bugs_long,\n  x = condition,\n  y = desire,\n  subject.id = subject,\n  type = \"robust\",\n  paired = TRUE,\n  p.adjust.method = \"hommel\"\n)\n\n# Bayesian\npairwise_comparisons(\n  data = bugs_long,\n  x = condition,\n  y = desire,\n  subject.id = subject,\n  type = \"bayes\",\n  paired = TRUE,\n  bf.prior = 0.77\n)\n```\n\n# Using `{pairwiseComparisons}` with `ggsignif`\n\n## Example-1: between-subjects\n\n```{r ggsignif, fig.height=5}\n# needed libraries\nset.seed(123)\nlibrary(ggplot2)\nlibrary(pairwiseComparisons)\nlibrary(ggsignif)\n\n# converting to factor\nmtcars$cyl \u003c- as.factor(mtcars$cyl)\n\n# creating a basic plot\np \u003c- ggplot(mtcars, aes(cyl, wt)) +\n  geom_boxplot()\n\n# using `{pairwiseComparisons}` package to create a dataframe with results\nset.seed(123)\n(df \u003c-\n  pairwise_comparisons(mtcars, cyl, wt) %\u003e%\n  dplyr::mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) %\u003e%\n  dplyr::arrange(group1))\n\n# using `geom_signif` to display results\n# (note that you can choose not to display all comparisons)\np +\n  ggsignif::geom_signif(\n    comparisons = list(df$groups[[1]]),\n    annotations = df$label[[1]],\n    test = NULL,\n    na.rm = TRUE,\n    parse = TRUE\n  )\n```\n\n## Example-2: within-subjects\n\n```{r ggsignif2}\n# needed libraries\nlibrary(ggplot2)\nlibrary(pairwiseComparisons)\nlibrary(ggsignif)\n\n# creating a basic plot\np \u003c- ggplot(WRS2::WineTasting, aes(Wine, Taste)) +\n  geom_boxplot()\n\n# using `{pairwiseComparisons}` package to create a dataframe with results\nset.seed(123)\n(df \u003c-\n  pairwise_comparisons(\n    WRS2::WineTasting,\n    Wine,\n    Taste,\n    subject.id = Taster,\n    type = \"bayes\",\n    paired = TRUE\n  ) %\u003e%\n  dplyr::mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) %\u003e%\n  dplyr::arrange(group1))\n\n# using `geom_signif` to display results\np +\n  ggsignif::geom_signif(\n    comparisons = df$groups,\n    map_signif_level = TRUE,\n    tip_length = 0.01,\n    y_position = c(6.5, 6.65, 6.8),\n    annotations = df$label,\n    test = NULL,\n    na.rm = TRUE,\n    parse = TRUE\n  )\n```\n\n# Acknowledgments\n\nThe hexsticker was generously designed by Sarah Otterstetter (Max Planck\nInstitute for Human Development, Berlin). \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIndrajeetPatil%2FpairwiseComparisons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIndrajeetPatil%2FpairwiseComparisons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIndrajeetPatil%2FpairwiseComparisons/lists"}