# Bret Larget # April 27, 2009 # ANOVA Analysis of fat data, Evans and Rosenthal Example 10.4.1 # Response is grams of fat absorbed while cooking donuts # There are eight different types of fat # There are six observations per treatment group # Read in the data fat = read.table("fat.txt",header=T) # Plot the data separately for each treatment group library(lattice) print( xyplot(absorbed ~ type, data=fat, pch=16) ) # Can also make side-by-side boxplots print( bwplot(absorbed ~ type, data=fat) ) # Things to notice from the graphs: # (1) While the sample means are different in each group, # it is less clear if the differences can be explained by chance alone. # (2) The variability within each group is about the same. # Here are some numerical summaries. # Note the use of tapply() to apply a function separately to each part of the variable absorbed # that is partitioned by the factor type. fat.mean = with( fat, tapply(absorbed,type,mean) ) fat.sd = with( fat, tapply(absorbed,type,sd) ) print(cbind(fat.mean,fat.sd)) # Use lm() to fit a linear model (ANOVA) fat.lm = lm(absorbed ~ type, data=fat) # Print out the estimated coeeficients print(summary(fat.lm)) # Print the ANOVA table print(anova(fat.lm))