RAFAEL IRIZARRY: Up to now, we have been focusing on understanding the concepts,
and we've used population data that we typically don't have access to.
Here, I'm simply going to show you what you would actually
do if you had a data set like this.
We can construct a t-statistic, calculate a p-value,
and confidence intervals.
So the first thing you do in practice is actually reading the data.
This is the data at hand, the 12 and 12.
And now we have to compute the mean difference
and estimate the standard error.
There's actually a function in R that does that all for us for us.
It's called the t.test function.
You can look it up.
You can look up the help file if you want to know the details,
but then you just feed it the two values, the two sets of values
that you want to compare.
And you run this.
We can put in an object if you want it, and then we can take a look.
And you'll see that you get some information here.
You get the t-statistic is 2.0552.
That's the value we got when we did it by hand.
The p-value is 0.053.
And then here is a 95% confidence interval.
Now one thing I want you to know is that earlier when
we used the central limit theorem approximation, the p-value was smaller.
That is because here we are not assuming that the central limit
theorem applies to the t-statistic.
Instead, we are using the t-distribution approximation.
The t-distribution has bigger tails so you get a smaller p-value.
Now an assumption we're making when we use that distribution
is that the data, the original data, original mouse data,
is normally distributed, meaning that if we had access to the entire population
and we looked at that, it to be roughly normally distributed.
Now we can test that somewhat by making q-q plots of the sample that we have.
So we can look at the qqnorm of the controls
and a qqnorm of the treatment group.
You can see that it's just 12 points.
So it's not a perfect check of assumptions,
but it's at least telling us that we're not totally off.
So here it is for the treatment.
And we'll then see a similar result. So you
can see that the normal distribution doesn't
look to be too off, meaning that using the t-distribution approximation
is probably OK.