0

我在 Kruskal-Wallis 测试中发现了几个问题。但是,我在之前的帖子中没有遇到以下问题:

我想做以下事情:

  1. 测试eachmedian_value之间的 是否不同。为此,我想执行Kruskal–Wallis 检验。但是,我的代码给了我相同的p 值study_groupnutrienttimepoint

  2. 是否也可以调整p 值以考虑多次测试

  3. Kruskal-Wallis 检验能否以相同的方式用于检验nutrient随时间变化的中位数?注:nutrient是随时间高度相关的数据。

这是我的数据:

d2 <- structure(list(study_group = structure(c(1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("Intervention group", 
"Control group"), class = "factor"), timepoint = structure(c(1L, 
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("Baseline", 
"6 months", "24 months", "48 months"), class = "factor"), nutrient = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Energy_kcal", 
"Carbohydrates_g", "Sugar_g", "Fat_g", "Saturated_FA_g", "Protein_g", 
"Fibre_g", "Alcohol_g", "Vegetables_g", "Fruit_g", "Grains_g", 
"Whole_grain_bread_g", "dairy_products_g", "fat_reduced_milk_and_cheese_g", 
"Red_and_processed_meat_g", "Fast_food_g", "Sweets_g", "Juice_and_soft_drinks_ml"
), class = "factor"), median_value = c(1879.6, 1557.2, 1540.4, 
1667.6, 1888.8, 1827.2, 1824.4, 1830.3, 209, 180.2, 178.2, 189.2, 
210.3, 203.3, 199.4, 193.6)), row.names = c(NA, 16L), class = "data.frame")

请参阅下面的代码:

comp1 <- d2 %>% 
    group_by(timepoint, nutrient) %>% 
    do(tidy(kruskal.test(x= .$median_value, g = .$study_group)))
comp1

# A tibble: 8 x 6
# Groups:   timepoint, nutrient [8]
  timepoint nutrient        statistic p.value parameter method                      
  <fct>     <fct>               <dbl>   <dbl>     <int> <chr>                       
1 Baseline  Energy_kcal             1   0.317         1 Kruskal-Wallis rank sum test
2 Baseline  Carbohydrates_g         1   0.317         1 Kruskal-Wallis rank sum test
3 6 months  Energy_kcal             1   0.317         1 Kruskal-Wallis rank sum test
4 6 months  Carbohydrates_g         1   0.317         1 Kruskal-Wallis rank sum test
5 24 months Energy_kcal             1   0.317         1 Kruskal-Wallis rank sum test
6 24 months Carbohydrates_g         1   0.317         1 Kruskal-Wallis rank sum test
7 48 months Energy_kcal             1   0.317         1 Kruskal-Wallis rank sum test
8 48 months Carbohydrates_g         1   0.317         1 Kruskal-Wallis rank sum test
4

0 回答 0