# This program illustrate partial/overal F-tests stat and # the effect of multicollinearity # cf. Table 7.1--7.8. in NKNW # Load the data (Body Fat Example, P 261) t<-matrix(scan("CH07TA01.DAT"),ncol=4,byrow=T) bfat <-data.frame(y=t[,4],x1=t[,1],x2=t[,2],x3=t[,3]) attach(bfat) # Prelim plots and correlation matrix calc windows() pairs(bfat,main="Scatter plot matrix of y, x1, x2, x3") cor(bfat) # Regress Y on X1, X2, X1 and X2 respectively m1<-lm(y~x1);m1s<-summary(m1);m1s;anova(m1); m2<-lm(y~x2);m2s<-summary(m2);m2s;anova(m2); m12<-lm(y~x1+x2);m12s<-summary(m12);m12s;anova(m12); m123<-lm(y~x1+x2+x3);m123s<-summary(m123);m123s;anova(m123); # m1$fitted.values m2$fitted.values m12$fitted.values m123$fitted.values m1$coef; m1s$cov.unscaled m2$coef; m2s$cov.unscaled m12$coef; m12s$cov.unscaled m123$coef; m123s$cov.unscaled detach(bfat) # Standardized Version stbfat <-data.frame(y=scale(t[,4]),x1=scale(t[,1]),x2=scale(t[,2]),x3=scale(t[,3])) attach(stbfat) # Prelim plots and correlation matrix calc windows() pairs(stbfat,main="Scatter plot matrix of y, x1, x2, x3") cor(stbfat)