Ttest
Ttest
Ttest
Assumptions
Virtually every statistic, parametric or nonparametric,
has assumptions which must be met prior
to the application of the experimental design
and subsequent statistical analysis.
We will discuss specific assumptions associated with
individual tests as they come up.
Virtually all parametric statistics have an
assumption that the data come from a population
that follows a known distribution.
Most of the tests we will evaluate in this module
require a normal distribution.
3
Normality
There are 5 major tests used:
Shapiro-Wilk W test
Anderson-Darling test
Martinez-Iglewicz test
Kolmogorov-Smirnov test
DAgostino Omnibus test
NB: Power of all is weak if N < 10
5
Shapiro-Wilk W test
Developed by Shapiro and Wilk (1965).
One of the most powerful overall tests.
It is the ratio of two estimates of variance (actual
calculation is cumbersome; adversely affected by ties).
Test statistic is W; roughly a measure of the straightness
of the quantile-quantile plot.
The closer W is to 1, the more normal the sample is.
Available in R and most other major stats applications.
2.6
2.4
2.2
Sample Quantiles
2.8
3.0
2.0
Example in R
(Tutorial-3)
-2
-1
Theoretical Quantiles
Anderson-Darling test
Developed by Anderson and Darling (1954).
Very popular test.
Based on EDF (empirical distribution function)
percentile statistics.
Almost as powerful as Shapiro-Wilk W test.
Martinez-Iglewicz Test
Based on the median & robust estimator of
dispersion.
Very powerful test.
Works well with small sample sizes.
Particularly useful for symmetrically skewed samples.
A value close to 1.0 indicates normality.
Strongly recommended during EDA.
Not available in R.
9
Kolmogorov-Smirnov Test
Calculates expected normal distribution and compares
it with the observed distribution.
Uses cumulative distribution functions.
Based on the max difference between two distributions.
Poor for discrimination below N = 30.
Power to detect differences is low.
Historically popular.
Available in R and most other stats applications.
10
The t-Distribution
t-distribution is similar to Z-distribution
Note similarity:
Z=
y
y
vs. t =
/ N
S / N
12
The t-Distribution
See Appendix
Statistical Table C
Standard
Normal (Z)
t, = 12
t, = 6
13
14
y
S / N
y t 2 , df SE y y t 2 , df SE y
2
df s
df s
2
2
2
/ 2, df
1/ 2, df
15
H0: = 0
HA: 0
16
Median
-1.050
Max.
1.700
=
=
=
=
=
=
15
1
1.2523
0.05
0.8199317
two.sided
=
=
=
=
=
=
20
1
1.2523
0.05
0.9230059
two.sided
=
=
=
=
=
25
1
1.2523
0.05
0.9691447
i
20
21
22
Sa2 = 16.27
Sb2 = 13.98
N = 12
N=8
z 1j =x j Med x
z 2j=y j Med y
Two-sample t-test
- for Homogeneous Variances Begin by calculating the mean & variance for
each of your two samples.
Then determine pooled variance Sp2:
2
p
N1
N2
i =1
j =1
yi yi 2 y j yj 2
N 11 N 21
Theoretical formula
N 1 1S 21 N 2 1 S 22
N 1 N 2 2
Machine formula
27
Two-sample t-test
- for Homogeneous Variances Determine the test statistic tcalc:
t=
y1 y2
2
df =N 1 N 2 2
S p Sp
N1 N 2
Two-sample t-test
- Example Suppose a microscopist has just identified
two potentially different types of cells based
upon differential staining.
She separates them out in to two groups
(amber cells and blue cells). She
suspects there may be a difference in
cell wall thickness (cwt) so she wishes to
test the hypothesis:
Ho: ACcwt = BCcwt
Ha: ACcwt BCcwt
29
Two-sample t-test
- Example Parameter
Mean
SS
N
AC-type
8.57
2.39
14
BC-type
8.40
2.74
18
Two-sample t-test
- Example -
Sp =
t calc =
2.392.74
= 0.17
1317
8.578.40
= 1.13
0.17 0.17
14
18
df = 14182=30
32
33
Two-sample t-test
- for Heterogeneous Variances -
34
Two-sample t-test
- Adjusted df for Heterogeneous Variances -
df
S1 S 2
N1 N2
S1
S2
N1
N2
N 1 1 N 2 1
36
37
Matched-Pair t-test
It is not uncommon in biology to conduct an
experiment whereby each observation in a
treatment sample has a matched pair in a control
sample.
Thus, we have violated the assumption of
independence and can not do a standard
t-test.
The matched-pair t-test was developed to
address this type of experimental design.
38
Matched-Pair t-test
By definition, sample sizes must be equal.
Such designs arise when:
Same obs are exposed to 2 treatments over time.
Before and after experiments (temporally related).
Side-by-side experiments (spatially related).
Many early fertilizer studies used this design. One plot
received fertilizer, an adjacent plot did not. Plots were
replicated in a field and plant yield measured.
39
Matched-Pair t-test
The approach to this type of analysis is a bit
counter intuitive.
Even though there are two samples, you will
work with only one sample composed of:
STANDARD DIFFERENCES
and df = Nab - 1
40
Matched-Pair t-test
- Assumptions The data are continuous (not discrete).
The data, i.e., the differences for the matchedpairs, follow a normal probability distribution.
The sample of pairs is a simple random sample
from its population.
41
Matched-Pair t-test
N
yd =
2
d
S =
yd
d=1
d=1
d =1
y 2d y d / N
N 1
t =
yd
S d / N
42
150
250
200
300
400
2.0
1.0
0.0
Frequency
3.0
Histogram of Dif.Fert
350
Dif.Fert
-1.5
-0.5
0.5
1.5
Theoretical Quantiles
43
44
Statistical Power
Q. What if I do a t-test on a pair of
samples and fail to reject the null
hypothesis--does this mean that there is
no significant difference?
A. Maybe yes, maybe no.
Depends upon the POWER of your test
and experiment.
45
Power
Power is the probability of rejecting the
hypothesis that the means are equal when they
are in fact not equal.
Power is one minus the probability of Type-II
error ().
The power of the test depends upon the sample
size, the magnitudes of the variances, the alpha
level, and the actual difference between the two
population means.
46
Power
Usually you would only consider the power of a test
when you failed to reject the null hypothesis.
High power is desirable (0.7 to 1.0). High power means
that there is a high probability of rejecting the null
hypothesis when the null hypothesis is false.
This is a critical measure of precision in hypothesis
testing and needs to be considered with care.
More on Power in the next lecture.
47