Transcript Document

How to do T-test?
Cindy Wu
1
Difference Between Two Means
Population means,
independent
samples
*
σ1 and σ2 known
Use a Z test statistic
σ1 and σ2 unknown,
assumed equal
Use Sp to estimate unknown
σ , use a t test statistic and
pooled standard deviation
σ1 and σ2 unknown,
not assumed equal
Use S1 and S2 to estimate
unknown σ1 and σ2, use a
separate-variance t test
Source: Mark L, Berenson, David M. Levine, Timonthy C. Levine, Basic Business Statistics–
Concepts and Applications, 10rd Edition, 2005
2
When is T-test performed?
• To compare the means between two groups
• One-tail T-test
– μ1 ≧ μ2 or μ1 ≤ μ2
– ex: Foreign students have higher grade than local
students
• Two-tail T-test
– μ1 ≠ μ2
– ex: the performance between foreign and local
students are different.
3
Hypothesis Testing for
Mean Difference, σD Unknown
Lower-tail test:
Upper-tail test:
Two-tail test:
H0: μ1 – μ2 ≧ 0
H1: μ1 – μ2 < 0
H0: μ1 – μ2 ≤ 0
H1: μ1 – μ2 > 0
H0: μ1 – μ2 = 0
H1: μ1 – μ2 ≠ 0
a
a
-ta
Reject H0 if t < -ta
ta
Reject H0 if t > ta
Where t has n - 1 d.f.
a/2
-ta/2
a/2
ta/2
Reject H0 if t < -ta/2
or t > ta/2
Source: Mark L, Berenson, David M. Levine, Timonthy C. Levine, Basic Business Statistics–
Concepts and Applications, 10rd Edition, 2005
4
Hypothesis
• Hypothesis 0: Gender differences have no
influence on the preference toward
chocolate
• Hypothesis 1: Gender differences have
influence on the preference toward
chocolate
5
T-test step1: The test of variance
(F-test)
• To test if the variances of the two groups
are equal
– If the p-value of F value (Pr > F ) >α=0.05, the
variances are equal
• Equal variance: pooled method
– If the p-value of F value (Pr > F ) <α=0.05, the
variances are unequal
• Unequal variance: Satterthwaite method
6
T-test step2: T-test
• To test if the hypothesis 1 is accepted.
– If the p-value of T value (Pr > |t|) >α=0.05, H0
is accepted
• Gender differences have no influence on the
preference toward chocolate
– If the p-value of T value (Pr > |t|) <α=0.05, H0
is rejected
• Gender differences do have influence on the
preference toward chocolate
7
Example (SAS)
Please open Tim’s HW
8
Common Mistakes
1. Didn’t check if the variance is equal or
not first
2. T-test can’t be used to find the reason
•
Why do people ride bike? For convenience?
For health?
3. Use pair T-test to test two different
groups
4. When using Excel, don’t know how to
interpret the result
9
Types of Data
Data
Categorical
Numerical
Examples:



Marital Status
Political Party
Eye Color
(Defined categories)
Discrete
Examples:


Number of Children
Defects per hour
(Counted items)
Continuous
Examples:


Weight
Grades
(Measured characteristics)
Source: Mark L, Berenson, David M. Levine, Timonthy C. Levine, Basic Business
Statistics– Concepts and Applications, 10rd Edition, 2005
10
Levels of Measurement
and Measurement Scales
EXAMPLES:
Ratio Data
Differences between
measurements, true
zero exists
Height, Age, Weekly
Food Spending
Interval Data
Differences between
measurements but no
true zero
Temperature in
Fahrenheit, Standardized
exam score
Ordinal Data
Ordered Categories
(rankings, order, or scaling)
Nominal Data
Categories (no ordering
or direction)
Service quality rating,
Standard & Poor’s bond
rating, Student letter
grades
Marital status, Type of car
owned
Source: Mark L, Berenson, David M. Levine, Timonthy C. Levine, Basic Business Statistics–
Concepts and Applications, 10rd Edition, 2005
11
Two-Sample Tests in EXCEL
For independent samples:
• Independent sample Z test with variances known:
– Tools | data analysis | z-test: two sample for means
• Pooled variance t test:
– Tools | data analysis | t-test: two sample assuming equal variances
• Separate-variance t test:
– Tools | data analysis | t-test: two sample assuming unequal variances
For paired samples (t test):
– Tools | data analysis | t-test: paired two sample for means
For variances:
• F test for two variances:
– Tools | data analysis | F-test: two sample for variances
Source: Mark L, Berenson, David M. Levine, Timonthy C. Levine, Basic Business Statistics–
Concepts and Applications, 10rd Edition, 2005
12
Example (Excel)
13
Example (SPSS)
14
Hypothesis
• Hypothesis 0: Gender differences have no
influence on the preference toward
chocolate
• Hypothesis 1: Gender differences have
influence on the preference toward
chocolate
15
Table 1. Descriptive statistics
Gender
number
mean
1 (boys)
2 (girls)
33
44
3.2424
4.1364
Standard
deviation
0.16872
0.13243
16
Table 2. T-test results (SPSS)
Equal variance of Equal mean of t-test
Levene test
Chocolate preference Significance
T value Significance
Equal variances
-4.227
0.000
-4.168
0.000
Unequal variances
0.558
P-value <0.05
Ho is rejected.
So the gender differences have influence on the
preference toward chocolate
17
Thanks.
18
F distribution
• Test for the Difference in 2 Independent
Populations
• Parametric Test Procedure
• Assumptions
–
Both populations are normally distributed
•
Test is not robust to this violation
– Samples are randomly and independently
drawn
Source: Mark L, Berenson, David M. Levine, Timonthy C. Levine, Basic Business Statistics–
Concepts and Applications, 10rd Edition, 2005
19
Hypothesis Tests for
Variances
Tests for Two
Population
Variances
F test statistic
*
H0: σ12 = σ22
H1: σ12 ≠ σ22
Two-tail test
H0: σ12 ≧ σ22
H1: σ12 < σ22
Lower-tail test
H0: σ12 ≤ σ22
H1: σ12 > σ22
Upper-tail test
20