赞
踩
- install.packages("leaps")
- library(leaps)
- exps<-regsubsets(y~x1+x2+x3+x4+x5+x6+x7+x8+x9,data = data3_1)
- exps<-regsubsets(y~x1+x2+x3+x4+x5+x6+x7+x8+x9,data = data3_1,nbest=1,really.big = T)
- expres<-summary(exps)
- res<-data.frame(expres$outmat,调整R平方=expres$adjr2)
- res
用R软件寻找最优子集, x1 x2 x3 x4 x5 x6 x7 x8 x9 调整R平方 1 ( 1 ) * 0.8823606 2 ( 1 ) * * 0.9513232 3 ( 1 ) * * * 0.9752336 4 ( 1 ) * * * * 0.9903308 5 ( 1 ) * * * * * 0.9903456 6 ( 1 ) * * * * * * 0.9901586 7 ( 1 ) * * * * * * * 0.9898406 8 ( 1 ) * * * * * * * * 0.9894367
逐步回归实例
- library(readr)
- data5_6 <- read_csv("data5.6.csv")
- View(data5_6)
- cor(dat
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。