xy = read.table("data030102.txt") X1 = xy$V1; X2 = xy$V2; X3 = xy$V3; X4 = xy$V4; X5 = xy$V5; X6 = xy$V6; X7 = xy$V7; X8 = xy$V8; Y = xy$V10; n = length(Y) Base = lm(Y ~ 1) Full = lm(Y~X1+X2+X3+X4+X5+X6+X7+X8) # Forward selection step(Base, scope = list(upper=Full, lower=~1), direction = "forward", trace=TRUE) # Backward selection step(Full, scope = list(upper=Full, lower=~1), direction = "backward", trace=TRUE) # Stepwise selection step(Full, scope = list(upper=Full, lower=~1), direction = "both", trace=TRUE) # BIC step(Full, direction = "both", k = log(n)) # AIC step(Full, direction = "both", k = 2)