Statistics for EES 3. From standard error to t-Test
Transcript of Statistics for EES 3. From standard error to t-Test
Statistics for EES3. From standard error to t-Test
Dirk Metzler
http://evol.bio.lmu.de/_statgen
May 14, 2012
1 / 52
Contents
1 The Normal Distribution
2 Taking standard errors into account
3 The t-Test for paired samplesExample: Orientation of pied flycatchers
2 / 52
The Normal Distribution
Contents
1 The Normal Distribution
2 Taking standard errors into account
3 The t-Test for paired samplesExample: Orientation of pied flycatchers
3 / 52
The Normal Distribution
Density of the normal distribution
−1 0 1 2 3 4 5
0.0
0.1
0.2
0.3
0.4
Nor
mal
dich
te
µµ µµ ++ σσµµ ++ σσ
The normal distribution is also called Gauß distribution(after Carl Friedrich Gauß, 1777-1855)
4 / 52
The Normal Distribution
Density of the normal distribution
−1 0 1 2 3 4 5
0.0
0.1
0.2
0.3
0.4
Nor
mal
dich
te
µµ µµ ++ σσµµ ++ σσ
The normal distribution is also called Gauß distribution
(after Carl Friedrich Gauß, 1777-1855)
4 / 52
The Normal Distribution
Density of the normal distribution
The normal distribution is also called Gauß distribution(after Carl Friedrich Gauß, 1777-1855)
4 / 52
The Normal Distribution
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●
●●●●●●●●●●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●●●●
●●●●●●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
400 450 500 550 600
0.00
00.
005
0.01
00.
015
0.02
00.
025
400:600
dbin
om(4
00:6
00, 1
000,
0.5
)
5 / 52
The Normal Distribution
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●
●●●●●●●●●●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●●●●
●●●●●●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
400 450 500 550 600
0.00
00.
005
0.01
00.
015
0.02
00.
025
400:600
dbin
om(4
00:6
00, 1
000,
0.5
)
5 / 52
The Normal Distribution
Density of standard normal distributionA random variable Z with density
f (x) =1√2π· e−
x22
−3 −2 −1 0 1 2 3
0.0
0.1
0.2
0.3
0.4
is called standard normally distributed.
“Gaussian bell”
for short: Z ∼N (0,1)
EZ = 0
Var Z = 1
6 / 52
The Normal Distribution
Density of standard normal distributionA random variable Z with density
f (x) =1√2π· e−
x22
−3 −2 −1 0 1 2 3
0.0
0.1
0.2
0.3
0.4
is called standard normally distributed.
“Gaussian bell”
for short: Z ∼N (0,1)
EZ = 0
Var Z = 1
6 / 52
The Normal Distribution
Density of standard normal distributionA random variable Z with density
f (x) =1√2π· e−
x22
−3 −2 −1 0 1 2 3
0.0
0.1
0.2
0.3
0.4
is called standard normally distributed.
“Gaussian bell”
for short: Z ∼N (0,1)
EZ = 0
Var Z = 1
6 / 52
The Normal Distribution
If Z is N (0,1) distributed, then X = σ · Z + µ is normallydistributed with mean µ and variance σ2, for short:
X ∼ N (0,1)
X has the density
f (x) =1√2πσ
· e−(x−µ)2
2σ2 .
7 / 52
The Normal Distribution
If Z is N (0,1) distributed, then X = σ · Z + µ is normallydistributed with mean µ and variance σ2, for short:
X ∼ N (0,1)
X has the density
f (x) =1√2πσ
· e−(x−µ)2
2σ2 .
7 / 52
The Normal Distribution
Keep in mind
If Z ∼ N (µ, σ2), then:Pr(|Z − µ| > σ) < 1
3
Pr(|Z − µ| > 2 · σ) < 0.05Pr(|Z − µ| > 3 · σ) < 0.003
8 / 52
The Normal Distribution
Keep in mind
If Z ∼ N (µ, σ2), then:Pr(|Z − µ| > σ) < 1
3
Pr(|Z − µ| > 2 · σ) < 0.05
Pr(|Z − µ| > 3 · σ) < 0.003
8 / 52
The Normal Distribution
Keep in mind
If Z ∼ N (µ, σ2), then:Pr(|Z − µ| > σ) < 1
3
Pr(|Z − µ| > 2 · σ) < 0.05Pr(|Z − µ| > 3 · σ) < 0.003
8 / 52
The Normal Distribution
f (x) =1√2πσ
· e−(x−µ)2
2σ2
0 2 4 6 8 10
0.0
00.0
50.1
00.1
50.2
00.2
5
µ− σ µ+ σµ
9 / 52
The Normal Distribution
Densities need integralsIf Z is a random variable with density f (x)
0 2 4 6 8 10
0.0
00
.05
0.1
00
.15
0.2
00
.25
ba ,then
Pr(Z ∈ [a,b]) =
∫ b
af (x)dx .
10 / 52
The Normal Distribution
Densities need integralsIf Z is a random variable with density f (x)
0 2 4 6 8 10
0.0
00
.05
0.1
00
.15
0.2
00
.25
ba ,then
Pr(Z ∈ [a,b]) =∫ b
af (x)dx .
10 / 52
The Normal Distribution
Example: Let Z ∼ N (µ = 5, σ2 = 2.25).
Pr(Z < a) can be computed with pnorm(a,mean=5,sd=1.5)
Computation of Pr(Z ∈ [3,4]):
Pr(Z ∈ [3,4]) = Pr(Z < 4)− Pr(Z < 3)
> pnorm(4,mean=5,sd=1.5)-pnorm(3,mean=5,sd=1.5)
[1] 0.1612813
11 / 52
The Normal Distribution
Example: Let Z ∼ N (µ = 5, σ2 = 2.25).
Pr(Z < a) can be computed with pnorm(a,mean=5,sd=1.5)
Computation of Pr(Z ∈ [3,4]):
Pr(Z ∈ [3,4]) = Pr(Z < 4)− Pr(Z < 3)
> pnorm(4,mean=5,sd=1.5)-pnorm(3,mean=5,sd=1.5)
[1] 0.1612813
11 / 52
The Normal Distribution
Example: Let Z ∼ N (µ = 5, σ2 = 2.25).
Pr(Z < a) can be computed with pnorm(a,mean=5,sd=1.5)
Computation of Pr(Z ∈ [3,4]):
Pr(Z ∈ [3,4]) = Pr(Z < 4)− Pr(Z < 3)
> pnorm(4,mean=5,sd=1.5)-pnorm(3,mean=5,sd=1.5)
[1] 0.1612813
11 / 52
The Normal Distribution
Example: Let Z ∼ N (µ = 5, σ2 = 2.25).
Pr(Z < a) can be computed with pnorm(a,mean=5,sd=1.5)
Computation of Pr(Z ∈ [3,4]):
Pr(Z ∈ [3,4]) = Pr(Z < 4)− Pr(Z < 3)
> pnorm(4,mean=5,sd=1.5)-pnorm(3,mean=5,sd=1.5)
[1] 0.1612813
11 / 52
The Normal Distribution
Example: Let Z ∼ N (µ = 5, σ2 = 2.25).
Pr(Z < a) can be computed with pnorm(a,mean=5,sd=1.5)
Computation of Pr(Z ∈ [3,4]):
Pr(Z ∈ [3,4]) = Pr(Z < 4)− Pr(Z < 3)
> pnorm(4,mean=5,sd=1.5)-pnorm(3,mean=5,sd=1.5)
[1] 0.1612813
11 / 52
The Normal Distribution
Let Z ∼ N (µ, σ2). How to compute Pr(Z = 5)?
Answer: For each x ∈ R holds Pr(Z = x) = 0
How about EZ =∑
a a · Pr(Z = a) ?
Needs a new definition:
EZ =
∫ ∞−∞
x · f (x)dx
But we already know the result EZ = µ.
12 / 52
The Normal Distribution
Let Z ∼ N (µ, σ2). How to compute Pr(Z = 5)?
Answer: For each x ∈ R holds Pr(Z = x) = 0
How about EZ =∑
a a · Pr(Z = a) ?
Needs a new definition:
EZ =
∫ ∞−∞
x · f (x)dx
But we already know the result EZ = µ.
12 / 52
The Normal Distribution
Let Z ∼ N (µ, σ2). How to compute Pr(Z = 5)?
Answer: For each x ∈ R holds Pr(Z = x) = 0
How about EZ =∑
a a · Pr(Z = a) ?
Needs a new definition:
EZ =
∫ ∞−∞
x · f (x)dx
But we already know the result EZ = µ.
12 / 52
The Normal Distribution
Let Z ∼ N (µ, σ2). How to compute Pr(Z = 5)?
Answer: For each x ∈ R holds Pr(Z = x) = 0
How about EZ =∑
a a · Pr(Z = a) ?
Needs a new definition:
EZ =
∫ ∞−∞
x · f (x)dx
But we already know the result EZ = µ.
12 / 52
The Normal Distribution
Let Z ∼ N (µ, σ2). How to compute Pr(Z = 5)?
Answer: For each x ∈ R holds Pr(Z = x) = 0
How about EZ =∑
a a · Pr(Z = a) ?
Needs a new definition:
EZ =
∫ ∞−∞
x · f (x)dx
But we already know the result EZ = µ.
12 / 52
Taking standard errors into account
Contents
1 The Normal Distribution
2 Taking standard errors into account
3 The t-Test for paired samplesExample: Orientation of pied flycatchers
13 / 52
Taking standard errors into account
Important consequence
Consider the intervalx − s/
√n x + s/
√n
x
14 / 52
Taking standard errors into account
Important consequence
x − s/√
n x + s/√
n
This interval contains µ with probabil-ity of ca. 2/3
x
14 / 52
Taking standard errors into account
Important consequence
x − s/√
n x + s/√
n
This interval contains µ with probabil-ity of ca. 2/3
probability that µ is outside of intervalis ca. 1/3
x
14 / 52
Taking standard errors into account
Thus:
It may happen that xdeviates from µ
by more thans/√
n.
15 / 52
Taking standard errors into account
Application 1:Which values of µ are plausible?
x = 0.12s/√
n = 0.007
Question: Could it be thatµ = 0.115?
16 / 52
Taking standard errors into account
Application 1:Which values of µ are plausible?
x = 0.12s/√
n = 0.007
Question: Could it be thatµ = 0.115?
16 / 52
Taking standard errors into account
Application 1:Which values of µ are plausible?
x = 0.12s/√
n = 0.007
Question: Could it be thatµ = 0.115?
16 / 52
Taking standard errors into account
Answer: Yes, not unlikely.
Deviationx − µ = 0.120− 0.115 = 0.005.
Standard Errors/√
n = 0.007
Deviations like thisare not unusual.
17 / 52
Taking standard errors into account
Answer: Yes, not unlikely.
Deviationx − µ = 0.120− 0.115 = 0.005.
Standard Errors/√
n = 0.007
Deviations like thisare not unusual.
17 / 52
Taking standard errors into account
Answer: Yes, not unlikely.
Deviationx − µ = 0.120− 0.115 = 0.005.
Standard Errors/√
n = 0.007
Deviations like thisare not unusual.
17 / 52
Taking standard errors into account
Answer: Yes, not unlikely.
Deviationx − µ = 0.120− 0.115 = 0.005.
Standard Errors/√
n = 0.007
Deviations like thisare not unusual.
17 / 52
Taking standard errors into account
Answer: Yes, not unlikely.
Deviationx − µ = 0.120− 0.115 = 0.005.
Standard Errors/√
n = 0.007
Deviations like thisare not unusual.
17 / 52
Taking standard errors into account
Application 2:Comparison of mean values
Example: Galathea
18 / 52
Taking standard errors into account
Application 2:Comparison of mean values
Example: Galathea
18 / 52
Taking standard errors into account
Galathea: Carapace lengthsin a sample
Males:x1 = 3.04 mms1 = 0.9 mm
n1 = 25
Females:x2 = 3.23 mms2 = 0.9 mm
n2 = 2919 / 52
Taking standard errors into account
The femalesare apparently larger.
Is this significant?
Or could it be just random?
20 / 52
Taking standard errors into account
The femalesare apparently larger.
Is this significant?
Or could it be just random?
20 / 52
Taking standard errors into account
The femalesare apparently larger.
Is this significant?
Or could it be just random?
20 / 52
Taking standard errors into account
How precisely do we know the true meanvalue?
Males:x1 = 3.04 mms1 = 0.9 mm
n1 = 25s1/√
n1 = 0.18 [mm]
We have to assume uncertainty in themagnitude of±0.18 (mm) in x1
21 / 52
Taking standard errors into account
How precisely do we know the true meanvalue?
Males:x1 = 3.04 mms1 = 0.9 mm
n1 = 25s1/√
n1 = 0.18 [mm]
We have to assume uncertainty in themagnitude of±0.18 (mm) in x1
21 / 52
Taking standard errors into account
How precisely do we know the true meanvalue?
Males:x1 = 3.04 mms1 = 0.9 mm
n1 = 25s1/√
n1 = 0.18 [mm]
We have to assume uncertainty in themagnitude of±0.18 (mm) in x1
21 / 52
Taking standard errors into account
How precisely do we know the true meanvalue?
Females:x2 = 3.23 mms2 = 0.9 mm
n2 = 29s2/√
n2 = 0.17 [mm]
It is not unlikelythat x2 deviates from the true mean by more
than ±0.17 (mm).
22 / 52
Taking standard errors into account
How precisely do we know the true meanvalue?
Females:x2 = 3.23 mms2 = 0.9 mm
n2 = 29s2/√
n2 = 0.17 [mm]
It is not unlikelythat x2 deviates from the true mean by more
than ±0.17 (mm).
22 / 52
Taking standard errors into account
How precisely do we know the true meanvalue?
Females:x2 = 3.23 mms2 = 0.9 mm
n2 = 29s2/√
n2 = 0.17 [mm]
It is not unlikelythat x2 deviates from the true mean by more
than ±0.17 (mm).22 / 52
Taking standard errors into account
The difference of the means
3.23− 3.04 = 0.19 [mm]
is not much larger thanthe expected inaccuracies.
It could also be due to pure randomthat
x2 > x1
23 / 52
Taking standard errors into account
The difference of the means
3.23− 3.04 = 0.19 [mm]
is not much larger thanthe expected inaccuracies.
It could also be due to pure randomthat
x2 > x1
23 / 52
Taking standard errors into account
The difference of the means
3.23− 3.04 = 0.19 [mm]
is not much larger thanthe expected inaccuracies.
It could also be due to pure randomthat
x2 > x1
23 / 52
Taking standard errors into account
MORE PRECISELY:
If the true meansare actually equalµFemales = µMales
it is still quite likely thatthe sample means
x2 are x1
that different.
24 / 52
Taking standard errors into account
MORE PRECISELY:
If the true meansare actually equalµFemales = µMales
it is still quite likely thatthe sample means
x2 are x1
that different.
24 / 52
Taking standard errors into account
In the language of statistics:
The differenceof the mean values
is(statistically)
not significant.
25 / 52
Taking standard errors into account
not significant
=
can be just random
26 / 52
Taking standard errors into account
Application 3:
If the mean valuesare represented graphically,
you should als showtheir precision
(±s/√
n)
27 / 52
Taking standard errors into account
Not Like this:Carapace lengths:
Mean values for males and females2.
62.
83.
03.
23.
4
Car
apac
e le
ngth
[mm
]
●
●
Males Females
28 / 52
Taking standard errors into account
Like that:Carapace lengths:
Mean values ± standard errors for males and females2.
62.
83.
03.
23.
4
Car
apac
e le
ngth
[mm
]
●
●
Males Females
28 / 52
Taking standard errors into account
Application 4:
Planning an experiment:
How many observationsdo I need?
(How large should n be?)
29 / 52
Taking standard errors into account
Application 4:
Planning an experiment:
How many observationsdo I need?
(How large should n be?)
29 / 52
Taking standard errors into account
If you know which precision you need for(the standard error s/
√n of)
x
and if you already have an idea of sthen you can estimate
the value of nthat is necessary:
s/√
n = g(g = desired standard error)
30 / 52
Taking standard errors into account
If you know which precision you need for(the standard error s/
√n of)
x
and if you already have an idea of s
then you can estimatethe value of n
that is necessary:s/√
n = g(g = desired standard error)
30 / 52
Taking standard errors into account
If you know which precision you need for(the standard error s/
√n of)
x
and if you already have an idea of sthen you can estimate
the value of nthat is necessary:
s/√
n = g(g = desired standard error)
30 / 52
Taking standard errors into account
Example:Stressed transpiration values
in another sorghum subspecies:x = 0.18s = 0.06n = 13
How often do we have to repeat theexperiment to
get a standard error of ≈ 0.01?
Which n do we need?
31 / 52
Taking standard errors into account
Example:Stressed transpiration values
in another sorghum subspecies:x = 0.18s = 0.06n = 13
How often do we have to repeat theexperiment to
get a standard error of ≈ 0.01?
Which n do we need?
31 / 52
Taking standard errors into account
Example:Stressed transpiration values
in another sorghum subspecies:x = 0.18s = 0.06n = 13
How often do we have to repeat theexperiment to
get a standard error of ≈ 0.01?
Which n do we need?31 / 52
Taking standard errors into account
Solution:
desired:s/√
n ≈ 0.01
From the previous experiment we know:
s ≈ 0.06,so:√
n ≈ 6n ≈ 36
32 / 52
Taking standard errors into account
Solution:
desired:s/√
n ≈ 0.01
From the previous experiment we know:
s ≈ 0.06,
so:√
n ≈ 6n ≈ 36
32 / 52
Taking standard errors into account
Solution:
desired:s/√
n ≈ 0.01
From the previous experiment we know:
s ≈ 0.06,so:√
n ≈ 6
n ≈ 36
32 / 52
Taking standard errors into account
Solution:
desired:s/√
n ≈ 0.01
From the previous experiment we know:
s ≈ 0.06,so:√
n ≈ 6n ≈ 36
32 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.
We draw a sample of size n from this population withsample mean x .x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .
x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .x is a random variable
with mean value µ and standard deviation σ/√
n.Estimate the standard deviation of x by s/
√n.
s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.
s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.s/√
n is the Standard Error (of the Mean).
Deviations of x of the magnitude of s/√
n are usual.They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
Taking standard errors into account
Summary
Assume a population has mean value µ and standarddeviation σ.We draw a sample of size n from this population withsample mean x .x is a random variablewith mean value µ and standard deviation σ/
√n.
Estimate the standard deviation of x by s/√
n.s/√
n is the Standard Error (of the Mean).Deviations of x of the magnitude of s/
√n are usual.
They are not significant: they can be random.
33 / 52
The t-Test for paired samples
Contents
1 The Normal Distribution
2 Taking standard errors into account
3 The t-Test for paired samplesExample: Orientation of pied flycatchers
34 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is A significantly different from B?
35 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is A significantly different from B?No: A is in 2/3 range of µB
35 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is B significantly different from C?
35 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is B significantly different from C?No: 2/3 ranges of µB and µC overlap
35 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is C significantly different from D?
35 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is C significantly different from D?We do not know yet.
35 / 52
The t-Test for paired samples
sample means ± standard errors
D
C
A
B
Is C significantly different from D?We do not know yet.(Answer will be “no”.)
35 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Contents
1 The Normal Distribution
2 Taking standard errors into account
3 The t-Test for paired samplesExample: Orientation of pied flycatchers
36 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Pied flycatchers (Ficedula hypoleuca)
http://en.wikipedia.org/wiki/File:Ficedula hypoleuca NRM.jpg
Foto (c) Simon Eugster
37 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Wiltschko, W.; Gesson, M.; Stapput, K.; Wiltschko, R.
Light-dependent magnetoreception in birds: interaction of at leasttwo different receptors.
Naturwissenschaften 91.3, pp. 130-4, 2004.
Wiltschko, R.; Ritz, T.; Stapput, K.; Thalau, P.;Wiltschko, W.
Two different types of light-dependentresponses to magnetic fields in birds.
Curr Biol 15.16, pp. 1518-23, 2005.
Wiltschko, R.; Stapput, K.; Bischof, H. J.;Wiltschko, W.
Light-dependent magnetoreception in birds:increasing intensity of monochromatic lightchanges the nature of the response.
Front Zool, 4, 2007.38 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
the more variable the directions the
shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Direction of flight with blue light.
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Direction of flight with blue light.Another flight of the same bird withblue light.
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
All flight’s directions of this bird inblue light.
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
All flight’s directions of this bird inblue light.
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
All flight’s directions of this bird inblue light.corresponding exit points
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Directions of this bird’s flights ingreen light.
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Directions of this bird’s flights ingreen light.corresponding exit points
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
corresponding exit pointsarrow heads: barycenter of exitpoints for green light
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
arrow heads: barycenter of exitpoints for green light
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
arrow heads: barycenter of exitpoints for green lightthe same for “blue” directions
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
arrow heads: barycenter of exitpoints for green lightthe same for “blue” directions
the more variable the directions the shorter the arrows!
39 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Question of interest
Does the color of monochromatic lightinfluence the orientation?
Experiment: For 17 birds comparebarycenter vector lengths for blue and green
light.
40 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Question of interest
Does the color of monochromatic lightinfluence the orientation?
Experiment: For 17 birds comparebarycenter vector lengths for blue and green
light.
40 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Pies flycathchers :barycenter vector lengths for
green light and for blue light b, n=17
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
0.0 0.1 0.2 0.3 0.4 0.5
0.0
0.1
0.2
0.3
0.4
0.5
with blue light
with
gre
en li
ght
41 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Compute for each bird the distance to thediagonal,
i.e.
x := “green length”− “blue length”
−0.05 0.00 0.05 0.10 0.15 0.20
42 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Compute for each bird the distance to thediagonal,
i.e.
x := “green length”− “blue length”
−0.05 0.00 0.05 0.10 0.15 0.20
42 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Compute for each bird the distance to thediagonal,
i.e.
x := “green length”− “blue length”
−0.05 0.00 0.05 0.10 0.15 0.20
42 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518s = 0.0912
SEM =s√n
=0.912√
17= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518
s = 0.0912
SEM =s√n
=0.912√
17= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518s = 0.0912
SEM =s√n
=0.912√
17= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518s = 0.0912
SEM =s√n
=0.912√
17= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518s = 0.0912
SEM =s√n
=0.912√
17
= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518s = 0.0912
SEM =s√n
=0.912√
17= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
−0.05 0.00 0.05 0.10 0.15 0.20
Can the theoretical mean be µ = 0? (i.e. the expectation valuefor a randomly chosen bird)
x = 0.0518s = 0.0912
SEM =s√n
=0.912√
17= 0.022
43 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Is |x − µ| ≈ 0.0518 a large deviation?
Large? Large compared to what?
Large compared the the standard error?
44 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Is |x − µ| ≈ 0.0518 a large deviation?
Large?
Large compared to what?
Large compared the the standard error?
44 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Is |x − µ| ≈ 0.0518 a large deviation?
Large? Large compared to what?
Large compared the the standard error?
44 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Is |x − µ| ≈ 0.0518 a large deviation?
Large? Large compared to what?
Large compared the the standard error?
44 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
|x − µ|s/√
n≈ 0.0518
0.022≈ 2.34
So, x is more than 2.3 standard deviations away from µ = 0.
How probable is this when 0 is the true theoretical mean? in
other words:
Is this deviation significant?
45 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
|x − µ|s/√
n≈ 0.0518
0.022≈ 2.34
So, x is more than 2.3 standard deviations away from µ = 0.
How probable is this when 0 is the true theoretical mean? in
other words:
Is this deviation significant?
45 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
|x − µ|s/√
n≈ 0.0518
0.022≈ 2.34
So, x is more than 2.3 standard deviations away from µ = 0.
How probable is this when 0 is the true theoretical mean?
in
other words:
Is this deviation significant?
45 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
|x − µ|s/√
n≈ 0.0518
0.022≈ 2.34
So, x is more than 2.3 standard deviations away from µ = 0.
How probable is this when 0 is the true theoretical mean? in
other words:
Is this deviation significant?
45 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We know:x − µσ/√
n
is asymptotically (for large n) standard-normally distributed.
σ is the theoretical standard deviation, but we do not know it.Instead of σ we use the sample standard deviation s. We haveapplied the “2/3 rule of thumb” which is based on the normaldistribution.For questions about the significance this approximation is tooimprecise if σ is replaced by s (and n is not extremely large).
46 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We know:x − µσ/√
n
is asymptotically (for large n) standard-normally distributed.σ is the theoretical standard deviation, but we do not know it.
Instead of σ we use the sample standard deviation s. We haveapplied the “2/3 rule of thumb” which is based on the normaldistribution.For questions about the significance this approximation is tooimprecise if σ is replaced by s (and n is not extremely large).
46 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We know:x − µσ/√
n
is asymptotically (for large n) standard-normally distributed.σ is the theoretical standard deviation, but we do not know it.Instead of σ we use the sample standard deviation s.
We haveapplied the “2/3 rule of thumb” which is based on the normaldistribution.For questions about the significance this approximation is tooimprecise if σ is replaced by s (and n is not extremely large).
46 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We know:x − µσ/√
n
is asymptotically (for large n) standard-normally distributed.σ is the theoretical standard deviation, but we do not know it.Instead of σ we use the sample standard deviation s. We haveapplied the “2/3 rule of thumb” which is based on the normaldistribution.
For questions about the significance this approximation is tooimprecise if σ is replaced by s (and n is not extremely large).
46 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We know:x − µσ/√
n
is asymptotically (for large n) standard-normally distributed.σ is the theoretical standard deviation, but we do not know it.Instead of σ we use the sample standard deviation s. We haveapplied the “2/3 rule of thumb” which is based on the normaldistribution.For questions about the significance this approximation is tooimprecise if σ is replaced by s (and n is not extremely large).
46 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
General RuleIf X1, . . . ,Xn are independently drawn from a normal distributedwith mean µ and
s2 =1
n − 1
n∑i=1
(Xi − X )2,
thenX − µs/√
n
is t-distributed with n − 1 degrees of freedom (df).
The t-distribution is also called Student-distribution, sinceGosset published it using this synonym.
47 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
General RuleIf X1, . . . ,Xn are independently drawn from a normal distributedwith mean µ and
s2 =1
n − 1
n∑i=1
(Xi − X )2,
thenX − µs/√
n
is t-distributed with n − 1 degrees of freedom (df).
The t-distribution is also called Student-distribution, sinceGosset published it using this synonym.
47 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Density of the t-distribution
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
dens
ity
Density of t-distribution with 16 df
48 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Density of the t-distribution
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
dens
ity
Density of t-distribution with 16 dfDensity of standard normal distribution
48 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Density of the t-distribution
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
dens
ity
Density of t-distribution with 16 dfDensity of standard normal distribution µ = 0 and σ2 = 16
14
48 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
Density of the t-distribution
−4 −2 0 2 4
0.0
0.1
0.2
0.3
dens
ity
Density of t-distribution with 5 dfDensity of normal distribution with µ = 0 and σ2 = 5
3
48 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
How (im)probable is a deviation by
at least
2.35 standard errors?
Pr(T = 2.34) =
0 does not help!
Compute Pr(T ≥ 2.34), the so-called p-value.
2.34−2.34
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
de
nsity The total area of the
magenta-colored regionsis the p-value.
49 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
How (im)probable is a deviation by
at least
2.35 standard errors?
Pr(T = 2.34) = 0
does not help!
Compute Pr(T ≥ 2.34), the so-called p-value.
2.34−2.34
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
de
nsity The total area of the
magenta-colored regionsis the p-value.
49 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
How (im)probable is a deviation by at least2.35 standard errors?
Pr(T = 2.34) = 0 does not help!
Compute Pr(T ≥ 2.34), the so-called p-value.
2.34−2.34
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
de
nsity The total area of the
magenta-colored regionsis the p-value.
49 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
How (im)probable is a deviation by at least2.35 standard errors?
Pr(T = 2.34) = 0 does not help!
Compute Pr(T ≥ 2.34), the so-called p-value.
2.34−2.34
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
de
nsity
The total area of themagenta-colored regionsis the p-value.
49 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
How (im)probable is a deviation by at least2.35 standard errors?
Pr(T = 2.34) = 0 does not help!
Compute Pr(T ≥ 2.34), the so-called p-value.
2.34−2.34
−4 −2 0 2 4
0.0
0.1
0.2
0.3
0.4
de
nsity The total area of the
magenta-colored regionsis the p-value.
49 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
R does that for us:
> pt(-2.34,df=16)+pt(2.34,df=16,lower.tail=FALSE)
[1] 0.03257345
Comparison with normal distribution:
> pnorm(-2.34)+pnorm(2.34,lower.tail=FALSE)
[1] 0.01928374
> pnorm(-2.34,sd=16/14)+
+ pnorm(2.34,sd=16/14,lower.tail=FALSE)
[1] 0.04060902
50 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
R does that for us:
> pt(-2.34,df=16)+pt(2.34,df=16,lower.tail=FALSE)
[1] 0.03257345
Comparison with normal distribution:
> pnorm(-2.34)+pnorm(2.34,lower.tail=FALSE)
[1] 0.01928374
> pnorm(-2.34,sd=16/14)+
+ pnorm(2.34,sd=16/14,lower.tail=FALSE)
[1] 0.04060902
50 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
t-Test with R
> x <- length$green-length$blue
> t.test(x)
One Sample t-test
data: x
t = 2.3405, df = 16, p-value = 0.03254
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
0.004879627 0.098649784
sample estimates:
mean of x
0.05176471
51 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We note:p −Wert = 0.03254
i.e.: If the Null hypothesis “just random”, in our case µ = 0holds, any deviation like the observed one or even more is veryimprobable.If we always reject the null hypothesis if and only if the p-value isbelow a level of significance of 0.05, then we can say followingholds:If the null hypothesis holds, then the probability that we reject it,is only 0.05.
52 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We note:p −Wert = 0.03254
i.e.: If the Null hypothesis “just random”, in our case µ = 0holds, any deviation like the observed one or even more is veryimprobable.
If we always reject the null hypothesis if and only if the p-value isbelow a level of significance of 0.05, then we can say followingholds:If the null hypothesis holds, then the probability that we reject it,is only 0.05.
52 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We note:p −Wert = 0.03254
i.e.: If the Null hypothesis “just random”, in our case µ = 0holds, any deviation like the observed one or even more is veryimprobable.If we always reject the null hypothesis if and only if the p-value isbelow a level of significance of 0.05, then we can say followingholds:
If the null hypothesis holds, then the probability that we reject it,is only 0.05.
52 / 52
The t-Test for paired samples Example: Orientation of pied flycatchers
We note:p −Wert = 0.03254
i.e.: If the Null hypothesis “just random”, in our case µ = 0holds, any deviation like the observed one or even more is veryimprobable.If we always reject the null hypothesis if and only if the p-value isbelow a level of significance of 0.05, then we can say followingholds:If the null hypothesis holds, then the probability that we reject it,is only 0.05.
52 / 52