hw4a - Solutions to Assignment 4 Stat 512, Spring 2010 1....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Solutions to Assignment 4 Stat 512, Spring 2010 1. (a) No, it doesnt. The old display was used during the first three-week period, and the new display (Treatment 1) was used during the second three-week period. Even if the average change is statistically significant, we do not know if the effect is due to the change in display, a trend over time, or some other variables that have not been measured. In this experiment, Treatments 1, 2 and 3 were randomly assigned, so these data can be used to make causal comparisons among Treatments 1, 2 and 3. But the old display was not randomly assigned, and so we cannot include the old display in our causal comparisons. (b) > # read in data and extract variables > Drugstore <- read.table("Drugstore.txt", header=T) > treatment <- factor(Drugstore$treatment) > contrasts(treatment) <- contr.sum > post <- Drugstore$post > pre <- Drugstore$pre > # perform ANOVA > result <- lm( post ~ treatment ) > anova(result) Analysis of Variance Table Response: post Df Sum Sq Mean Sq F value Pr(>F) treatment 2 1524.40 762.20 6.6899 0.01117 * Residuals 12 1367.20 113.93--- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Yes, the treatment effect is significant. > # define contrast weights > c1 <- c(-1,1,0) > c2 <- c(-1,0,1) > c3 <- c(0,-1,1) > # compute estimated contrasts > Ybari <- tapply( post, treatment, mean) > Lhat1 <- sum(c1*Ybari) > Lhat2 <- sum(c2*Ybari) > Lhat3 <- sum(c3*Ybari) > # compute SEs > MSE <- sum( result$residuals^2 ) / result$df.residual > a <- 3 > n <- 5 > SE1 <- sqrt( MSE * sum(c1^2)/n ) > SE2 <- sqrt( MSE * sum(c2^2)/n ) > SE3 <- sqrt( MSE * sum(c3^2)/n ) > # compute t-statistics and Fs > T1 <- Lhat1 / SE1 > T2 <- Lhat2 / SE2 > T3 <- Lhat3 / SE3 > F1 <- T1^2 > F2 <- T2^2 > F3 <- T3^2 > # compute pvals > p1 <- 1 - pf(F1, 1, 12) > p2 <- 1 - pf(F2, 1, 12) > p3 <- 1 - pf(F3, 1, 12) > # create table > result <- cbind( + Lhat = c(Lhat1, Lhat2, Lhat3), + SE = c(SE1, SE2, SE3), + T = c(T1, T2, T3), + F = c(F1, F2, F3), + p = c(p1, p2, p3)) > rownames( result ) <- c( "2 versus 1", "3 versus 1", "3 versus 2" ) > result Lhat SE T F p 2 versus 1 23.8 6.750802 3.5255068 12.4291984 0.00418084 3 versus 1 17.6 6.750802 2.6070975 6.7969573 0.02292398 3 versus 2 -6.2 6.750802 -0.9184093 0.8434757 0.37649542 Treatment 2 is significantly different from 1, and 3 is significantly different from 1, but 3 is not significantly different from 2. (c) First, fit the unequal slopes model to see if the slopes are different. > # center the covariate > preC <- pre - mean(pre) > # unequal slopes model > result <- lm( post ~ preC + treatment + preC:treatment) > anova(result) Analysis of Variance Table Response: post Df Sum Sq Mean Sq F value Pr(>F) preC 1 1317.79 1317.79 81.6808 8.251e-06 *** treatment 2 1397.28 698.64 43.3040 2.409e-05 *** preC:treatment 2 31.33 15.66 0.9709 0.4151 Residuals 9 145.20 16.13--- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 The interactions are not significant, so there is no convincing evidence that the slopes...
View Full Document

Page1 / 10

hw4a - Solutions to Assignment 4 Stat 512, Spring 2010 1....

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online