Skip to content

Instantly share code, notes, and snippets.

@marutter
Created November 19, 2010 14:03
Show Gist options
  • Select an option

  • Save marutter/706547 to your computer and use it in GitHub Desktop.

Select an option

Save marutter/706547 to your computer and use it in GitHub Desktop.
data1 <- read.csv("data_set_1.csv")
library(MASS)
library(car)
data1a <- within(data1,Y2<-exp(Y))
res <- stepAIC(lm(Y~(X1+X2+X3+X4+X5+X6)^2+I(X1^2)+I(X2^2)+I(X3^2)+I(X4^2)+I(X5^2)+I(X6^2),data=data1),k=log(2010))
plot(res,1)
data2 <- read.csv("data_set_2.csv")
res <- stepAIC(lm(log(Y)~(X1+X2+X3+X4+X5+X6)^2+I(X1^2)+I(X2^2)+I(X3^2)+I(X4^2)+I(X5^2)+I(X6^2),data=data2),
k=log(6903))
summary(res)
plot(res,1)
data3 <- read.csv("data_set_3.csv")
res <- stepAIC(lm(Y~X1+X2+X3+X4+X5+X6+X7+X8,data=data3),
k=log(956))
boxTidwell(Y~X1+X3,~X2+X4+X6,data=data3a)
res <- stepAIC(lm(Y~log(X1)+X2+I(X3^2)+X4+I(1/X5)+X6+X7+X8,data=data3),
k=log(956))
plot(res,1)
summary(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment