Download Two sample test_supplement

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Psychometrics wikipedia , lookup

Bootstrapping (statistics) wikipedia , lookup

Taylor's law wikipedia , lookup

German tank problem wikipedia , lookup

Resampling (statistics) wikipedia , lookup

Student's t-test wikipedia , lookup

Transcript
TWO SAMPLE
STATISTICAL INFERENCES
Additional material
1
How can we compare two means?
• Suppose that we have two populations.
Furthermore, suppose that
the first population has a mean 1 and the second population a
mean 2.
• We would like to use inferential statistics to compare 1 and 2 by
using either a confidence interval and/or a significance test.
2
Independent Samples
• Independent Samples occur when observations are gathered
independently from two different populations.
•
For example, suppose we want to compare starting salaries for males
and females at a certain bank. We collect a random sample of males and
a random sample of females and measure their starting salaries.
3
Paired Samples
• Paired Samples occur when observations are
gathered in pairs, where each pair consists of an
observation from population 1 and an observation
from population 2, and these two observations are
related.
• Although there are other types of paired samples, a
common type is a before-after sample.
4
Paired Samples
• For example, suppose we want to determine the effectiveness
of a new drug in reducing blood pressure.
• For each individual in the sample a measurement is taken prior to the
medication and another measurement is taken after using the
medication for a fixed period of time.
• These two observations (for each individual) are related. This constitutes
a paired sample.
5
Outline
• Two sample comparisons:
• Paired Samples (dependent samples)
• Independent Samples – Population Standard Deviations
Not Assumed to be Equal (σ1≠ σ2)
• Independent Samples – Population Standard Deviations
Assumed to be Equal (σ1= σ2)
• All methods assume random samples from normal
populations with unknown means and unknown
standard deviations.
• For small sample sizes, it is critical that our observations
are normal or approximately normal.
• However, for sufficiently large sample sizes (from the
C.L.T.) the assumptions of normality can be relaxed.
6
PAIRED SAMPLES
7
Paired (dependent) Samples
8
Paired (dependent) Samples
9
Paired (dependent) Samples
t-score = di invttail(n-1,α/2)
10
Paired (dependent) Samples
11
INDEPENDENT TWO
SAMPLES
12
Independent Two Samples
• We gather independent and random samples
from each population.
13
Independent Two Samples
14
Independent Two Samples
15
Independent Two Samples: Not Assuming Equal
Standard Deviations (σ1≠ σ2)
~ tdf=v,
Note: Unless we obtain our degrees of freedom using a computer, we will
round v down to the nearest integer.
16
Independent Two Samples: Not Assuming Equal
Standard Deviations (σ1≠ σ2)
• A (1-α)×100% CI is
( x1  x2 )  t
*
df  v , / 2
2
1
2
2
s
s

n1 n2
*
where tdf v, / 2 a critical value that makes the right tail
probability equal to α/2
Stata: di invttail(df, α/2)
17
Independent Two Samples: Not Assuming Equal
Standard Deviations (σ1≠ σ2)
18
Exercise: Does alcohol affect males and
females differently?
A study involving males and females with similar physical
characteristics was conducted. In a controlled setting, each
individual was asked to consume 4 ounces of alcohol. One
hour after consumption each participant took a Breathalyzer to
measure his or her blood alcohol level. The following results
were obtained:
•Is
there a real difference in blood alcohol levels between males and
females? Carry out an appropriate test to answer this question.
•Calculate a 99% confidence interval for the difference in blood alcohol
levels between males and females.
19
Exercise
• Stata command and outputs:
•
ttesti n1 u1 s1 n2 u2 s2, unequal level(#)
20
Independent Samples: Assuming Equal Standard
Deviations (σ1= σ2)
21
Independent Samples: Assuming Equal Standard
Deviations (σ1= σ2)
22
Independent Samples: Assuming Equal Standard
Deviations (σ1= σ2)
23
Independent Samples: Assuming Equal Standard
Deviations (σ1= σ2)
24
To be pooled, or not to be pooled? Equal S.D. or
not equal?
• We
could base our decision on an informal rule (usually
works and is much less complicated).
• If
no sample standard deviation is twice the other, (i.e 0.5 < s1/s2 <
2), then the assumption of equal standard deviations should be ok.
• We
could perform a graphical analysis and look at the
box-plots for the samples to informally assess the equal
standard deviations assumption.
• There are formal tests to assess the evidence against
equal population standard deviations
• Variance Ratio Test
• Levene’s Test
25
Variance Ratio Test
• Ho: σ12 = σ22
vs. Ha: σ12 ≠ σ22
• Test statistic: F= s12 / s22 ~ Fdf1=n1-1, df2=n2-1
• p-value:
26
Variance Ratio Test
• Stata command:
sdtesti n1 . sd1 n2 . sd2
• Example: Test σ1= σ2 when observed n1=75,
sd1=6.5, n2=65, and sd2= 7.5
• sdtesti 75 . 6.5
65 . 7.5
27
Exercise
• Two
machines are used to fill plastic bottles with
dishwashing detergent. Two random samples are taken
and the following results are obtained:
• Is
there a real difference between their average fills?
Carry out an appropriate test to answer this question.
• Calculate a 95% confidence interval for the difference in
the mean fill between the two machines
28
Exercise
• s1=√0.113=0.336; s2= √0.125 =0.354
• Testing for Equal Variances
29
Exercise
• Stata command for two-sample t test with equal variances
• ttesti N1 u1 s1 N2 u2 S2, level(#)
Compared with machine 2, machine 1 had a statistically significantly lower
mean fill. The difference in mean fill was -0.41 (95%CI: -0.59 to -0.23) for
machine 2 relative to machine 1 (p<0.001).
30