Professional Documents
Culture Documents
Lecture 6
October 7, 2014
Robert Dahl Jacobsen
robert@math.aau.dk
Department of Mathematical Sciences
Aalborg University
Agenda
Estimation
Two means
Likelihoods
Matlab
Statistics in a nutshell
Model:
Xi N(, 2 )
Estimation:
b = x,
b2 = s2
= 0 ,
2 = 02
Hypothesis test:
Estimation
population:
I
I
sample: b
estimate
estimator
x
s2
X
S2
Unbiased estimate
I
Unbiased estimator:
b =
E()
Example:
Xi N(, 2 ),
X =
S2 =
1
n1
1
n
n
X
i=1
i = 1, . . . , n
2
Xi N ,
n
n
X
(Xi X )2
i=1
2 2
(n 1)
n1
Then:
X and S 2 are independent
E(X ) =
E(S 2 ) = 2
Confidence interval
Repeat 10 times:
I
I
Questions:
I
I
Sample:
Xi N(, 2 ),
i = 1, . . . , n
Notation:
z = fractile of N(0, 1)
2
X N ,
n
x + z/2 x + z1/2
n
n
Shorthand:
x z/2
n
2
10
x 20
Confidence intervals
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1
10 11 12 13 14 15 16 17 18 19 20
Chocolate bars
In a sample of 20 chocolate bars the amount of calories has been
measured. We have:
I
Calculate 90% and 95% confidence intervals for the mean. Which
one is larger?
Solutions:
10
[220.3; 227.7].
90% confidence interval: 224 1.64
20
10
[219.6; 228.4].
95% confidence interval: 224 1.96
20
Sample:
Xi N(, 2 ),
i = 1, . . . , n
Notation:
t = fractile of t(n 1)
n
s2 =
1X
(xi x)2
n
k =1
Note: t < z
10
Normal or t distribution?
11
Situation 2
Estimate:
Estimate:
mean = x,
I
variance = s2
Use
I
I
mean = x
I
Use
I
12
10
[220.1; 227.9].
90% confidence interval: 224 1.73
20
10
95% confidence interval: 224 2.1
[219.3; 228.7].
20
Sample:
Xi N(, 2 ),
i = 1, . . . , n
Notation:
n
s2 =
1 X
(xi x)2
n1
k =1
(n 1)S 2
2 (n 1)
2
2,n1 = fractile of 2 (n 1)
I
13
Solutions:
h
i
2
19102
[63.0; 187.8]
90% confidence interval: 1910
30.1 ; 10.1
h
i
19102 19102
95% confidence interval: 32.9 ; 8.9 [57.8; 213.3]
Difference in means
Known variances
15
Two populations:
X1,i N(1 , 12 )
X2,i N(2 , 22 )
Two samples:
x1,1 , x1,2 , . . . , x1,n1
x2,1 , x2,2 , . . . , x2,n2
Estimate of 1 2 :
x1 x2 =
n1
n2
1 X
1 X
x1,i
x2,i
n1
n2
i=1
i=1
Confidence interval:
s
s
12
22
12
2
(x 1 x 2 )+z/2
+
1 2 (x 1 x 2 )+z1/2
+ 2
n1
n2
n1
n2
Degrees of freedom: = n1 + n2 2
Confidence interval:
s
(x 1 x 2 ) + t/2, sp
1
1
+
1 2
n1
n2
s
(x 1 x 2 ) + t1/2, sp
1
1
+
n1
n2
Degrees of freedom:
=
s22 /n2
n2 1
Confidence interval:
s
s
s12
s22
s12
s2
(x 1 x 2 )+t/2,
+
1 2 (x 1 x 2 )+t1/2,
+ 2
n1
n2
n1
n2
18
0.3
0.2
0.1
0.2
0.4
0.6
0.8
18
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood, contd
19
p 7 b(3; 10, p)
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood, contd
19
p 7 b(6; 20, p)
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood, contd
19
p 7 b(9; 30, p)
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood, contd
19
p 7 b(12; 40, p)
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood, contd
19
p 7 b(15; 50, p)
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood, contd
19
p 7 b(18; 60, p)
0.3
0.2
0.1
0.2
0.4
0.6
0.8
Likelihood function
The general approach
20
Notice:
Density: (x1 , x2 , . . . , xn ) 7 f (x1 , x2 , . . . , xn ; ) ( fixed)
Likelihood: 7 f (x1 , x2 , . . . , xn ; ) (data fixed)
Likelihood function
21
I
I
n
Y
i=1
f (xi ; )
I
I
I
L(; x1 , x2 , . . . , xn ) =
f (xi ; ) =
exp
2
2 2
2
i=1
i=1
n
1 X
1
2
=
exp
(x
)
i
2 2
(2 2 )n/2
i=1
Log-likelihood function:
n
n
n
1 X
l(; x1 , x2 , . . . , xn ) = log(2) log( 2 )
(xi )2
2
2
2 2
i=1
= x,
2 =
1X
(xi x)2 6= s2
n
i=1
Good vs Best
23
MLE gives the best parameter within the chosen model class.
Good vs Best
23
MLE gives the best parameter within the chosen model class.
Matlab
24