Skip to content

pairwise_t_test and t_test does not return the same unadjusted p-values when doing many-to-one comparisons. #215

@Zhenglei-BCS

Description

@Zhenglei-BCS

I compared the output from t_test and pairwise_t_test with the input argument specifying the reference group:
The output from the two are as below, the code to reproduce the table is included. I checked t.test output, and the t_test output is the same as t.test. I am not sure why the unadjusted p-value could be different from these two tests. I might have an incorrect understanding of pairwise_t_test.

On the other hand, the wilcox_test and pairwise_wilcox_test produce the same outcome.

t_test pairwise_t_test
7.05e-01 7.65e-01
6.38e-01 7.65e-01
4.00e-03 1.52e-03
5.38e-04 7.00e-07
5.58e-04 0.00e+00
3.60e-06 0.00e+00
# Create a simulated toxicity test dataset
set.seed(456)
toxicity_data <- data.frame(
  concentration = rep(c(0, 0.1, 1, 5, 10, 50, 100), each = 4),
  survival = c(
    rbinom(4, 20, 0.95),  # Control: ~95% survival
    rbinom(4, 20, 0.93),  # 0.1 mg/L: ~93% survival
    rbinom(4, 20, 0.90),  # 1 mg/L: ~90% survival
    rbinom(4, 20, 0.85),  # 5 mg/L: ~85% survival
    rbinom(4, 20, 0.70),  # 10 mg/L: ~70% survival
    rbinom(4, 20, 0.40),  # 50 mg/L: ~40% survival
    rbinom(4, 20, 0.15)   # 100 mg/L: ~15% survival
  )
)

# Calculate survival percentage
toxicity_data <- toxicity_data %>%
  mutate(
    total = 20,  # Assuming 20 organisms per replicate
    survival_pct = (survival / total) * 100,
    concentration = factor(concentration)
  )
res1 <- toxicity_data %>% t_test(survival_pct ~ concentration, ref.group = "0")
res1.0 <- toxicity_data %>% pairwise_t_test(survival_pct ~ concentration, ref.group = "0")
## strangely, res1.0 and res1 give different results
knitr::kable(data.frame(t_test=res1$p,pairwise_t_test=res1.0$p),format = "markdown")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions