T-test() 不添加调整后的 p 值
T-test() does not add adjusted p-values
我在学期开始和结束时(预和 post)在 3 个不同的 类(数学、物理、生物)中进行了一项调查。在调查中,有 3 组问题(A、B、C)和李克特量表。我把所有的答案都转换成了数值分数
我想测试每门课程的每种问题类型是否存在学期前调查和 post 学期调查之间的分数差异。我还想在此处添加 Bonferroni 校正以说明多重比较:
library(rstatix)
library(tidyr)
df= data.frame(
survey = rep(c("pre","post"),60),
subject = rep(c("bio", "math", "phys"),40),
q = rep(c("A", "B", "C"),40),
score = sample(x=1:7, size = 120, replace = TRUE))
df
df %>% group_by(subject, q) %>%
t_test(score ~ survey, paired = TRUE, p.adjust.method = "bonferroni") %>%
add_significance()
但是,p.adjust.method = "bonferroni"
不会产生任何输出。我不知道为什么。
我们可以使用adjust_pvalue
library(dplyr)
library(rstatix)
df %>%
group_by(subject, q) %>%
t_test(score ~ survey, paired = TRUE) %>%
adjust_pvalue(method = 'bonferroni') %>%
add_significance()
-输出
# A tibble: 3 x 12
# subject q .y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
#* <chr> <chr> <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <chr>
#1 bio A score post pre 20 20 1.52 19 0.145 0.435 ns
#2 math B score post pre 20 20 -0.543 19 0.594 1 ns
#3 phys C score post pre 20 20 1.24 19 0.232 0.696 ns
我在学期开始和结束时(预和 post)在 3 个不同的 类(数学、物理、生物)中进行了一项调查。在调查中,有 3 组问题(A、B、C)和李克特量表。我把所有的答案都转换成了数值分数
我想测试每门课程的每种问题类型是否存在学期前调查和 post 学期调查之间的分数差异。我还想在此处添加 Bonferroni 校正以说明多重比较:
library(rstatix)
library(tidyr)
df= data.frame(
survey = rep(c("pre","post"),60),
subject = rep(c("bio", "math", "phys"),40),
q = rep(c("A", "B", "C"),40),
score = sample(x=1:7, size = 120, replace = TRUE))
df
df %>% group_by(subject, q) %>%
t_test(score ~ survey, paired = TRUE, p.adjust.method = "bonferroni") %>%
add_significance()
但是,p.adjust.method = "bonferroni"
不会产生任何输出。我不知道为什么。
我们可以使用adjust_pvalue
library(dplyr)
library(rstatix)
df %>%
group_by(subject, q) %>%
t_test(score ~ survey, paired = TRUE) %>%
adjust_pvalue(method = 'bonferroni') %>%
add_significance()
-输出
# A tibble: 3 x 12
# subject q .y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
#* <chr> <chr> <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <chr>
#1 bio A score post pre 20 20 1.52 19 0.145 0.435 ns
#2 math B score post pre 20 20 -0.543 19 0.594 1 ns
#3 phys C score post pre 20 20 1.24 19 0.232 0.696 ns