r R模型创建和摘要统计

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r R模型创建和摘要统计相关的知识,希望对你有一定的参考价值。

# Library Dependencies
library(tidyverse)
library(modelr)
library(broom)

# Example Model Logic

model1 <- lm(avgHouseIncome ~ population, data=dfAgg)
model2 <- lm(avgHouseIncome ~ wgtEducation, data=dfAgg)
model3 <- lm(avgHouseIncome ~ population * wgtEducation, data=dfAgg)
model4 <- lm(avgHouseIncome ~ population + wgtEducation, data=dfAgg)

model5 <- rlm(avgHouseIncome ~ population, data=dfAgg)
model6 <- rlm(avgHouseIncome ~ wgtEducation, data=dfAgg)
model7 <- rlm(avgHouseIncome ~ population * wgtEducation, data=dfAgg)
model8 <- rlm(avgHouseIncome ~ population + wgtEducation, data=dfAgg)

model9 <- lm(avgHouseIncome ~ population * wgtEducation + poplation + wgtEducation, data=dfAgg)
model10 <- lm(avgHouseIncome ~ population * wgtEducation + poplation, data=dfAgg)
model11 <- lm(avgHouseIncome ~ population * wgtEducation + wgtEducation, data=dfAgg)

# Combine Model Data

grid1 <- dfAgg %>%
    data_grid(population, wgtEducation) %>%
    gather_predictions(model1, model2, model3, model4)

grid2 <- dfAgg %>%
    data_grid(population, wgtEducation) %>%
    gather_predictions(model5, model6, model7, model8)

grid3 <- dfAgg %>%
    data_grid(population, wgtEducation) %>%
    gather_predictions(model9, model10, mode11)

# Create Model Performance Data Sets

glance1 <- tibble(c(modelNum="model1", glance(model1))
glance2 <- tibble(c(modelNum="model2", glance(model2))
glance3 <- tibble(c(modelNum="model3", glance(model3))
glance4 <- tibble(c(modelNum="model4", glance(model4))
glance5 <- tibble(c(modelNum="model5", glance(model5))
glance6 <- tibble(c(modelNum="model6", glance(model6))
glance7 <- tibble(c(modelNum="model7", glance(model7)) 
glance8 <- tibble(c(modelNum="model8", glance(model8))
glance9 <- tibble(c(modelNum="model9", glance(model9))
glance10 <- tibble(c(modelNum="model10", glance(model10))
glance11 <- tibble(c(modelNum="model11", glance(model11))

glanceAll <- full_join(glance1, glance2, by = modelNum) %>%
    full_join(., glance3, by =modelNum) %>%
    full_join(., glance4, by =modelNum) %>%
    full_join(., glance5, by =modelNum) %>%
    full_join(., glance6, by =modelNum) %>%
    full_join(., glance7, by =modelNum) %>%
    full_join(., glance8, by =modelNum) %>%
    full_join(., glance9, by =modelNum) %>%
    full_join(., glance10, by =modelNum) %>%
    full_join(., glance11, by =modelNum)

以上是关于r R模型创建和摘要统计的主要内容,如果未能解决你的问题,请参考以下文章

r 将摘要统计信息转换为R中的整理数据框

Titanic生存预测(Kaggle入门赛)——基于R语言

R中线性模型的系数和摘要的不同NA动作

在R语言中显示美丽的数据摘要summary统计信息

使用混淆矩阵和插入符号统计的灵敏度和特异性的零 R 模型计算

R-统计分析的一些R包和函数