Title: Two Sample Inference
1Two Sample Inference
2One Sample Inference
Everything weve been doing lately has been to
compare some test sample with another group weve
called population, at least some of whose
parameters are known. ex compare a sample
mean with the population mean. If the population
standard deviation is known, then compute z
score. Do this even if n isnt big! ex
compare sample mean with the population mean. If
the population standard deviation is not known,
compute t-score. (as n approaches infinity, the
t-distribution converges to the normal
distribution) ex compare sample proportion
with population proportion. Use normal approx if
Then compute z score.
3Two Sample Inference
Suppose instead we want to compare two samples,
assumed to be normal, whose parameters are NOT
known a priori. How should a test statistic
differ from the previous ones? Consider for
instance the comparison of the means of two
samples, which are drawn from two different
populations. Then each population has some
(unknown) mean and some (unknown) standard
deviation. We can only get our hands on the
sample means and sample standard deviations. How
can we compare these? How might we test the
hypothesis that the means of these two groups are
different?
4Longitudinal Study vs. Cross-Sectional Study
Longitudinal Study especially useful when were
talking about how a treatment affects a person.
The two sets are before and after, and we measure
(for instance) the blood pressure of each person
before and after the treatment and look at the
individual differences. The statistic that we
end up studying is the difference between the two
measurements, over a period of time. Cross-sectio
nal Study Take the measurements of each group,
take the means of each group, and compare the
means. This might be handy when you have two
groups with different sizes, or when there is not
an obvious way to pair members of each group.
5Two Sample Inference paired t-test
In the one sample test statistic Where Xbar
and mu are the sample mean and population mean,
and s is the sample standard deviation.
6Two Sample Inference paired t-test
One sample test statistic By analogy two
sample test statistic might be where the
numerator is just the difference in the two
sample means. And it seems ok to put some kind
of standard error of the mean type thing in the
denominator. But what exactly is s_d? That
depends on the way the test is set up.
7Two Sample Inference paired t-test
So if each member of group one is paired with a
member with group two, then the difference
between the two is really what were looking at.
Where n is the number of matched pairs.
8Paired t-test
- Ex 8.2, 8.3 Cardiovascular Disease, Hypertension.
- Consider the relationship between the use of oral
contraceptives and blood pressure in women. - Conduct a longitudinal study
- Identify a large group of non-pregnant women who
are not taking oral contraceptives (but
presumably might someday). Measure the blood
pressure of each. Call this the baseline blood
pressure. - Look at the same group one year later, and
determine a subgroup of people who have started
using birth control pills. This is the study
population. - Take the blood pressure of each person in the
study group. - Compare each of these with their baseline blood
pressure.
Note each person is her own control value as
well as experimental value!
9Paired t-test
Ex 8.2, 8.3 Cardiovascular Disease, Hypertension.
Consider the relationship between the use of
oral contraceptives and blood pressure in women.
10Paired t-test
Ex 8.2, 8.3 Cardiovascular Disease, Hypertension.
Consider the relationship between the use of
oral contraceptives and blood pressure in women.
Test the hypothesis that use of birth control
pills affects blood pressure
Now, formulate the hypotheses, and compute the
test statistic
11Paired t-test
Ex 8.2, 8.3 Cardiovascular Disease, Hypertension.
Consider the relationship between the use of
oral contraceptives and blood pressure in
women.
Now, formulate the hypotheses, and compute the
test statistic H0 the difference is 0 (theres
no difference) H1 dbar not equal to 0 For
two sided test, alpha .05, 9 df, t_critical
2.262. So reject the null hypothesis. Whats
the conclusion?
12Paired t-test, confidence intervals
Just as we gave confidence interval for the mean
of a sample, we can construct a confidence
interval for difference of two means. As
before, a confidence interval for any parameter
is a point estimate plus or minus some critical
value times a number of standard errors.
13Paired t-test, confidence intervals
Ex 8.7 Cardiovascular Disease, Hypertension.
Give a 95 confidence interval for the true mean
difference in blood pressure.
14Paired t-test, confidence intervals
Ex 8.7 Cardiovascular Disease, Hypertension.
Give a 95 confidence interval for the true mean
difference in blood pressure.
For 9 degrees of freedom, and 95 confidence (two
sided), the critical value is 2.262. Thus, can
be 95 confident that the true mean difference is
somewhere between 4.8 2.2624.57/sqrt(10) and
4.8 2.2624.57/sqrt(10) , Which is between
1.53 and 8.07 mm Hg.
15Cross-sectional Study
The previous case was with paired samples each
person in the study had a before and an after
reading, and the difference for each was
measured. In contrast, we could have set up the
problem as follows Take a group of women who
are not taking birth control pills, measure their
blood pressure. Compute the mean and standard
deviation. Do the same with a second group of
women who do use the pill. How can we compare
the two? Assume that each group is normally
distributed. If the two samples had the same
known standard deviation sigma, then
16Cross-sectional Study
If the two samples had the same known standard
deviation sigma, then
Why?
Why? If the two groups are normally distributed
each with the same s.d. sigma, then the
difference d bar between random variables X1 bar
and X2 bar is also a random variable (its a
linear combination). Recall that
17Cross-sectional Study
If the two samples had the same known standard
deviation sigma, then
But in general, the population standard deviation
is not known. Furthermore, since were comparing
two different groups (drawn from different
populations), the standard deviations of the two
samples will in general be different. For now,
lets pretend that the two sample standard
deviations are both estimators for the same
unknown population standard deviation. Then will
need to use some kind of sample standard
deviation. We have two samples, possibly of
different sizes, and want to take some kind of
weighted average of the two sample standard
deviations, and call that thing s.
18Cross-sectional Study
Where s comes from the pooled estimate of the
variance
Note n1 1 degrees of freedom from s1 and n2-1
degrees of freedom from s2
Now, as before, formulate a hypothesis, compute
the t-statistic, and compare with the critical
values (use n1n2-2 df) And decide if there is
sufficient evidence to say there is a significant
difference.
19Cross-sectional Study - example
Consider the same question as before, Does the
use of oral contraceptives affect blood
pressure? H0 mu1 mu2 H1 mu1 not equal to
mu2
20Cross-sectional Study - example
Consider the same question as before, Does the
use of oral contraceptives affect blood
pressure? H0 mu1 mu2 H1 mu1 not equal to
mu2
This is just the mean of the two standard
deviations. Will this be the case in general?
21Cross-sectional Study - example
Consider the same question as before, Does the
use of oral contraceptives affect blood
pressure? H0 mu1 mu2 H1 mu1 not equal to
mu2
What conclusion do you draw? Compare this with
the result from the paired t-test.
22Cross-sectional Study - example
Consider the same question as before, Does the
use of oral contraceptives affect blood
pressure? H0 mu1 mu2 H1 mu1 not equal to
mu2
What conclusion do you draw? Compare this with
the result from the paired t-test.
23Cross-sectional Study example2
Ex 8.5 8.9 Nutrition The mean of the ln of
calcium intake (in mg) among girls age 12-14
seems to depend on poverty. In a group of 25
girls living below the poverty level, the mean of
the ln of calcium intake is 6.56, with a standard
deviation of 0.64. In contrast, a group of 40
girls the same age living above the poverty level
has a mean of 6.80 and standard deviation of
0.76. How might we test whether there is a
significant difference in the means?
24How to determine if Variances are Equal?
The previous problems assumed that population
variances of the two groups were equal, and we
came up with a pooled variance a weighted
average of the two sample variances. This is
only valid if the two sample variances are
comparable but how do we measure that? Compute
the ratio of the two sample variances. If it is
very much larger than 1 or very much smaller than
1, then we conclude that the variances are
different. Note that this ratio is always
positive. Thus, there is a different standard to
compare the statistic with, called F distribution.
25How to determine if Variances are Equal?
Consider the case seen earlier, with the oral
contraceptives and blood pressure. We assumed
that the variances of the blood pressure was the
same for each group. Was that a reasonable
assumption?
26How to determine if Variances are Equal?
F distribution is a family of distributions
(like t-distributions, for instance). Takes two
parameters, corresponding to the degrees of
freedom in the numerator and the number of
degrees of freedom in the denominator. It is
positively skewed. Compute the F-statistic, and
compare it to the value in table 9, page 836, or
use the finv function in excel.
27How to determine if Variances are Equal?
Consider the case seen earlier, with the oral
contraceptives and blood pressure. We assumed
that the variances of the blood pressure was the
same for each group. Was that a reasonable
assumption?
Note that these are inverses of each
other. Thats because n1 n2.
28How to determine if Variances are Equal?
Consider the case seen earlier, with the oral
contraceptives and blood pressure. We assumed
that the variances of the blood pressure was the
same for each group. Was that a reasonable
assumption?
Since F is between these two, it is reasonable to
assume that the variances are equal. This
seems like an awfully big window doesnt it? But
n is small. If n were larger, we should be less
tolerant of very large (or very small) F scores.
Look at percentiles for F as df1 and df2 go to
infinity.
29If Variances are unequal?
If it is determined that the variances of the two
groups are unequal, then the t-statistic is
computed differently, using each sample standard
deviation.
30Linear Regression
31Linear Regression
(1, 1.8436) (2, 3.4764) (3, 4.3525) (4,
6.8114) (5, 9.8709)
y mxberror Assume error is normally
distributed
32Linear Regression
Corrected sum of cross products
(1, 1.8436) (2, 3.4764) (3, 4.3525) (4,
6.8114) (5, 9.8709)
Corrected sum of squares of x
33Linear Regression
(1, 1.8436) (2, 3.4764) (3, 4.3525) (4,
6.8114) (5, 9.8709)
34Linear Regression
(1, 1.8436) (2, 3.4764) (3, 4.3525) (4,
6.8114) (5, 9.8709)
35Linear Regression
(1, 1.8436) (2, 3.4764) (3, 4.3525) (4,
6.8114) (5, 9.8709)
36Linear Regression
(1, 1.8436) (2, 3.4764) (3, 4.3525) (4,
6.8114) (5, 9.8709)
37Linear Regression