library(leaps)
demand.lm = lm(y ~ X, data = Data)
X = model.matrix(demand.lm)[, -1]
demand.leaps1 = summary(regsubsets(X, Data$Y,data=Data, nbest = 3))
Subsets <- demand.leaps1$which
RSS <- demand.leaps1$rss
adjr2 <- demand.leaps1$adjr2
cp <- demand.leaps1$cp
bic <- demand.leaps1$bic
Subsets1 <- cbind(as.data.frame(Subsets), RSS=RSS,adjR2=adjr2,cp=cp,BIC=bic)
现在我的 Subset1 数据框有我想要的列,除了 AIC How to get AIC with the BIC I have for all Subset Models