NotMyName
NotMyName

Reputation: 51

Why is p-value always the same between different group, Someone know what I am doing of wrong?

Hi All I am doing comparison of weight of different distribution. My data are formatted in this way:

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    

And I am using the following code:

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

The p-value appear to be alway the same 0.22, what I am doing of wrong?

Upvotes: 0

Views: 266

Answers (1)

Annet
Annet

Reputation: 866

I don't think anything is going wrong, so this is not necessarily going to be an answer to your question. I am just going to counter with another question: what do you acutally want to do?

You create a nice plot with p-values in it. Although it is nice for putting in a paper/report, this isn't how I would usually perform my 'actual' analyses. Therefore, my first question for you is, what type of analysis/comparision are you trying to do? You don't mention that, you just say you think your results are weird. But what you are trying to analyse is of incredible importance for what you are doing with stat_compare_means.

I don't think this example makes sense, but I could easily reproduce it, so don't use it for your analyses itself (it is just an example). So say, you want to do a paired t-test. The analysis would look like:

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)

Respectively resulting in

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 

If we want to plot that in your graph you would do:

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) 

The plot now contains the p-values I also got from the paired t-test.

In your example you didn't specify the method of comparing/calculating p-values. I cannot find in the documentation what is used as default, but that likely explains your 'weird' result. So if you go back to the drawing table and decide on what analysis you actually want to look at and add that to stat_compare_means, your results are going to make more sense.

Upvotes: 1

Related Questions