# In this Lab, we'll do t.tests and chi-squared tests. It seems long, but
# it's only 20 lines of code, many of which are very similar. So, use
# the UP/DOWN arrows.
# 1) Even though we've used t.test() already, we're going to use it again,
# but this time with emphasis on the resulting p-values, as opposed to the CI.
# The reason is that t.test() has some arguments that do not affect the CI, but
# do affect the p-value.
# Exercise 8.38 is good to do, because it asks if some difference exceeds
# some number.
#
# First, copy/paste the data from
# http://www.stat.washington.edu/marzban/390/8_38_dat.txt .
#
# Then, ask yourself if the data are paired.
# In this problem the answer is Yes!
weight=c(14.6,14.4,19.5,24.3,16.3,22.1,23,18.7,19,17,19.1,19.6,23.2,18.5,15.9)
tread=c(11.3,5.3,9.1,15.2,10.1,19.6,20.8,10.3,10.3,2.6,16.6,22.4,23.6,12.6,4.4)
# Before doing any test, "look" at the data:
boxplot(weight,tread,names=c("weight","treadmill"))
# Discuss these relative boxplots. But, keep in mind that the data are
# paired; these boxplots do NOT reflect that fact. As such,
# the comparison of these boxplots may be misleading.
# The scatterplot of the two variables, shows a correlation,
# confirming that the data are paired.
plot(weight,tread)
cor(weight,tread)
# Now, the t.test assumes that the population is normal. So, let's see
# if our data are at least consistent with that assumption:
qqnorm(weight)
qqnorm(tread)
# These could look better; but with the small sample size we're
# dealing with, they are normal enough. Also, technically, since
# we need to do a paired test, it is the differences which should have