Created
October 7, 2019 19:12
-
-
Save monogenea/66dff559969502f0c995dcf6184e52ca to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Fit lm using all 14 vars | |
modHousesFull <- lm(MEDV ~ ., data = houses) | |
summary(modHousesFull) # R2 = 0.741 | |
# Compare obs. vs. pred. plots | |
par(mfrow = c(1,2)) | |
plot(houses$MEDV, predict(modHouses), | |
xlab = "Observed MEDV", ylab = "Predicted MEDV", | |
main = "PCR", abline(a = 0, b = 1, col = "red")) | |
plot(houses$MEDV, predict(modHousesFull), | |
xlab = "Observed MEDV", ylab = "Predicted MEDV", | |
main = "Full model", abline(a = 0, b = 1, col = "red")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment