data <- scan(what = list(person=0,treatment="",taste=0), multi.line=F) 1 KFC 6.8 1 Popeyes 7.2 1 Churchs 7.0 2 KFC 7.7 2 Popeyes 7.4 2 Churchs 6.8 3 KFC 1.8 3 Popeyes 1.6 3 Churchs 1.5 4 KFC 6.3 4 Popeyes 7.4 4 Churchs 6.7 5 KFC 8.1 5 Popeyes 7.9 5 Churchs 7.1 6 KFC 7.8 6 Popeyes 8.4 6 Churchs 8.0 7 KFC 8.8 7 Popeyes 9.5 7 Churchs 8.7 data biscuits <- data.frame(data) rm(data) biscuits$person <- as.factor(biscuits$person) biscuits$treatment <- as.factor(biscuits$treatment) boxplot(taste ~ treatment, data=biscuits, main = "Biscuit data") # RCB analysis biscuit.rcb <- lm(taste ~ person +treatment, data=biscuits) anova(biscuit.rcb) # check model assumptions par(mfrow=c(2,2)) plot(biscuit.rcb) par(mfrow=c(1,1)) # create the variable to use in performing Tukey's additivity test biscuits$pred <- biscuit.rcb$fitted.values biscuits$res <- biscuit.rcb$residuals biscuits$Tukey <- biscuits$pred^2/(2*mean(biscuits$taste)) # refit the model with the new variable # its P value is for the test of additivity biscuit.rcb2 <- lm(taste ~ person +treatment +Tukey, data=biscuits) anova(biscuit.rcb2) # if we had rejected the null hypothesis of additivity, we could # have used 1 - betahat for the estimate of the Tukey variable slope # to suggest a power transformation to restore additivity summary(biscuit.rcb2)