Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Week 8
Week 2
Week 3
Week 4
Probability:
Week 6
Review
Estimation: Week 5
Week
7
Week
9
Hypothesis testing:
Week
10
Week
11
Week 12
Linear regression:
Week 2 VL
Week 3 VL
Week 4 VL
Video lectures: Week 1 VL
Week 1
Week 5 VL
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
- Statistical tests;
- Rejection region;
Neyman-Pearson Lemma;
Uniformly most powerful;
Likelihood ratio test.
- Value of test;
- Accept the null or reject the null hypothesis.
L(x; b0 )
<k
b
L(x; )
s.t.: Pr (X C ? |H0 ) = .
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
H1 : = 1 > 0 .
v.s.
=
2205/2250
n
1X
exp
2
k=1
xk
2 !
.
b=x
and
1X
(xk x)2 .
b =
n
2
k=1
e = 0
and
e2 =
1X
(xk 0 )2 ,
n
k=1
2206/2250
n
n
2
P
(xk 0 )
1
exp 12
n
P
2e
(xk 0 )2
k=1 n
2207/2250
1
2b
n
Pn
k=1
n
1 P
exp 2
k=1
1
n
(xk x)
n
P
(xk x)2
k=1
n/2
2 k=1 (xk 0 )2
e n/2
<k
P
n/2
n
2
n/2
2 k=1 (xk x)
e
Pn
(xk x)2
< k1
(= k 2/n ).
Pnk=1
2
(x
)
0
k=1 k
Simplifying, we have:
=
(xk x)2
Pn
+ (x 0 ))2
Pn
2
k=1 (xk x)
= Pn
Pn
Pn
2
2
x) (x ))
k=1 (xk x) +
k=1 (x 0 ) + 2
k=1 ( (x
| k {z } | {z 0}
k=1 ((xk x)
=nxnx=0
Pn
=
Pn
x)
x) + n (x 0 )2
1
.
< k1
2 Pn
2
1 + n (x 0 )
k=1 (xk x)
n (x 0 )2
k2
n
P
(xk x)2
k=1 (xk
k=1
2208/2250
k=1 (xk
2
constant
(=
1
1 ).
k
| 1{z }
decreasing
* using s 2 =
Pn
2
k=1 (xk x)
n1
n1
= k2
n
p
(= k3 )
k
H0 = .
S
2209/2250
Pn
=
T .
(n 1) = |{z}
2
S
n / n
n
| {z } |
t(n1)
{z
}
We have: X =
i=1 Xi /n|H0
=Z
2 (n1)
(n1)
X 0
?
Pr
k H0 =
S
Pr |T | n k ? =
Pr |T | t1/2,n1 =
Thus:
n k?
n
Hence: C ? = (X1 , . . . , Xn ) : t1/2,n1
2210/2250
x
0
s/ n
k ? =t1/2,n1 / n.
o
t1/2,n1 .
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
(Type I
error) is the
blue shaded
area.
f(x|H1)
(Type II
error) is the
green
shaded area.
2212/2250
(1 )
(power) is
the purple
shaded area.
Type I error
2213/2250
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
2215/2250
() = Pr ((X1 , X2 , . . . , Xn ) C | H1 )
= Pr X > 2| H1
= Pr X > 2| H1 + Pr X < 2| H1
= Pr Z > n (2 ) + Pr Z < n (2 )
= n (2 ) + n (2 ) .
P
2
* using X = ni=1 Xi /n N(, n ) (using m.g.f. technique).
= Pr n X > 2 n + Pr n X < 2 n
= Pr Z > 2 n + Pr Z < 2 n
= 2 2 n .
* using X |H0 =
2216/2250
Pn
i=1 Xi /n
N(0, n1 ).
= Pr 3 n X 1 n n = 1
= Pr 3 n Z n
= n 1 3 n = n + 3 n 1.
The complement, 1 , gives the power of the test when = 1.
* using X |H1 N(1, 1/n).
2217/2250
Exercise power
We have X N(, 1).
Test: H0 : = 0 v.s. H1 : > 0 .
2218/2250
=1 z1 +
.
/ n
Power function
1
When n
increases
the power of
the test is
higher, i.e.,
more likely
to reject H0
if H1 is
correct.
2219/2250
n=20
n=100
v.s.
H1 : p > 0.5,
with = 0.05. SOI> 10 in 50, 55, 71, 73, 75, 88, 10.
Question: What is the test statistic? Solution: Number of
successes X Bin(n, p).
Question: What is the rejection region? Solution: large
values of X , i.e., C = {8, 9, 10}, we then have
Pr (reject H0 when true) = = 0.0547, C ? = {9, 10}:
Pr (X C ? |p = 0.5) = = 0.0107.
2221/2250
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
p-value
When the rejection region is of the form T > t (or T < t)
then t is called the critical value of the test (independent of
data).
The p-value is the smallest value of for which the null
hypothesis, given the data, will be rejected.
Note: p-value and critical value are both obtained using the
test statistic. However, critical value is computed given ,
whereas p-value is calculated by determining the probability
that the sample occurs given the null hypothesis (i.e., the
inverse).
- In case that the p-value is smaller than the level of significance
reject null.
- In case that the p-value is larger than the level of significance
accept null.
2222/2250
Example: p-value
(Continued from slide 2215) Suppose X1 , X2 , . . . , Xn is a
random sample from N (, 1) and that we wish to test
H0 : = 0 versus H1 : 6= 0 with constant as level of
significance.
Suppose the observed sample mean X turned out to be 3, we
can calculate the p-value:
p-value = Pr X 3 | = 0
= Pr X 3 | = 0 + Pr X 3 | = 0
= Pr Z 3 n + Pr Z 3 n
= 2 3 n
which is smaller than the level of significance (check this).
This implies that you would reject the null hypothesis H0 .
2223/2250
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
x < 0 z/2
or
x > 0 + z/2 n .
n
This test clearly has size , because:
Pr X z1/2 n < 0 < X + z1/2 n H0 = 1,
or, equivalently,
Pr
2224/2250
X 0
< z1/2 |H0
/ n
+ Pr
X 0
> z1/2 |H0
/ n
= ,
x 0
< z1/2 ,
/ n
or
x z1/2
< 0 < x + z1/2
,
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
k-sample tests
Suppose that k independent random samples N(j , j2 ) are
obtained with sample size nj , j = 1, . . . , k.
We denote xij the observed value of the i th random variable,
from j th random sample. Moreover, denote N = n1 + . . . + nk :
xj
nj
P
xij
nj
i=1
nj
k P
P
j=1i=1
sj2 =
xij
N
k
P
nj x j
j=1
s2 =
nj
P
(xij x j )2
nj 1
i=1
n
j
k P
P
(xij x j )2
N1
j=1i=1
2227/2250
k-sample tests
We use GLR. Need to find the ratio of the likelihood functions
and thus the ML- estimates in restricted and unrestricted
case. Note: in unrestricted case we still have l2 = 2 for
l = 1, . . . , k.
Likelihood function:
nj
k Y
Y
(xij j )2
1
exp
L(x; 1 , . . . , k , ) =
2 2
2
j=1 i=1
nj
k X
X
1
=(2 2 )N/2 exp 2
(xij j )2
2
2
j=1 i=1
nj
1 XX
N
log(2 2 ) 2
log L =
(xij j )2
2
2
j=1 i=1
2228/2250
Parameter space
= {(1 , . . . , k , 2 )| < j < , 2 > 0}
log L
j
log L
2
bj =
nj
X
xij /nj = x j
nj
k X
X
b =
(xij x j )2 /N
2
j=1 i=1
i=1
log L
log L
2
b0 =
2229/2250
nj x j /N = x
b02
nj
k X
X
j=1 i=1
(xij x)2 /N
b0
(2b
=
=
<k
N/2
2
b2
(2b
)
exp (N/2)
Pk Pnj
2
b02
j=1
i=1 (xij x)
2 = Pk Pnj
k1
(= k 2/N )
2
b
x
(x
)
j
j=1
i=1 ij
Pk
Pk
2
2
j=1 nj (x j x)
j=1 nj (x j x)
=1 + Pk Pnj
k1
k ?.
Pk Pnj
2
2
j=1
j=1
i=1 (xij x j )
i=1 (xij x j )
b0 ,
b02 )
L(x;
2230/2250
j=1 i=1
j=1
k)s
(x
x
)
p
j
j=1
i=1 ij
- V1 =
- V2 =
Pk
Pj=1
k
Pkj=1
j=1
Pnj
Pi=1
nj
where
i=1 (xij
x j )2 / 2 2 (N k),
nj (x j x)2 / 2 2 (k 1).
using (1): V1 = V2 + V3 , thus V3 2 ((N 1) (N k)) = 2 (k 1).
- V3 =
Define F =
thus:
2231/2250
k?
V3 /(k1)
V2 /(Nk)
F (k 1, N k)
= F1 (k 1, N k)
(k1)
(Nk) .
Analysis of variance
k-sample test: testing the effect of k different experimental
treatments.
Example: Are the mean claim sizes in different countries
equivalent.
We will see this also in Linear Regression.
Rational of the name Analysis of variance: recall (1):
nj
k X
X
(xij x)2 =
j=1 i=1
nj
k X
X
(xij x j )2 +
j=1 i=1
{z
SST
k
X
nj (x j x)2
j=1
{z
SSW
{z
SSB
where
2232/2250
1
0.11
0.46
0.71
1.45
1
A
2.73
2.8303
2
0.52
1.43
1.84
2.47
2
B
6.26
11.8018
3
1.48
2.05
2.38
3.31
3
C
9.22
23.0134
4
1.52
2.36
2.95
4.08
4
D
10.91
33.2289
total
29.12
70.8744
2234/2250
SSB/(k 1)
9.6709/3
=
= 4.715
SSW /(N k)
8.2051/12
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
b2
bX2 + 4X
2 (2), reject H0 if
Test statistic: JB = n6
2235/2250
JB > 21 (2).
Y n
Z
/ n
!
n
1 X
Yi
n
n
1 X
Yi
n
!
n
N(0, 2 )
i=1
N(0, )
i=1
E[Y ] g (X ),
2236/2250
4. Use n6
bX2 Z 2 2 ,
n 2
bX
24
Z 2 2 hence JB 2 (2)
x)
(x
i
i
i
i
i=1
= n
bX n P
3/2
n
1
1P
2 3/2
x)
xi2 2xxi + x 2
(x
i=1 i
n
n
=
m3 3m12 m2 + 2m13
= g (m1 , m2 , m3 )
3/2
m2 m12
2. Note,
under H0 we have E[[m1 m2 m3 ]> ] = [0 1 0]> . Hence
xi
xi xi
xi (xi2 1)
xi xi3
=E xi2 1 xi xi2 1 xi3 = E (xi2 1)xi (xi2 1)(xi2 1) (xi2 1)xi3
xi3
xi3 xi3
xi3 xi
xi3 (xi2 1)
xi3 xi
xi4
1 0 3
xi2
3
4
2
5
=E xi xi xi 2xi + 1 xi xi3 = 0 2 0
xi4
xi5 xi3
xi6
3 0 15
2237/2250
g (m1 , m2 , m3 )/m1
g (m1 , m2 , m3 ) = g (m1 , m2 , m3 )/m2
g (m1 , m2 , m3 )/m3
4. Note:
bX and
bX are independent (using delta method).
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
2240/2250
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
Application
OPTIONAL
Consider the case in which an health insurer has two types of
insured, young individuals and old individuals.
You observe the age, you know the proportion of your
portfolio in young/old and you observe the total number of
claims each month.
You can approximate the number of claims by a Binomial
distribution (why?).
Question: Can you test wether the probability of issuing a
claim for young individuals is smaller than for old individuals?
Notation: X Bin(n1 , p1 ) the number of claims for young
individuals, Y Bin(n2 , p2 ) the number of claims for old
individuals, and S = X + Y the total number of claims.
2241/2250
fY |S (y ) =
2242/2250
n1
n2
sy y
n1 +n2
s
2243/2250
P
Exercise: (OPTIONAL) Let Xi N(, ) and S = ni=1 Xi
is sufficient if 2 is known. Test H0 : 0 v.s. H1 : < 0 ,
when n = 2.
Note: can do for general n, but becomes messy.
fX (x) = (2 )
2. The density of S =
Pn
i=1 Xi
Pn
2
i=1 (xi )
exp
2
under H0 is S N(n , n 2 ).
3. The density
Pof Xn |S = s under H0 is equal to
Xn = S n1
i=1 Xi |S = s:
fS,X1 ,...,Xn1 (s, x1 , . . . , xn1 )
fS (s)
P
fX1 ,...,Xn (x1 , . . . , xn1 , s n1
i=1 xi )
=
fS (s)
P
Pn1
n1
2
2
2
n/2
i=1 (xi ) +(s i=1 xi )
(2 )
exp
2
=
2
(2 n 2 )1/2 exp (sn)
n 2
2244/2250
Consider n = 2 we have:
)
x
)
i
i
i=1
exp
i=1
n 2
2
(x1 s/2)2
2
1/2
=(2 /n)
exp
2 2
* use: (x1 )2 + (s x1 )2 (s 2)2 /2 = (x12 + 2 2x1 )
+ ((s x1 )2 + 2 2(s x1 )) s 2 /2 22 + 2(x1 + x2 )
=x12 + (s x1 )2 s 2 /2
=2x12 + s 2 /2 2sx1 = (2x1 s) (x1 s/2) = 2(x1 s/2)2
Notice, this is the p.d.f. of N(s/2, 2 /2).
2245/2250
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
Introduction
Sometimes, we have a test which does not allow for pivots or
conditions.
Sometimes, we only have approximate test what if n is
small? Example: Jarque-Bera when n < 200.
Use bootstrap tests.
Idea:
1.
2.
3.
4.
Define H0 and H1 ;
Create a statistic T , based on H0 and H1 ;
Determine T ? based on the sample.
Simulate m times from H0 (m is large), calculate Tj for
j = 1, . . . , m.
5. Calculate the probability that T ? < Tj , use that for critical
region.
2246/2250
T (x) =
n
X
emp. quantile
FX (x(i) )
2247/2250
Bootstrap tests
Advantages:
- Allows a wider variety of tests (i.e., does not require test
statistic);
- Is exact, i.e., no approximations made.
Disadvantages:
- Time consuming (programming/ computer time);
- Depends on simulations: how many/how exact (quantifiable
using non-parametric hypothesis test: see week 9);
- More complicated to find the power of the test.
2249/2250
Hypothesis testing
Hypothesis testing
Overview
Exercise: testing a mean, variance unknown
Properties of hypothesis testing
Type I and Type II Errors, power of a test
Example: type I and II errors and power
p-value
Relation between Confidence intervals and hypothesis tests
Other tests
k-Sample tests
Jarque-Bera test
Other testing methods
Introduction
Conditional tests
Bootstrap tests
Summary
Summary
Summary
Type I error: Pr (Reject H0 |H0 is true) = .
Type II error: Pr (Do not reject H0 |H1 is true) = .
Power: = 1 = Pr (Do reject H0 |H1 is true).
p-value: For any level of significance less than the p-value
you would accept the null hypothesis.
k-sample test: k independent normal distributed samples,
test whether means are all equal: Use F -statistic.
Jarque-Bera test: Test whether a distribution is normally
distributed (more accurate: is symmetric (skewness = 0) and
excess kurtosis equals zero).
Other testing methods: Conditional tests (using sufficient
statistics) & Bootstrap tests.
2250/2250