Code Monkey home page Code Monkey logo

pairwisecomparisons's Introduction

About Me

LinkedIn

I am a software developer with a passion for data science and full-stack web development. With several years of experience in building data-driven products, I have acquired a deep understanding of how to create robust and scalable software solutions that solve business problems. I have a proven track record of delivering high-quality, user-friendly software solutions to real-world problems; my open-source software packages have been downloaded over 30 million times. Additionally, I have 10+ years of experience in using data science tools to draw insights from complex experimental datasets. My skills include statistical modelling, experimental design, data analysis, visualization, and communication. I have 20+ peer-reviewed publications with 5000+ citations and 2 online books.

Software development

I have authored over a dozen R packages that deal with:

  • statistical analysis and reporting (e.g. easystats project, a collection of 10 packages)
  • data visualization (e.g. ggstatsplot: Enhancing {ggplot2} plots with statistical analysis)
  • code analysis (e.g. lintr: Static code analysis for R)

Other authored packages include:

datawizard, performance, parameters, insight, effectsize, bayestestR, modelbased, ggsignif, see, statsExpressions, report, correlation, styler, ospsuite, ospsuite.utils, esqlabsR

Presentations

If you are interested in good programming and software development practices, check out my slide decks.

pairwisecomparisons's People

Contributors

indrajeetpatil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pairwisecomparisons's Issues

Feature suggestion for Bayesian muliple comparisons

Hi Indrajeet,

Was working on multiple comparisons for bayes analysis see https://ibecav.netlify.com/post/pairwise-bayesian-comparisons-even-faster/ when it struck me that a nice future feature for ggstatsplot::ggbetweenstats might be to display BF10 similar to the way you do p values for parametric.

I hacked at your code a little bit signif_column and pairwise_p and the reprex kind of shows what's possible...

library(tidyverse)
library(ggstatsplot)
#> Registered S3 methods overwritten by 'broom.mixed':
#>   method         from 
#>   augment.lme    broom
#>   augment.merMod broom
#>   glance.lme     broom
#>   glance.merMod  broom
#>   glance.stanreg broom
#>   tidy.brmsfit   broom
#>   tidy.gamlss    broom
#>   tidy.lme       broom
#>   tidy.merMod    broom
#>   tidy.rjags     broom
#>   tidy.stanfit   broom
#>   tidy.stanreg   broom
#> Registered S3 methods overwritten by 'lme4':
#>   method                          from
#>   cooks.distance.influence.merMod car 
#>   influence.merMod                car 
#>   dfbeta.influence.merMod         car 
#>   dfbetas.influence.merMod        car
library(BayesFactor)
#> Loading required package: coda
#> Loading required package: Matrix
#> 
#> Attaching package: 'Matrix'
#> The following object is masked from 'package:tidyr':
#> 
#>     expand
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey ([email protected]).
#> 
#> Type BFManual() to open the manual.
#> ************
# function body
xpairwise_p <- function(data,
                       x,
                       y,
                       type = "parametric",
                       tr = 0.1,
                       paired = FALSE,
                       var.equal = FALSE,
                       p.adjust.method = "holm",
                       k = 2,
                       messages = TRUE,
                       ...) {
  ellipsis::check_dots_used()

  # ---------------------------- data cleanup -------------------------------
  # creating a dataframe
  data <-
    dplyr::select(
      .data = data,
      x = !!rlang::enquo(x),
      y = !!rlang::enquo(y)
    ) %>%
    dplyr::mutate(.data = ., x = droplevels(as.factor(x))) %>%
    tibble::as_tibble(x = .)
# return(data)
  # ---------------------------- parametric ---------------------------------
  
  if (type %in% c("parametric", "p")) {
    if (isTRUE(var.equal) || isTRUE(paired)) {
      # anova model
      aovmodel <- stats::aov(formula = y ~ x, data = data)
      
      # safeguarding against edge cases
      aovmodel$model %<>%
        dplyr::mutate(
          .data = .,
          x = forcats::fct_relabel(
            .f = x,
            .fun = ~ stringr::str_replace(
              string = .x,
              pattern = "-",
              replacement = "_"
            )
          )
        )
      
      # extracting and cleaning up Tukey's HSD output
      df_tukey <- stats::TukeyHSD(x = aovmodel, conf.level = 0.95) %>%
        broomExtra::tidy(x = .) %>%
        dplyr::select(.data = ., comparison, estimate) %>%
        tidyr::separate(
          data = .,
          col = comparison,
          into = c("group1", "group2"),
          sep = "-"
        ) %>%
        dplyr::rename(.data = ., mean.difference = estimate) %>%
        dplyr::mutate_at(
          .tbl = .,
          .vars = dplyr::vars(dplyr::matches("^group[0-9]$")),
          .funs = ~ stringr::str_replace(
            string = .,
            pattern = "_",
            replacement = "-"
          )
        )
      
      # tidy dataframe with results from pairwise tests
      df_tidy <- broomExtra::tidy(
        stats::pairwise.t.test(
          x = data$y,
          g = data$x,
          p.adjust.method = p.adjust.method,
          paired = paired,
          alternative = "two.sided",
          na.action = na.omit
        )
      ) %>%
        signif_column(data = ., p = p.value)
      
      # combining mean difference and results from pairwise t-test
      df <-
        dplyr::full_join(
          x = df_tukey,
          y = df_tidy,
          by = c("group1", "group2")
        ) %>% # the group columns need to be swapped to be consistent
        dplyr::rename(.data = ., group2 = group1, group1 = group2) %>%
        dplyr::select(.data = ., group1, group2, dplyr::everything())
      
      # display message about the post hoc tests run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The parametric pairwise multiple comparisons test used-\n",
            "Student's t-test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    } else {
      
      # dataframe with Games-Howell test results
      df <-
        games_howell(data = data, x = x, y = y) %>%
        p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method) %>%
        dplyr::select(.data = ., -conf.low, -conf.high)
      
      # display message about the post hoc tests run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The parametric pairwise multiple comparisons test used-\n",
            "Games-Howell test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    }
  }
  
  # ---------------------------- nonparametric ----------------------------

  if (type %in% c("nonparametric", "np")) {
    if (!isTRUE(paired)) {
      # running Dwass-Steel-Crichtlow-Fligner test using `jmv` package
      jmv_pairs <-
        jmv::anovaNP(
          data = data,
          deps = "y",
          group = "x",
          pairs = TRUE
        )

      # extracting the pairwise tests and formatting the output
      df <-
        as.data.frame(x = jmv_pairs$comparisons[[1]]) %>%
        tibble::as_tibble(x = .) %>%
        dplyr::rename(
          .data = .,
          group1 = p1,
          group2 = p2,
          p.value = p
        ) %>%
        ggstatsplot:::p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method)

      # letting the user know which test was run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The nonparametric pairwise multiple comparisons test used-\n",
            "Dwass-Steel-Crichtlow-Fligner test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    } else {
      # converting the entered long format data to wide format
      data_wide <- long_to_wide_converter(
        data = data,
        x = x,
        y = y
      )

      # running Durbin-Conover test using `jmv` package
      jmv_pairs <-
        jmv::anovaRMNP(
          data = data_wide,
          measures = names(data_wide[, -1]),
          pairs = TRUE
        )

      # extracting the pairwise tests and formatting the output
      df <-
        as.data.frame(x = jmv_pairs$comp) %>%
        tibble::as_tibble(x = .) %>%
        dplyr::select(.data = ., -sep) %>%
        dplyr::rename(
          .data = .,
          group1 = i1,
          group2 = i2,
          statistic = stat,
          p.value = p
        ) %>%
        ggstatsplot:::p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method)

      # letting the user know which test was run
      if (isTRUE(messages)) {
        message(cat(
          crayon::green("Note: "),
          crayon::blue(
            "The nonparametric pairwise multiple comparisons test used-\n",
            "Durbin-Conover test.\n",
            "Adjustment method for p-values: "
          ),
          crayon::yellow(p.adjust.method),
          sep = ""
        ))
      }
    }
  }

  # ---------------------------- robust ----------------------------------

  if (type %in% c("robust", "r")) {
    if (!isTRUE(paired)) {
      # object with all details about pairwise comparisons
      rob_pairwise_df <-
        WRS2::lincon(
          formula = y ~ x,
          data = data,
          tr = tr
        )
    } else {
      # converting to long format and then getting it back in wide so that the
      # rowid variable can be used as the block variable for WRS2 functions
      data_within <-
        long_to_wide_converter(
          data = data,
          x = x,
          y = y
        ) %>%
        tidyr::gather(data = ., key, value, -rowid) %>%
        dplyr::arrange(.data = ., rowid)

      # running pairwise multiple comparison tests
      rob_pairwise_df <-
        with(
          data = data_within,
          expr = WRS2::rmmcp(
            y = value,
            groups = key,
            blocks = rowid,
            tr = tr
          )
        )
    }

    # extracting the robust pairwise comparisons and tidying up names
    rob_df_tidy <-
      suppressMessages(tibble::as_tibble(
        x = rob_pairwise_df$comp,
        .name_repair = "unique"
      )) %>%
      dplyr::rename(
        .data = .,
        group1 = Group...1,
        group2 = Group...2
      )

    # cleaning the raw object and getting it in the right format
    df <-
      dplyr::full_join(
        # dataframe comparing comparison details
        x = rob_df_tidy %>%
          ggstatsplot:::p_adjust_column_adder(df = ., p.adjust.method = p.adjust.method) %>%
          tidyr::gather(
            data = .,
            key = "key",
            value = "rowid",
            group1:group2
          ),
        # dataframe with factor level codings
        y = rob_pairwise_df$fnames %>%
          tibble::enframe(x = ., name = "rowid"),
        by = "rowid"
      ) %>%
      dplyr::select(.data = ., -rowid) %>%
      tidyr::spread(data = ., key = "key", value = "value") %>%
      dplyr::select(.data = ., group1, group2, dplyr::everything())

    # for paired designs, there will be an unnecessary column to remove
    if (("p.crit") %in% names(df)) {
      df %<>% dplyr::select(.data = ., -p.crit)
    }

    # renaming confidence interval names
    df %<>% dplyr::rename(.data = ., conf.low = ci.lower, conf.high = ci.upper)

    # message about which test was run
    if (isTRUE(messages)) {
      message(cat(
        crayon::green("Note: "),
        crayon::blue(
          "The robust pairwise multiple comparisons test used-\n",
          "Yuen's trimmed means comparisons test.\n",
          "Adjustment method for p-values: "
        ),
        crayon::yellow(p.adjust.method),
        sep = ""
      ))
    }
  }

  # ---------------------------- bayes factor --------------------------------

  # print a message telling the user that this is currently not supported
  if (type %in% c("bf", "bayes")) {
    # anova model
    aovmodel <- stats::aov(formula = y ~ x, data = data)
    
    # safeguarding against edge cases
    aovmodel$model %<>%
      dplyr::mutate(
        .data = .,
        x = forcats::fct_relabel(
          .f = x,
          .fun = ~ stringr::str_replace(
            string = .x,
            pattern = "-",
            replacement = "_"
          )
        )
      )
    
    # extracting and cleaning up Tukey's HSD output
    df_tukey <- stats::TukeyHSD(x = aovmodel, conf.level = 0.95) %>%
      broomExtra::tidy(x = .) %>%
      dplyr::select(.data = ., comparison, estimate) %>%
      tidyr::separate(
        data = .,
        col = comparison,
        into = c("group1", "group2"),
        sep = "-"
      ) %>%
      dplyr::rename(.data = ., mean.difference = estimate) %>%
      dplyr::mutate_at(
        .tbl = .,
        .vars = dplyr::vars(dplyr::matches("^group[0-9]$")),
        .funs = ~ stringr::str_replace(
          string = .,
          pattern = "_",
          replacement = "-"
        )
      )
    # return(df_tukey)
    
    # combining mean difference and results from pairwise t-test
    df <- df_tukey %>% # the group columns need to be swapped to be consistent
      dplyr::rename(.data = ., group2 = group1, group1 = group2) %>%
      dplyr::select(.data = ., group1, group2, dplyr::everything())
    
    g1_list <- df_tukey %>% pull(group2) %>% as.character()
    g2_list <- df_tukey %>% pull(group1) %>% as.character()
    
    # return(g1_list)
    
    bfresults <- map2(
      g1_list,
      g2_list,
      function(a, b)
        data %>%
        filter(!is.na(x)) %>%
        filter(!is.na(y)) %>%
        filter(x %in% c(a, b)) %>%
        droplevels() %>%
        as.data.frame()
    ) %>%
      map(.x = ., ~ ttestBF(
        formula = y ~ x,
        data = .
      )) %>%
      map(.x = ., ~ extractBF(x = .)) %>%
      map_dbl(.x = ., ~ .[, "bf"]) 
    # return(bfresults)
    
    df$bfactor <- bfresults
    
    # display message about the post hoc tests run
    if (isTRUE(messages)) {
      message(cat(
        crayon::green("Note: "),
        crayon::blue(
          "The pairwise multiple comparisons test used - \n",
          "BayesFactor::ttestBF.\n"
        ),
        sep = ""
      ))
    }
  } # bayes


  # ---------------------------- cleanup ----------------------------------

  # if there are factors, covert them to character to make life easy
  df %<>%
    dplyr::mutate_if(
      .tbl = .,
      .predicate = is.factor,
      .funs = ~ as.character(.)
    ) 
#  return(df)
  if (type %in% c("parametric", "nonparametric", "robust", "p", "np", "r")) {
  df %<>%
    purrrlyr::by_row(
      .d = .,
      ..f = ~ specify_decimal_p(
        x = .$p.value,
        k = k,
        p.value = TRUE
      ),
      .collate = "rows",
      .to = "label",
      .labels = TRUE
    ) %>%
    dplyr::mutate(
      .data = .,
      p.value.label = dplyr::case_when(
        label == "< 0.001" ~ "p <= 0.001",
        TRUE ~ paste("p = ", label, sep = "")
      )
    ) %>%
    dplyr::select(.data = ., -label)
  }
  # return
  return(tibble::as_tibble(df))
}


bf_column <- function(data = NULL, bf) {
  
  # if dataframe is provided
  if (!is.null(data)) {
    
    # storing variable name to be assigned later
    p_lab <- colnames(dplyr::select(
      .data = data,
      !!rlang::enquo(bf)
    ))
    
    # preparing dataframe
    df <-
      dplyr::select(
        .data = data,
        # column corresponding to bf-values
        bf = !!rlang::enquo(bf),
        dplyr::everything()
      )
  } else {
    
    # if only vector is provided
    df <-
      base::cbind.data.frame(bf = bf)
  }
  
  # make sure the bf-value column is numeric; if not, convert it to numeric
  if (!is.numeric(df$bf)) {
    
    # display message about conversion
    base::message(cat(
      crayon::green("Note:"),
      crayon::blue(
        "The entered vector is of class",
        crayon::yellow(class(df$bf)[[1]]),
        "; attempting to convert it to numeric."
      )
    ))
    
    # conversion
    df$bf <- as.numeric(as.character(df$bf))
  }
  
  # add new support column based on 
  # Wagenmakers, Wetzels, Borsboom, & Van Der Maas, 2011 
  df %<>%
    dplyr::mutate(
      .data = .,
      support = dplyr::case_when(
        # first condition
        bf < .01 ~ "extreme BF01",
        bf < .03 & bf >= .01 ~ "very strong BF01",
        bf < .1 & bf >= .03 ~ "strong BF01",
        bf < 1/3 & bf >= .1 ~ "moderate BF01",
        bf < 1 & bf >= 1/3 ~ "anectdotal BF01",
        bf >= 1 & bf < 3 ~ "anectdotal BF10",
        bf >= 3 & bf < 10 ~ "moderate BF10",
        bf >= 10 & bf < 30 ~ "strong BF10",
        bf >= 30 & bf < 100 ~ "very strong BF10",
        bf >= 100  ~ "extreme BF10",
        # fourth condition
        bf < 0.001 ~ "***"
      )
    ) %>%
    tibble::as_data_frame(x = .) # convert to tibble dataframe
  
  # change back from the generic bf-value to the original name that was provided by the user for the bf-value
  if (!is.null(data)) {
    
    # reordering the dataframe
    df %<>%
      dplyr::select(.data = ., -bf, -support, dplyr::everything())
    
    # renaming the bf-value variable with the name provided by the user
    colnames(df)[which(names(df) == "bf")] <- p_lab
  }
  
  # return the final tibble dataframe
  return(df)
}

testme <- xpairwise_p(data = ggplot2::msleep,
x = vore,
y = brainwt, 
type = "bf")
#> Note: The pairwise multiple comparisons test used - 
#>  BayesFactor::ttestBF.
#> 

bf_column(testme, bfactor)
#> Warning: `as_data_frame()` is deprecated, use `as_tibble()` (but mind the new semantics).
#> This warning is displayed once per session.
#> # A tibble: 6 x 5
#>   group1  group2  mean.difference bfactor support        
#>   <chr>   <chr>             <dbl>   <dbl> <chr>          
#> 1 carni   herbi            0.542    0.540 anectdotal BF01
#> 2 carni   insecti         -0.0577   0.718 anectdotal BF01
#> 3 carni   omni             0.0665   0.427 anectdotal BF01
#> 4 herbi   insecti         -0.600    0.540 anectdotal BF01
#> 5 herbi   omni            -0.476    0.571 anectdotal BF01
#> 6 insecti omni             0.124    0.545 anectdotal BF01

Created on 2019-07-11 by the reprex package (v0.3.0)

Package stuck solving

Having many issues trying to install. Tried with a fresh conda environment and it's been stuck on "solving" overnight.

image

Do you have a list of packages to install, in a specific order, to get this following code to work?

# for reproducibility
set.seed(123)
library(ggstatsplot)

# plot
ggbetweenstats(
  data = iris,
  x = Species,
  y = Sepal.Length,
  title = "Distribution of sepal length across Iris species"
)

feature request for `PMCMRplus`

# setup
set.seed(123)
library(tidyverse)
library(PMCMRplus)

# custom function
PMCMR_to_tidy <- function(mod, ...) {
  # custom function to convert from a matrix to a tidy dataframe
  matrix_to_tidy <- function(m, col_name = "value") {
    result <-
      data.frame(
        group1 = rep(rownames(m), each = ncol(m)),
        group2 = rep(colnames(m), times = nrow(m)),
        col3 = as.numeric(base::t(m)),
        stringsAsFactors = FALSE
      )

    names(result)[3] <- col_name
    stats::na.omit(result)
  }

  # combine all components of the object in a single dataframe
  tibble::as_tibble(dplyr::bind_cols(
    dplyr::full_join(
      matrix_to_tidy(mod$statistic, col_name = "statistic"),
      matrix_to_tidy(mod$p.value, col_name = "p.value"),
      by = c("group1", "group2")
    ),
    purrr::flatten_dfr(list(mod$parameter)),
    tibble::tibble(method = mod$method),
    tibble::tibble(distribution = mod$dist),
    tibble::tibble(p.adjust.method = mod$p.adjust.method)
  ))
}

# example PMCMRplus object
ans <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays, p.adjust.method = "single-step")
#> Warning in kwAllPairsConoverTest.default(c(10, 7, 20, 14, 14, 12, 10, 23, : Ties
#> are present. Quantiles were corrected for ties.

# using the function
PMCMR_to_tidy(ans)
#> # A tibble: 15 x 9
#>    group1 group2 statistic  p.value nmeans    df method distribution
#>    <chr>  <chr>      <dbl>    <dbl>  <int> <int> <chr>  <chr>       
#>  1 B      A          0.890 9.88e- 1      6    66 Conov~ q           
#>  2 C      A        -13.6   0.            6    66 Conov~ q           
#>  3 C      B        -14.5   0.            6    66 Conov~ q           
#>  4 D      A         -8.87  4.61e- 7      6    66 Conov~ q           
#>  5 D      B         -9.76  3.61e- 8      6    66 Conov~ q           
#>  6 D      C          4.71  1.70e- 2      6    66 Conov~ q           
#>  7 E      A        -11.0   1.12e- 9      6    66 Conov~ q           
#>  8 E      B        -11.8   7.57e-11      6    66 Conov~ q           
#>  9 E      C          2.63  4.37e- 1      6    66 Conov~ q           
#> 10 E      D         -2.09  6.81e- 1      6    66 Conov~ q           
#> 11 F      A          1.15  9.64e- 1      6    66 Conov~ q           
#> 12 F      B          0.264 1.00e+ 0      6    66 Conov~ q           
#> 13 F      C         14.7   0.            6    66 Conov~ q           
#> 14 F      D         10.0   1.68e- 8      6    66 Conov~ q           
#> 15 F      E         12.1   3.05e-11      6    66 Conov~ q           
#> # ... with 1 more variable: p.adjust.method <chr>

Created on 2020-10-14 by the reprex package (v0.3.0.9001)

WRS2 feature request: retaining group level names in the `comp` object itself

Pairwise comparison objects from WRS2 contain the comparisons in comp object but the group level names are removed and replaced with numeric values, while the names are contained in fnames. The correspondence between numeric values and group levels is unclear and in edge cases (dropped factor levels, reordered factor levels) can be tricky.

setup

    library(WRS2)
    library(magrittr)
    require(reshape)
    #> Loading required package: reshape

    bushLong <- 
      melt(bush, id.var = "participant", variable_name = "food") %>%
      dplyr::arrange(participant)

within-subjects

    x_w <- rmmcp(bushLong$value, bushLong$food, bushLong$participant)

    x_w$comp
    #>      Group Group    psihat    ci.lower  ci.upper    p.value  p.crit
    #> [1,]     1     2  3.666667  -0.4830017  7.816335 0.01359625 0.01020
    #> [2,]     1     3  4.000000  -0.3572784  8.357278 0.01172054 0.00851
    #> [3,]     1     4  2.000000  -8.0992023 12.099202 0.44148206 0.01690
    #> [4,]     2     3  0.000000  -5.3880170  5.388017 1.00000000 0.05000
    #> [5,]     2     4 -1.833333  -9.2326553  5.565989 0.34371248 0.01270
    #> [6,]     3     4 -2.000000 -12.5482728  8.548273 0.46001407 0.02500
    
    x_w$fnames
    #> [1] "stick_insect"      "kangaroo_testicle" "fish_eye"         
    #> [4] "witchetty_grub"

between-subjects

    x_b <- lincon(libido ~ dose, data = viagra)

    x_b$comp
    #>      Group Group psihat ci.lower ci.upper   p.value
    #> [1,]     1     2     -1 -5.31858  3.31858 0.4353309
    #> [2,]     1     3     -3 -7.31858  1.31858 0.1805095
    #> [3,]     2     3     -2 -6.31858  2.31858 0.3166048

    x_b$fnames
    #> [1] "placebo" "low"     "high"

Created on 2020-09-28 by the reprex package (v0.3.0.9001)

feature request for `WRS2`: allow to adjust confidence intervals plus consistent output

  • allow users to change the confidence intervals for estimate of group difference
  • have a consistent output for both designs
    (e.g., columns p.crit and sig are only present in within-subjects output)

between-subjects design

WRS2::lincon(libido ~ dose, data = viagra)
#> Call:
#> lincon(formula = libido ~ dose, data = viagra)
#> 
#>                  psihat ci.lower ci.upper p.value
#> placebo vs. low      -1 -5.31858  3.31858 0.43533
#> placebo vs. high     -3 -7.31858  1.31858 0.18051
#> low vs. high         -2 -6.31858  2.31858 0.31660

within-subjects design

WRS2::rmmcp(WineTasting$Taste, WineTasting$Wine, WineTasting$Taster)
#> Call:
#> rmmcp(y = WineTasting$Taste, groups = WineTasting$Wine, blocks = WineTasting$Taster)
#> 
#>                    psihat ci.lower ci.upper p.value p.crit   sig
#> Wine A vs. Wine B 0.02143 -0.02164  0.06449 0.19500 0.0500 FALSE
#> Wine A vs. Wine C 0.11429  0.02148  0.20710 0.00492 0.0169  TRUE
#> Wine B vs. Wine C 0.08214  0.00891  0.15538 0.00878 0.0250  TRUE

Error: package or namespace load failed for ‘pairwiseComparisons’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘rstan’

Hi,

I'm trying to instal the library pairwiseComparisons but I keep getting the same error. I'm running RStudio 1.3.1056 for R 4.02 on a macOS Catalina 10.15.6. Haven't had any problem with other libraries, so I wonder if you have a quickfix.

library(pairwiseComparisons)
Registered S3 method overwritten by 'broom.mixed':
method from
tidy.gamlss broom
Error: package or namespace load failed for ‘pairwiseComparisons’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘rstan’

Tried to install lib.loc or .libPaths but I get the following mistake.

install.packages("lib.loc")
Warning in install.packages :
package ‘lib.loc’ is not available (for R version 4.0.2)

This (https://indrajeetpatil.github.io/pairwiseComparisons/) did not help either.

move `pairwise_caption` here from `ggstatsplot`

#' @name pairwise_caption
#' @noRd

pairwise_caption <- function(caption, test.description, p.adjust.method) {
  substitute(
    atop(
      displaystyle(top.text),
      expr = paste(
        "Pairwise comparisons: ",
        bold(test.description),
        "; Adjustment (p-value): ",
        bold(p.adjust.method.text)
      )
    ),
    env = list(
      top.text = caption,
      test.description = test.description,
      p.adjust.method.text = p_adjust_text(p.adjust.method)
    )
  )
}

use `statsExpressions` for Bayesian test?

Doesn't really add that many new dependencies, since ipmisc anyways relies on tidyr.

setdiff(
  tools::package_dependencies("statsExpressions")$statsExpressions,
  tools::package_dependencies("pairwiseComparisons")$pairwiseComparisons
)
#> [1] "correlation" "effectsize"  "performance" "tidyr"

Created on 2021-06-08 by the reprex package (v2.0.0)

brain dump

  • add support for PMCMR objects in parameters
  • check which tests work with NAs and which not (why is long_to_wide needed here?)
  • use rlang::exec when non-parametric
  • have separate if statements for parametric and bayes; don't put them together
  • see if PMCMRplus might be willing to support pairwise t tests as well
  • don't support quoted arguments any more
  • once easystats API is stabilized, have strict tests for the entire dataframes
  • change default trimming to 0.2
  • move PMCMRplus from Imports to Suggests
  • simplify installation instructions

TO DO for 3.0.0

  • remove internal Games-Howell test (use PMCMRplus)
  • remove reliance on Dunn test (use PMCMRplus)
  • uniform output for everything but Bayes
  • remove dependence from tidyBF to make the package lighter
  • remove dependence from broomExtra to make the package lighter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.