R Statistics Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

In general, once we have determined that a factor is significative (at least one of its levels has a mean that's different from the rest), we want to plot the differences between the levels, along with their 95% confidence intervals. This can be achieved via the Tukey Honest Differences function (TukeyHSD in R), as follows:

rbind(TukeyHSD(d)$Colour,TukeyHSD(d)$Font)

The preceding code generates the following output: 

This prints all of the mean differences between each pair of factors, along with the lower and upper 95% confidence intervals (this can be changed via the conf.level parameter). Finally, the p-value is printed (the null hypothesis is that the difference is equal to zero) with an adjustment. This adjustment is necessary because, when we do multiple comparisons, it is likely that some of them will appear to be significative just because of random chance.

We can conclude that the Blue background colour provides a statistically significative difference with respect to the Red colour (it is actually between 31 and 42). For the font type, we can conclude that the modern font type yields an extra average of 19.42 over the classic one.