1
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

4

1 回答 1

1

如此处所述,您可以相对于 BIC 获得它:

n <- length(Data$Y)
p <- apply(demand.leaps1$which, 1, sum)
aic <- demand.leaps1$bic - log(n) * p + 2 * p
于 2013-07-12T04:40:09.660 回答