Created
November 20, 2015 14:35
-
-
Save DonatasD/a6bf20151c4483c3fe04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plotSubset = function(regfit.summary) { | |
#Plot RSS | |
op = par(mfrow = c(2,2)) | |
plot(regfit.summary$rss, xlab = "Number of variables", ylab="RSS", type="l") | |
#Plot adjusted RS^2 and mark its maximum | |
plot(regfit.summary$adjr2, xlab = "Number of variables", ylab="Adjusted RS^2", type="l") | |
max = which.max(regfit.summary$adjr2) | |
points(max, regfit.summary$adjr2[max], col="red", cex=2, pch=20) | |
#Plot CP and mark its minimum point | |
plot(regfit.summary$cp, xlab= "Number of variables", ylab="CP", type="l") | |
min = which.min(regfit.summary$cp) | |
points(min, regfit.summary$cp[min], col="red", cex=2,pch=20) | |
#Plot BIC and mark its minimum | |
plot(regfit.summary$bic, xlab="Number of variables", ylab="BIC", type="l") | |
min = which.min(regfit.summary$bic) | |
points(min, regfit.summary$bic[min], col="red", cex=2,pch=20) | |
par(op) | |
} | |
plotSubsetWithPredictors = function(reg) { | |
op = par(mfrow=c(2,2)) | |
plot(reg, scale ="r2") | |
plot(reg, scale ="adjr2") | |
plot(reg, scale ="Cp") | |
plot(reg, scale ="bic") | |
par(op) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment