数据分析:多组ANOVA和后置检验

介绍

单因素多个levels数据在做方差分析后,需要进一步做如t检验等置后检验,判断两两组间差异。

加载R包和准备数据

# Load required R packages
library(tidyverse)
library(rstatix)
library(ggpubr)
  
data("PlantGrowth")
set.seed(1234)
PlantGrowth %>% sample_n_by(group, size = 1)

查看统计量

PlantGrowth %>%
  group_by(group) %>%
  get_summary_stats(weight, type = "mean_sd")

使用ANOVA test比较多组的平均值

res.aov <- PlantGrowth %>% anova_test(weight ~ group)
res.aov

组间t检验

pwc <- PlantGrowth %>%
  pairwise_t_test(weight ~ group, p.adjust.method = "bonferroni")
pwc

p值的坐标轴参数

pwc <- pwc %>% add_xy_position(x = "group")
pwc

可视化

ggboxplot(PlantGrowth, x = "group", y = "weight") +
  stat_pvalue_manual(pwc, label = "p.adj", tip.length = 0, step.increase = 0.1) +
  labs(
    subtitle = get_test_label(res.aov, detailed = TRUE),
    caption = get_pwc_label(pwc))

Reference

  1. HOW TO PERFORM T-TEST FOR MULTIPLE GROUPS IN R

相关推荐

  1. C++:++--运算符的前如何实现

    2024-05-10 01:30:03       26 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-10 01:30:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-10 01:30:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-10 01:30:03       82 阅读
  4. Python语言-面向对象

    2024-05-10 01:30:03       91 阅读

热门阅读

  1. SSD存储基本知识

    2024-05-10 01:30:03       31 阅读
  2. C++学习笔记(多线程)

    2024-05-10 01:30:03       31 阅读
  3. Vuex存储数据实例

    2024-05-10 01:30:03       35 阅读
  4. SSH免密登录

    2024-05-10 01:30:03       31 阅读
  5. baxter机械臂校准

    2024-05-10 01:30:03       30 阅读
  6. 网络安全零信任学习2:零信任概念

    2024-05-10 01:30:03       37 阅读
  7. mybatis 中 #{}和 ${}的区别是什么?

    2024-05-10 01:30:03       28 阅读