Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created October 30, 2016 05:27
Show Gist options
  • Save lotusirous/e2732093d21c61e52be6e4bc5cc3bba0 to your computer and use it in GitHub Desktop.
Save lotusirous/e2732093d21c61e52be6e4bc5cc3bba0 to your computer and use it in GitHub Desktop.
rm(list=ls())
data = read.csv('weisberg_fuel.csv',header=TRUE)
X1 <- data$TAX # Tax
X2 <- data$DLIC
X3 <- data$INC
X4 <- data$ROAD
Y <- data$FUEL
df <- cbind(X1,X2,X3,X4,Y)
pairs(df)
summary(df)
cor(df)
fit <- lm(Y ~ X1+X2+X3+X4)
summary(fit)
# Anova
anova(fit)
# Use stepAIC
library(MASS)
stepAIC(fit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment