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的估计值为负。
    另外两个图显示这些变量和我们要预测的变量之间没有很强的关系,我们已经从模型中算出来了。
  • 相关阅读:
    【转】Git详解之六 Git工具
    【转】Git详解之五 分布式Git
    【转】Git详解之四 服务器上的Git
    【转】Git详解之三 Git分支
    【转】Git详解之二 Git基础
    【转】Git详解之一 Git起步
    【教】Windows下的Git入门
    <<万物简史>>第三章埃文斯牧师的宇宙
    上班两周
    记录一下
  • 原文地址:https://www.cnblogs.com/tszr/p/11236234.html
Copyright © 2011-2022 走看看