{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw3a - Solutions to Assignment 3 Stat 512 Spring 2010 >...

This preview shows pages 1–5. Sign up to view the full content.

Solutions to Assignment 3 Stat 512, Spring 2010 1. (a) > # read in data > FabricShrink <- read.table("FabricShrink.txt", header=T) > # change fabric and temp to factors and plot > FabricShrink\$fabric <- factor(FabricShrink\$fabric) > FabricShrink\$temp <- factor(FabricShrink\$temp) > plot( y ~ fabric, data=FabricShrink) > plot( y ~ temp, data=FabricShrink) 1 2 3 4 2 4 6 8 10 12 fabric y We see some differences in shrinkage among the fabrics. 210 215 220 225 2 4 6 8 10 12 temp y Percent shrinkage increases with temperature in a curvilinear fashion. The variance of the response appears to increase with the mean, so the errors are not homoscedastic.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
(b) > # apply effect coding and fit the two-way ANOVA model > contrasts(FabricShrink\$fabric) <- contr.sum > contrasts(FabricShrink\$temp) <- contr.sum > result <- lm( y ~ fabric*temp, data=FabricShrink) > summary(result) Call: lm(formula = y ~ fabric * temp, data = FabricShrink) Residuals: Min 1Q Median 3Q Max -3.000e-01 -1.125e-01 -1.388e-17 1.125e-01 3.000e-01 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 5.66875 0.03953 143.409 < 2e-16 *** fabric1 -1.54375 0.06847 -22.548 1.50e-13 *** fabric2 -0.31875 0.06847 -4.656 0.000264 *** fabric3 1.64375 0.06847 24.009 5.63e-14 *** temp1 -3.00625 0.06847 -43.909 < 2e-16 *** temp2 -2.13125 0.06847 -31.129 9.59e-16 *** temp3 0.48125 0.06847 7.029 2.85e-06 *** fabric1:temp1 0.83125 0.11859 7.010 2.95e-06 *** fabric2:temp1 -0.04375 0.11859 -0.369 0.717015 fabric3:temp1 -1.30625 0.11859 -11.015 7.04e-09 *** fabric1:temp2 0.05625 0.11859 0.474 0.641665 fabric2:temp2 0.88125 0.11859 7.431 1.42e-06 *** fabric3:temp2 -0.58125 0.11859 -4.902 0.000160 *** fabric1:temp3 0.19375 0.11859 1.634 0.121812 fabric2:temp3 -0.33125 0.11859 -2.793 0.013019 * fabric3:temp3 0.75625 0.11859 6.377 9.17e-06 *** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Residual standard error: 0.2236 on 16 degrees of freedom Multiple R-squared: 0.9977, Adjusted R-squared: 0.9955 F-statistic: 455.6 on 15 and 16 DF, p-value: < 2.2e-16 > anova(result) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(>F) fabric 3 41.876 13.959 279.175 5.048e-14 *** temp 3 283.936 94.645 1892.908 < 2.2e-16 *** fabric:temp 9 15.856 1.762 35.236 7.094e-09 *** Residuals 16 0.800 0.050 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 From the ANOVA table, we see that the interactions fabric:temp are highly signifi- cant, so the effects of these two factors are not additive.
(c) > # compute the means for each temp and plot > Ybar.j. <- tapply( FabricShrink\$y, FabricShrink\$temp , mean) > plot(1:4, Ybar.j., type="l") 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4 6 8 10 1:4 Ybar.j. One way to find the contrast SS’s is to compute them yourself. yourself. Orthogonal polynomial contrast scores for a four-level factor are: linear: - 3 - 1 1 3 quadratic: 1 - 1 - 1 1 cubic: - 1 3 - 3 1 > # define contrast weights > c1 <- c(-3,-1,1,3) > c2 <- c(1,-1,-1,1) > c3 <- c(-1,3,-3,1) > # compute estimated contrasts and SS’s > a <- 4 > b <- 4 > n <- 2 > L1 <- sum(c1*Ybar.j.) > SSL1 <- a*n*L1^2/sum(c1^2) > L2 <- sum(c2*Ybar.j.) > SSL2 <- a*n*L2^2/sum(c2^2) > L3 <- sum(c3*Ybar.j.) > SSL3 <- a*n*L3^2/sum(c3^2) > # compute F’s and p-values > S2 <- sum( result\$residuals^2 ) / result\$df.residual > F1 <- SSL1 / S2 > F2 <- SSL2 / S2 > F3 <- SSL3 / S2 > p1 <- 1-pf( F1, 1, 16) > p2 <- 1-pf( F2, 1, 16) > p3 <- 1-pf( F3, 1, 16) > # display everything in a table

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> tmp <- matrix(NA,3,4) > rownames(tmp) <- c("linear", "quadratic", "cubic") > colnames(tmp) <- c("SS", "df", "F", "p") > tmp[,1] <- c(SSL1,SSL2,SSL3) > tmp[,2] <- 1 > tmp[,3] <- c(F1,F2,F3) > tmp[,4] <- c(p1,p2,p3) > round(tmp,4)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 11

hw3a - Solutions to Assignment 3 Stat 512 Spring 2010 >...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online