为什么不同组之间的 p 值总是相同,有人知道我做错了什么吗?
Why is p-value always the same between different group, Someone know what I am doing of wrong?
大家好我正在比较不同分布的权重。我的数据是这样格式化的:
Weight_G1 Gaussian_One
0.714484 Non_Treated
0.6992871 Non_Treated
0.7144726 Non_Treated
0.7062965 Non_Treated
0.7331027 Non_Treated
0.6927765 Non_Treated
0.5939587 Treated1
0.6230649 Treated1
0.5935826 Treated1
0.59120414 Treated1
0.6069062 Treated1
0.6024558 Treated1
0.6285782 Treated2
0.6328368 Treated2
0.6339552 Treated2
0.6193341 Treated2
0.6412954 Treated2
0.6160553 Treated2
我正在使用以下代码:
My_table <- structure(list(Weight_G1 = c(30.71604, 30.29721, 30.71587,
30.91229, 30.77887, 30.54265, 28.38478, 28.84662, 28.32799,
28.25268, 28.42514, 28.51167, 29.28263, 29.40063, 29.28390,
29.27207, 29.34798, 29.08956), Gaussian_One = c("Non_Treated",
"Non_Treated", "Non_Treated", "Non_Treated", "Non_Treated", "Non_Treated",
"Treated1", "Treated1", "Treated1", "Treated1", "Treated1", "Treated1",
"Treated2", "Treated2", "Treated2", "Treated2", "Treated2", "Treated2"
)), row.names = c(NA, -18L), class = c("tbl_df", "tbl", "data.frame"
))
library(ggpubr)
my_comparisons <- list( c("Non_Treated", "Treated1"), c("Non_Treated", "Treated2"), c("Treated1", "Treated2"))
Mean1 <- ggboxplot(My_table, x = "Gaussian_One", y = "Weight_G1",lwd=1,
color = "Gaussian_One", palette = "jco")+
stat_compare_means(label = "p",comparisons = my_comparisons) # Add pairwise comparisons p-value
Mean1<- Mean1+theme_pubr(base_size = 20)
Mean1
p 值似乎总是相同的 0.22,我做错了什么?
我认为没有任何问题,所以这不一定是您问题的答案。我只想反驳另一个问题:你到底想做什么?
您创建了一个包含 p 值的漂亮绘图。虽然放入 paper/report 很好,但这不是我通常执行 'actual' 分析的方式。因此,我要问你的第一个问题是,你想做什么类型的 analysis/comparision?你不提那个,你只是说你认为你的结果很奇怪。但是您要分析的内容对于您使用 stat_compare_means
.
所做的事情非常重要
我认为这个例子没有意义,但我可以很容易地重现它,所以不要将它用于你自己的分析(它只是一个例子)。所以说,你想做一个配对 t 检验。分析看起来像:
t1 <- df %>% filter(Gaussian_One == "Non_Treated") %>% pull(Weight_G1)
t2 <- df %>% filter(Gaussian_One == "Treated1") %>% pull(Weight_G1)
t3 <- df %>% filter(Gaussian_One == "Treated2") %>% pull(Weight_G1)
t.test(t1, t2, paired = TRUE)
t.test(t1, t3, paired = TRUE)
t.test(t2, t3, paired = TRUE)
分别导致
data: t1 and t2
t = 13.166, df = 5, p-value = 4.515e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.08708014 0.12933555
sample estimates:
mean of the differences
0.1082078
data: t1 and t3
t = 22.133, df = 5, p-value = 3.497e-06
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.07194078 0.09084735
sample estimates:
mean of the differences
0.08139407
Paired t-test
data: t2 and t3
t = -5.2963, df = 5, p-value = 0.003202
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.03982790 -0.01379965
sample estimates:
mean of the differences
-0.02681378
如果我们想在你的图表中绘制它,你会这样做:
ggboxplot(df, x = "Gaussian_One", y = "Weight_G1",lwd=1,
color = "Gaussian_One", palette = "jco")+
stat_compare_means(method = "t.test", paired = TRUE,
label = "p",comparisons = my_comparisons)
该图现在包含我也从配对 t 检验中获得的 p 值。
在您的示例中,您没有指定 comparing/calculating p 值的方法。我在文档中找不到默认使用的内容,但这可能解释了您的 'weird' 结果。因此,如果您返回绘图 table 并决定您实际想要查看的分析并将其添加到 stat_compare_means
,您的结果将更有意义。
大家好我正在比较不同分布的权重。我的数据是这样格式化的:
Weight_G1 Gaussian_One
0.714484 Non_Treated
0.6992871 Non_Treated
0.7144726 Non_Treated
0.7062965 Non_Treated
0.7331027 Non_Treated
0.6927765 Non_Treated
0.5939587 Treated1
0.6230649 Treated1
0.5935826 Treated1
0.59120414 Treated1
0.6069062 Treated1
0.6024558 Treated1
0.6285782 Treated2
0.6328368 Treated2
0.6339552 Treated2
0.6193341 Treated2
0.6412954 Treated2
0.6160553 Treated2
我正在使用以下代码:
My_table <- structure(list(Weight_G1 = c(30.71604, 30.29721, 30.71587,
30.91229, 30.77887, 30.54265, 28.38478, 28.84662, 28.32799,
28.25268, 28.42514, 28.51167, 29.28263, 29.40063, 29.28390,
29.27207, 29.34798, 29.08956), Gaussian_One = c("Non_Treated",
"Non_Treated", "Non_Treated", "Non_Treated", "Non_Treated", "Non_Treated",
"Treated1", "Treated1", "Treated1", "Treated1", "Treated1", "Treated1",
"Treated2", "Treated2", "Treated2", "Treated2", "Treated2", "Treated2"
)), row.names = c(NA, -18L), class = c("tbl_df", "tbl", "data.frame"
))
library(ggpubr)
my_comparisons <- list( c("Non_Treated", "Treated1"), c("Non_Treated", "Treated2"), c("Treated1", "Treated2"))
Mean1 <- ggboxplot(My_table, x = "Gaussian_One", y = "Weight_G1",lwd=1,
color = "Gaussian_One", palette = "jco")+
stat_compare_means(label = "p",comparisons = my_comparisons) # Add pairwise comparisons p-value
Mean1<- Mean1+theme_pubr(base_size = 20)
Mean1
p 值似乎总是相同的 0.22,我做错了什么?
我认为没有任何问题,所以这不一定是您问题的答案。我只想反驳另一个问题:你到底想做什么?
您创建了一个包含 p 值的漂亮绘图。虽然放入 paper/report 很好,但这不是我通常执行 'actual' 分析的方式。因此,我要问你的第一个问题是,你想做什么类型的 analysis/comparision?你不提那个,你只是说你认为你的结果很奇怪。但是您要分析的内容对于您使用 stat_compare_means
.
我认为这个例子没有意义,但我可以很容易地重现它,所以不要将它用于你自己的分析(它只是一个例子)。所以说,你想做一个配对 t 检验。分析看起来像:
t1 <- df %>% filter(Gaussian_One == "Non_Treated") %>% pull(Weight_G1)
t2 <- df %>% filter(Gaussian_One == "Treated1") %>% pull(Weight_G1)
t3 <- df %>% filter(Gaussian_One == "Treated2") %>% pull(Weight_G1)
t.test(t1, t2, paired = TRUE)
t.test(t1, t3, paired = TRUE)
t.test(t2, t3, paired = TRUE)
分别导致
data: t1 and t2
t = 13.166, df = 5, p-value = 4.515e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.08708014 0.12933555
sample estimates:
mean of the differences
0.1082078
data: t1 and t3
t = 22.133, df = 5, p-value = 3.497e-06
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.07194078 0.09084735
sample estimates:
mean of the differences
0.08139407
Paired t-test
data: t2 and t3
t = -5.2963, df = 5, p-value = 0.003202
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.03982790 -0.01379965
sample estimates:
mean of the differences
-0.02681378
如果我们想在你的图表中绘制它,你会这样做:
ggboxplot(df, x = "Gaussian_One", y = "Weight_G1",lwd=1,
color = "Gaussian_One", palette = "jco")+
stat_compare_means(method = "t.test", paired = TRUE,
label = "p",comparisons = my_comparisons)
该图现在包含我也从配对 t 检验中获得的 p 值。
在您的示例中,您没有指定 comparing/calculating p 值的方法。我在文档中找不到默认使用的内容,但这可能解释了您的 'weird' 结果。因此,如果您返回绘图 table 并决定您实际想要查看的分析并将其添加到 stat_compare_means
,您的结果将更有意义。