zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 R数据分析:2014年美国人时间使用调查(ATUS)饮食与健康模块文件分析

    # libraries we'll need
    library(car) # for avplots
    library(tidyverse) # for general utility functions
    
    # read in our data 
    bmi_data <- read_csv("../input/eating-health-module-dataset//ehresp_2014.csv") %>%
        filter(erbmi > 0) # remove rows where the reported BMI is less than 0 (impossible)
    nyc_census <- read_csv("../input/new-york-city-census-data/nyc_census_tracts.csv")
    # fit a glm model
    model <- glm(erbmi ~ euexfreq + euwgt + euhgt + ertpreat, # formula
                 data = bmi_data, # dataset
                 family = ("gaussian")) # fit a linear model
    # output plots in a 2 x 2 grid 
    par(mfrow = c(2,2)) 
    # diagnostic plots
    plot(model)

    # examine our model
    summary(model)

    # added-variable plots for our model
    avPlots(model)

    结论
    看这些图,我们可以在右上角看到随着euwgt(体重)的增加,erbmi(体重指数,我们试图预测的变量)也在增加。看左下角我们可以看到,随着euhgt(高度)的增加,erbmi实际上在减少。所以身高和体重都很重要,但它们有相反的效果!我们也可以从模型总结中看出这一点,因为euwgt的估计值为正,而euhgt的估计值为负。
    另外两个图显示这些变量和我们要预测的变量之间没有很强的关系,我们已经从模型中算出来了。
  • 相关阅读:
    Python字典处理技巧
    javascript常用对象
    8. 异步操作
    九度OnlineJudge之1022:游船出租
    直方图(下)
    MySQL中关于日期、时间的数据类型和函数
    libvirt(virsh命令介绍)
    11g的alert日志路径
    使用GridView来获取xml文件数据
    MediaPlayer视频播放器
  • 原文地址:https://www.cnblogs.com/tszr/p/11236234.html
Copyright © 2011-2022 走看看