• R 方差分析 analysis of variance



    title: “方差分析 analysis of variance”
    author:

    • Liu tiezhu
      date: ‘2022-08-29’
      documentclass: ctexart
      keywords:
    • 中文
    • R Markdown
      output:
      rticles::ctex:
      fig_caption: yes
      number_sections: yes
      toc: yes

    knitr::opts_chunk$set(echo = TRUE)
    
    • 1

    Analysis with R

    • Explore
    • clean
    • Manipulate
    • Describe and summarise
    • Analyse

    Analyse your data

    ANOVA coding

    library(tidyverse)
    library (patchwork)
    library(gapminder)  #life expect in difference area
    library(forcats)
    #data()
    head(gapminder)
    # Create a data set to work with
    gapdata <-  gapminder %>%
    filter(year ==2007&
    continent %in% c("Americas","Europe","Asia")) %>%
    select(continent,lifeExp)
    #Take a look at the distribution of means
    gapdata %>%
    group_by(continent) %>%
    summarise(Mean_life=mean(lifeExp)) %>%
    arrange(Mean_life)
    #Research question:
    # Is the life expectancy  in these three continents
    # Research question: Is the life expectancy in these three continents different
    # Hypothesis testing: HO:Mean life expectancy is the same
    #                     HI:Mean life expectancy is not the same
    # observation:
    # Difference in mean is observed in the sample data,but is this statistically 
    #  significant (alpha 0.05)    
    #  Create ANOVA mode 1  
    gapdata  %>%
    aov(lifeExp ~ continent,data =.) %>%
    summary()
    aov_model <- gapdata  %>%
    aov(lifeExp ~ continent,data =.)
    
    # Is this significance being driven by a particular continent?  
    gapdata %>%
    aov(lifeExp ~ continent,data = .) %>%
    TukeyHSD() %>%
    plot()
    TukeyHSD(aov_model)
    
    #The difference between Asia and the Americas
    #has an adjusted p value of 0.14 (not significant)
    #and a 95%cI that overlaps 0
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42

    多组间两两比较图形 TukeyHSD方法:
    多组间两两比较图形 TukeyHSD方法:

  • 相关阅读:
    FreePascal 解析命令行参数
    【JavaEE初阶--多线程进阶】JUC里的一些组件和多线程中的一些集合类
    算法 - 检查是否存在满足条件的数字组合
    Vue3: 获取元素DOM的方法
    递归构建下拉树
    No.1-------MySQL:数据库系统概述、MySQL简介、库操作
    Hive 上配置 Hive on Spark
    R语言、因子载荷矩阵
    一文彻底搞懂Mysql索引优化
    JAVASE 第二十三天
  • 原文地址:https://blog.csdn.net/qq_43596960/article/details/126601222