library(leaps) g x <- model.matrix(g)[,-1] y <- statedata$Life g <- leaps(x,y) g Cpplot(g) plot(g$size,g$Cp) abline(0,1) plot(g$size,g$Cp,ylim=c(0,20)) abline(0,1) g$Cp[size==4] g$Cp[g$size==4] g$which$Cp[g$size==4][1] g$which[g$size==4][1] g$which[g$size==4][1,] g$which[g$size==4] g$which[g$size==4,][1,] statedata[1:2] statedata[1:2,] g g <- leaps(x,y,method="adjr2") maxadjr(adjr,8) g g$which(g$adjr==max(g$adjr)) g$which[g$adjr==max(g$adjr),] help(leaps) h <- hat(x) names(h) <- state.abb rev(sort(h)) l <- leaps(x[-2,],y[,-2],method="adjr2") l <- leaps(x[-2,],y[-2],method="adjr2") g$which[g$adjr==max(a$adjr),] l$which[l$adjr==max(l$adjr),] par(mfrow=c(3,3)) for(i in 1:8) box(state.x77[,i]) for(i in 1:8) boxplot(state.x77[,i]) nx <- cbind(log(x[,1],x[2:6],log(x[,7])) ) nx <- cbind(log(x[,1],x[,2:6],log(x[,7])) ) nx <- cbind(log(x[,1]),x[,2:6],log(x[,7])) a <- leaps(nx,y,methods="adjr2") a <- leaps(nx,y,method="adjr2") a$which[a$adjr==max(a$adjr),]