> ## sec. 10.5.1 Leaf Sping Experiment > # > data<-read.table("http://www.stat.ucla.edu/~hqxu/stat225/data/springrobust.dat") > data V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 -1 1 1 -1 7.78 7.78 7.81 7.50 7.25 7.12 2 1 1 1 1 8.15 8.18 7.88 7.88 7.88 7.44 3 -1 -1 1 1 7.50 7.56 7.50 7.50 7.56 7.50 4 1 -1 1 -1 7.59 7.56 7.75 7.63 7.75 7.56 5 -1 1 -1 1 7.94 8.00 7.88 7.32 7.44 7.44 6 1 1 -1 -1 7.69 8.09 8.06 7.56 7.69 7.62 7 -1 -1 -1 -1 7.56 7.62 7.44 7.18 7.18 7.25 8 1 -1 -1 1 7.56 7.81 7.69 7.81 7.50 7.59 > names(data)[1:4] <- LETTERS[2:5] > names(data) [1] "B" "C" "D" "E" "V5" "V6" "V7" "V8" "V9" "V10" > > # responses for location and dispersion models > ybar <- apply(data[,5:10], 1, mean) > lns2 <- log( apply(data[,5:10], 1, var) ) > > # make names be available > attach(data) > > # we need the halfnormal function in halfnormal.R > source("http://www.stat.ucla.edu/~hqxu/stat225/R/halfnormal.R") > > # we need to know the aliasing among factorial effects > # I=BCDE > # we can entertain 4 ME's + 3 2fi's > > # Fig 10.3 half-normal plot for location > g<-lm(ybar~B+C+D+E+B:C+B:D+C:D) # BC=DE, BD=CE, BE=CD > summary(g) Call: lm(formula = ybar ~ B + C + D + E + B:C + B:D + C:D) Residuals: ALL 8 residuals are 0: no residual degrees of freedom! Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.636042 B 0.110625 C 0.088125 D 0.014375 E 0.051875 B:C 0.008542 B:D 0.009792 C:D -0.017708 Residual standard error: NaN on 0 degrees of freedom Multiple R-Squared: 1, Adjusted R-squared: NaN F-statistic: NaN on 7 and 0 DF, p-value: NaN > halfnormal(2*g$coef[-1], label=T, type="n") # remove intercept > > # Fig 10.3 half-normal plot for dispersion > g<-lm(lns2~B+C+D+E+B:C+B:D+C:D) # BC=DE, BD=CE, BE=CD > summary(g) Call: lm(formula = lns2 ~ B + C + D + E + B:C + B:D + C:D) Residuals: ALL 8 residuals are 0: no residual degrees of freedom! Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.68862 B 0.06749 C 1.09010 D -0.52218 E -0.32493 B:C -0.26294 B:D 0.39974 C:D 0.59257 Residual standard error: NaN on 0 degrees of freedom Multiple R-Squared: 1, Adjusted R-squared: NaN F-statistic: NaN on 7 and 0 DF, p-value: NaN > halfnormal(2*g$coef[-1], label=T, type="n") # remove intercept >