可以使用AIC得分比较多元回归模型 [英] It is possible to compare the multiple regression models using AIC scores

查看:165
本文介绍了可以使用AIC得分比较多元回归模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用AIC得分比较多元回归模型,以及从支持最好的模型到支持最差的模型?

It is possible to compare the multiple regression models using AIC scores, with the models ordered from best-supported to worst-supported?

这是我的代码

 library(data.table)

 Regressions<- 
 data.table(February)[, 
                      .(Lm = lapply(.SD, function(x) summary(lm(February$PPNA ~ February$Acum1 + x)))),
                      .SDcols = 80:157]

推荐答案

我们可以基于"AIC"值提取AIC值和order

We can extract the AIC values and order based on the 'AIC' values

library(data.table)
dt <- as.data.table(February)
dt1 <- dt[, .(Lm = lapply(.SD, function(x) lm(February$PPNA ~ February$Acum1 + x))),
          .SDcols = 80:157]
dt2 <-  dt1[, .(Lm = Lm[order(unlist(lapply(Lm, AIC)))])]


或使用可复制的示例


Or using a reproducible example

dt1 <- as.data.table(iris)[, .(Lm = lapply(.SD, function(x) 
          lm(iris$Petal.Length ~ iris$Species + x)))]
dt2 <-  dt1[, .(Lm = Lm[order(unlist(lapply(Lm, AIC)))])]

这篇关于可以使用AIC得分比较多元回归模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆