Input = ( "Food Raw.p Blue_fish .34 Bread .594 Butter .212 Carbohydrates .384 Cereals_and_pasta .074 Dairy_products .94 Eggs .275 Fats .696 Fruit .269 Legumes .341 Nuts .06 Olive_oil .008 Potatoes .569 Processed_meat .986 Proteins .042 Red_meat .251 Semi-skimmed_milk .942 Skimmed_milk .222 Sweets .762 Total_calories .001 Total_meat .975 Vegetables .216 White_fish .205 White_meat .041 Whole_milk .039 ") Data = read.table(textConnection(Input),header=TRUE) Data = Data[order(Data$Raw.p),] Data$Bonferroni = p.adjust(Data$Raw.p, method = "bonferroni") Data
> Data Food Raw.p Bonferroni 20 Total_calories 0.001 0.025 --> 0.001 * nrow(Data) = 0.025 12 Olive_oil 0.008 0.200 --> 0.008 * nrow(Data) = 0.200 25 Whole_milk 0.039 0.975 24 White_meat 0.041 1.000 15 Proteins 0.042 1.000 11 Nuts 0.060 1.000 5 Cereals_and_pasta 0.074 1.000 23 White_fish 0.205 1.000 3 Butter 0.212 1.000 22 Vegetables 0.216 1.000 18 Skimmed_milk 0.222 1.000 16 Red_meat 0.251 1.000 9 Fruit 0.269 1.000 7 Eggs 0.275 1.000 1 Blue_fish 0.340 1.000 10 Legumes 0.341 1.000 4 Carbohydrates 0.384 1.000 13 Potatoes 0.569 1.000 2 Bread 0.594 1.000 8 Fats 0.696 1.000 19 Sweets 0.762 1.000 6 Dairy_products 0.940 1.000 17 Semi-skimmed_milk 0.942 1.000 21 Total_meat 0.975 1.000 14 Processed_meat 0.986 1.000
set.seed(123) data<-data.frame(x=rep(letters[1:4], each=5), y=sort(rlnorm(20))) pairwise.t.test(x=data$y, g=data$x, p.adj="bonf") #see results below: # data: data$y and data$x # a b c # b 1.00000 - - # c 0.38945 1.00000 - # d 8.3e-06 3.5e-05 0.00031 # P value adjustment method: bonferroni t.test(y~x, data[data$x=="a" | data$x=="b",])$p.value*6 t.test(y~x, data[data$x=="a" | data$x=="c",])$p.value*6 t.test(y~x, data[data$x=="a" | data$x=="d",])$p.value*6 t.test(y~x, data[data$x=="b" | data$x=="c",])$p.value*6 t.test(y~x, data[data$x=="b" | data$x=="d",])$p.value*6 t.test(y~x, data[data$x=="c" | data$x=="d",])$p.value*6 # a vs. b = 0.0788128848 # a vs. c = 0.0001770066 # a vs. d = 0.0324680659 # b vs. c = 0.0137812904 # b vs. d = 0.0488036762 # c vs. d = 0.0970799045