Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Practice Exam Solutions

Solution to Problem 1

(a) Let 6 = "Roll 6", F = "Die is fair" and L = "Die is loaded". Then

P( L) P(6 | L) (1 / 2)(1 / 2)
P( L | 6) = 3/4 = 0.75 .
P( L) P(6 | L) P( F ) P(6 | F ) (1 / 2)(1 / 2) (1 / 2)(1 / 6)

(b) Let 6 = "Roll 6", F = "Die is fair", L = "Die is loaded", Q = {p = 1/4} and N = {p = 1/5}
(where Q stands for "one Quarter" and N standing for "Not one quarter"). Then

1 1 1 1
P(QL6) P(Q ) P( L | Q ) P(6 | QL)
2 3 4 24
1 1 1 1
and P( NL6) P ( N ) P ( L | N ) P (6 | NL)
2 3 5 30
1 1 3
P( L6) P (QL6) P ( NL6)
24 30 40

1 1 1 1 9
Also, P(6 | L) P (Q | L) P (6 | QL) P ( N | L) P (6 | NL) (see the Note below)
2 4 2 5 40
1 9 2 1 3 1 67
P(6) P( L) P (6 | L) P ( F ) P (6 | F ) .
3 40 3 6 40 9 360

P( L6) 3 / 40
It follows that P( L | 6) = 27/67 = 0.4030 .
P(6) 67 / 360

Check: P( L | 6) > P( L) = 1/3, which makes sense because 6 coming up should increase the chance
that the die is loaded.

Note: If we knew we had chosen the loaded die, this information would not have altered our beliefs
regarding whether p = 1/4 or p = 1/5. Hence P (Q | L) P(Q ) 1 / 2 and P ( N | L) P ( N ) 1 / 2 .

1 2 1 1 1
Next: P(QF 6) P(Q ) P( F | Q ) P(6 | QF ) and P (QL6) from earlier
2 3 6 18 24
1 1 7
P(Q 6) P(QL6) P(QF 6) .
24 18 72

P(Q 6) 7 / 72
It follows that P(Q | 6) = 35/67 = 0.5224 .
P(6) 67 / 360

Check: P(Q | 6) P (Q ) 1 / 2 , which makes sense because 6 coming up should increase the
probability of p being large (i.e. 1/4 relative to 1/5).

Page 1
Alternative workings for part (b):

2 1 1 1 7
[1] Observe that P(6 | Q ) P ( F | Q ) P (6 | FQ ) P ( L | Q ) P (6 | LQ )
3 6 3 4 36
P(Q ) P(6 | Q ) (1 / 2) (7 / 36) 7 / 72
P(Q | 6) .
P(6) P(6) P(6)

2 1 1 1 8
Likewise, P(6 | N ) P ( F | N ) P (6 | FN ) P ( L | N ) P (6 | LN )
3 6 3 5 45
P( N ) P(6 | N ) (1 / 2) (8 / 45) 4 / 45
P( N | 6) .
P(6) P(6) P (6)

P(Q | 6) 7 / 72 7 45
It follows that P(Q | 6) = 35/67.
P(Q | 6) P( N | 6) (7 / 72) (4 / 45) 7 45 4 72

Note: This working avoids the need to find P (6) , which cancels out conveniently in the last line.

P( L | p ) P(6 | L, p ) (1 / 3) p 3p
[2] P( L | 6, p ) (1)
P( L | p ) P(6 | L, p ) P( F | p ) P(6 | F , p ) (1 / 3) p (2 / 3)(1 / 6) 3p 1

3p 3(1 / 4) 1 3(1 / 5) 1
P( L | 6) E P ( L | 6, p ) 6 E 6 P p 6 P p 6 . (2)
3p 1 3(1 / 4) 1 4 3(1 / 5) 1 5

3 3
Thus, P( L | 6) P(Q | 6) (1 P(Q | 6)) .
7 8
56 56 27 35
So, using the result for P( L | 6) , we have that P (Q | 6) 7 P ( L | 6) 7 .
3 3 67 67

P( L) P(6 | L)
Note 1: Equation (1) follows from P( L | 6) after conditioning on p.
P( L) P(6 | L) P( F ) P(6 | F )

Note 2: Equation (2) follows from EL EE ( L | p ) after conditioning throughout on the event "6".

Page 2
Solution to Problem 2

(a) We are considering a sample of n values, Y1 ,..., Yn ~ iid U (0,1) , each of which has mean
2 n
EYi 0.5 and variance VYi 1 / 12 , and the average of these values, Y i 1 Yi / n .

We wish to find the integer value of n which most closely satisfies


P (| Y 0.5 | 0.06) 0.95 .

2
Now, by the central limit theorem, Y ~ N ( , / n ) . So we write
Y 0.06
0.95 P P (| Z | 0.06 12n ) , where Z ~ N (0,1) .
/ n 1 / 12n

(1.96 / 0.06) 2
But P(| Z | 1.96) 0.95 . So we equate 0.06 12n 1.96 to get n = 88.926.
12

Rounding 88.926 to the nearest integer yields the required number, 89 .

(b) We wish to find the smallest integer value of n which satisfies


P(| Y 0.5 | 0.06) 0.95 .

2
Now, Y has mean and variance / n . So, by Chebyshev's inequality,
1
P |Y | k 1 .
n k2

k 1 k2 2 20 1 / 12
Setting 0.06 and 1 0.95 , we get n = 462.963.
n k2 0.062 0.0036

Rounding 462.963 up to the nearest integer yields the required number, 463 .

R Code for Problem 2

c( (1.96/0.06)^2/12, 20*(1/12)/0.06^2 ) # 88.92593 462.96296

Page 3
Solution to Problem 3

(a) Let Y be the number of tosses. Then

py f ( y) P(Y y) P( H ) P (Y y | H ) P (T ) P(Y y |T)

1 1
P( y 2 tails and then heads | H ) P(Y 1 y ) (consider y = 5, for example)
2 2

( y 2) 1
1 1 1
P(Y y 1) .
2 2 2

y
1 1
So p y py 1 for y = 2, 3, 4, …
2 2

Now p2 P( HT ) = 1/4 and p3 P(THT ) P ( HHT ) 1 / 8 1 / 8 = 1/4 (the same).

4
1 1 1 1 1 3
Therefore: p4 p3 =
2 2 16 2 4 16

5
1 1 1 1 3 4
p5 p4 =
2 2 32 2 16 32

6
1 1 1 1 4 5
p6 p5 = , etc.
2 2 64 2 32 64

y 1
We see that the pmf of Y is given generally by f ( y) , y 2,3, 4,... .
2y

Alternative working: f (5) P (Y 5) P ( HHHHT ) {P (THHHT ) P (TTHHT ) P (TTTHT )}


5
1 5 1
(1 (5 2)) .
2 25
The same logic applies for y = 2, 3, 4, 6, 7, …
y 1
We thereby obtain, more simply, f ( y ) , y 2,3,... .
2y

Next, EY P ( H ) E (Y | H ) P (T ) E (Y | T )

1 1
E (Y | H ) ( EY 1) , (1)
2 2

Page 4
where E (Y | H ) P ( HH | H ) E (Y | H , HH ) P ( HT | H ) E (Y | H , HT )

1 1
E (Y | H ) 1 2. (2)
2 2

Now (2) 2 E (Y | H ) E (Y | H ) 1 2 E (Y | H ) = 3.

Hence (1) 2 EY 3 EY 1 EY = 4 .

y 1 y 1 y 1
Alternative working: EY y ( y 1)
y 2 2y y 2 2y y 2 2y
x
1 y 1 1 2 1
1 ( y 1) y 1 1 x where x y 1
2y 2 2 2 x 1 2
1
1 EX 2 where X ~ Geo(1/ 2)
2
2
1 2 1 1 1/ 2 1 1
1 VX ( EX ) 1 1 2 4 4.
2 2 (1/ 2) 2 1/ 2 2

(b) Let X i be the indicator for HT occurring on tosses i and i + 1.

Then the total number of times that HT occurs may be written as

X X 1 ... X n 1 , where X i ~ id Bern(1 / 4) (identically distributed but not independent).

1 n 1
So EX EX 1 ... EX n 1 ( n 1) . Thus EX , n = 2, 3, 4,… , and EX = 9.75 if n = 40.
4 4

n 1 n 2 n 1
Also, VX VX i 2 C ( XYi , X j )
i 1 i 1 j 2

( n 1)VX 1 2( n 2)C ( X 1 , X 2 ) (by symmetry and because C ( X i , X j ) = 0 if | i j | 1 ).

Now VX (1 / 4)(1 1 / 4) 3 / 16 .

Also C ( X 1 , X 2 ) E ( X 1 X 2 ) ( EX 1 ) EX 2 P( X 1 X 2 1) ( EX 1 ) 2 0 (1 / 4) 2 1 / 16 .

3 1 3 2 3 4
So VX ( n 1) 2( n 2) n .
16 16 16 16 16 16
n 1
Thus VX , n = 2, 3, 4,… , and VX = 2.5625 if n = 40.
16

Page 5
Solution to Problem 4

(a) The joint pdf of X and Y is


x 3 1 (1 x )1 1 1 x (4) x
f ( x, y ) f ( x) f ( y | x) 3.
B(3,1) 4x 4 (3) (1) 4

3
Thus f ( x, y ) x, 0 x 1, 0 y 4 x , and f ( x 0.2, y 0.2) = 0.15 .
4

1 1
3 3 x2 3 y2
(b) f ( y ) xdx . Thus f ( y) 1 ,0 y 4 , and f ( y 0.2) = 0.3741 .
y /4
4 4 2 y /4
8 16

4 4
3 y2 3 y2 y4 3 16 256 2 32
(c) EY y 1 dy 3 = 1.5 .
0
8 16 8 2 64 0 8 2 64 2 64

4 4
2 3
2 y2 3 y3 y5 3 64 1024 128 16
EY y 1 dy 8 3 8 3 4.8 .
0
8 16 8 3 80 0 8 3 80 80 10

So, VY EY 2 ( EY ) 2 4.8 1.52 = 3.2 .

Alternative working:

EX 3 / (3 1) 3/ 4 0.75
4X 3
EY EE (Y | X ) E 2 EX 2 = 3/2 = 1.5
2 4
3 1
VX = 3/80 = 0.0375
(3 1) 2 (3 1 1)
(4 X 0) 2 0 4X
VY EV (Y | X ) VE (Y | X ) E V
12 2
2
42 2 2 4 3 3 3
VX ( EX ) 2 VX 4 = 16/5 = 3.2.
12 3 80 4 80

(d) The cdf of R is

r r
F (r) P( R r) P ( XY r) P Y 1 P Y ,
X X

Page 6
where
1 4x
r 3
P Y f ( x, y )dxdy x 1dx dy
X y r/ x
4 r /2 r/ x

by considering region A in Figure 1 (for the case r = 0.5)

1
3 r
x 4x dy
4 r /2
x
1
3 4 x3
rx
4 3 x r /2

3 4 4 r 3/2 r
r r
4 3 3 8 2
3 1 3/2 3 3/2 3 1 3/2
1 r r r 1 r r .
4 8 8 4 4

r 3 1 3/2 3 1 3/2
So F ( r ) 1 P Y 1 1 r r r r , 0 < r < 4.
X 4 4 4 4

3 1 3/2
Check: F ( r ) 0 0 0 and F (4) (4) (4) 3 2 1 (both correct).
4 4

3 1 3 1/2 3 3
So f ( r ) F (r) r , that is, f ( r ) r , 0 r 4 , as shown in Figure 2.
4 4 2 4 8
3 3 1
Specifically, f ( r 0.25) = 9/16 = 0.5625 , as shown by the dot in Figure 2.
4 8 4

Page 7
(e) Using the pdf of R derived in (b),

4 4 4
3 3 3 r2 3 r 5/2
E ( XY ) ER rf ( r )dr r r dr
0 0
4 8 4 2 8 5/2 r 0

3 2 3 80 64
16 ( 4)5 = 6/5 = 1.2.
8 5 8 5

Also, EX 0.75 and EY 1.5 by (c).

So C ( X , Y ) E ( XY ) ( EX ) EY 1.2 0.75 1.5 = 0.075 = 3/40.

Further, VX = 3/80 and VY = 3.2 by (c).

C ( X ,Y ) 3 / 40 3
So = 0.2165 .
SD ( X ) SD (Y ) 3 / 80 3.2 8

Page 8
Alternative workings for part (e):

1 4x 1 4x
2 1
[1] E ( XY ) xyf ( x, y )dxdy xf ( x ) yf ( y | x )dy dx x 3x y dy dx
0 0 0 0
4x
1 2 4x 1 5 1
3 2 y 3 2 x 6
x dx x 16 x 2 dx 6 1 = 1.2
40 2 y 0
80 5 x 0
5

[2] E ( XY ) EE ( XY | X ) E{ XE (Y | X )} E{ X (4 X / 2)} 2 EX 2
2
2 3 1 3
2{VX ( EX ) } 2 = 1.2
(3 1) 2 (3 1 1) 3 1

4X 3 3
[3] C ( X , Y ) EC ( X , Y | X ) C E ( X | X ), E (Y | X ) E0 C X , 2VX 2 .
2 80 40

R Code for Problem 4

X11(w=8,h=5)

# FIGURE 1
plot(c(0,1.5),c(0,5),type="n",xlab="x",ylab="y",
main="Figure 1: Region of integration A for finding P(Y>r/X) when r = 0.5")
abline(h=seq(0,6,0.5),lty=3); abline(v=seq(0,2,0.25),lty=3)
abline(h=0,lty=2,lwd=2); abline(v=0,lty=2,lwd=2)
lines(c(1,1),c(0,4),lty=2,lwd=2); lines(c(0,1),c(0,4),lwd=3)
xvec=seq(0.001,10,0.005)
lines(xvec,0.5/xvec,lty=2,lwd=2)
text(1.35,0.68,"y = r/x"); text(0.65,3.25,"y = 4x"); text(0.77,1.9,"A",cex=3)
xval=sqrt(0.5)/2; c(xval,4*xval) # 0.3535534 1.4142136
points(xval,4*xval,pch=16,cex=1.5)
text(0.85,4.75,"The point has coordinates (x,y) = (sqrt(r)/2, 2*sqrt(r)) = (0.35355, 1.41421)")

# FIGURE 2
rvec=seq(0,4,0.01); fvec=0.75-(3/8)*sqrt(rvec)
plot(rvec,fvec,type="l",xlab="r",ylab="f(r)",lwd=3, main="Figure 2: Density of R = XY")
abline(h=seq(0,1,0.1),lty=3); abline(v=seq(0,4,0.5),lty=3)
abline(h=0,lty=2,lwd=2); abline(v=0,lty=2,lwd=2)
fval=0.75-(3/8)*sqrt(0.25); fval # 0.5625
points(0.25, fval, pch=16, cex=1.5);
abline(h=fval,lty=2,lwd=2); abline(v=0.25,lty=2,lwd=2)

Page 9
Solution to Problem 5

(a) Y ~ Geo( k / 4) with mean EY 1 / ( k / 4) 4 / k .


Setting this to y yields kˆ 4 / y , y 1, 2,3,... generally. If y = 5, kˆ 4 / 5 = 0.8 .

y 1
k k
(b) The pmf of Y is 1 , y 1, 2,3,... (k = 1, 2).
4 4

1 / 4, y 1 1 / 4, y 1
y 1
1 1 (3 / 4)(1 / 4), y 2 3 / 16, y 2
So if k = 1 then f ( y ) 1 .
4 4 (3 / 4) 2 (1 / 4), y 3 9 / 64, y 3
.......................... ..........................

1 / 2, y 1
y 1 y
2 2 1 1 / 4, y 2
Also, if k = 2 then f ( y ) 1 .
4 4 2 1 / 8, y 3
..........................

We see that the likelihood function L( k | y ) is given by:

1 / 4, k 1
L( k |1) (which is maximised at k = 2)
1 / 2, k 2

3 / 16, k 1
L( k | 2) (which is maximised at k = 2)
1 / 4, k 2

9 / 64 0.1406, k 1
L( k | 3) (which is maximised at k = 1)
1 / 8 0.1250, k 2

27 / 128 0.2109, k 1
L( k | 4) (which is maximised at k = 1)
1 / 16 0.0625, k 2

81 / 256 0.3164, k 1
L( k | 5) (which is maximised at k = 1), etc.
1 / 32 0.03125, k 2

2 if y 2
From this we see that the MLE of k is given by kˆ ,
1 if y 2
or equivalently kˆ 1 I ( y 2) (for example). If y = 5, k̂ = 1 .

Page 10
(c) Let k̂ be the MLE in (b). Then
k k k
Ekˆ 1 P(Y 2) 1 P (Y 1) P (Y 2) 1 1 , k = 1, 2.
4 4 4

23 / 16, k 1
Thus Ekˆ .
28 / 16, k 2

23 / 16, k 1 16 / 16, k 1
Hence B ( kˆ) Ekˆ k .
28 / 16, k 2 32 / 16, k 2

7 / 16, k 1
Thus B( kˆ) .
4 / 16, k 2

(d) Let k̂ be the MLE in (b). Then, by (c),


23
Ekˆ a bk , where: a b 1
16
28
a b 2.
16

18 5 18 5
Solving, we get a = and b = . Thus Ekˆ k.
16 16 16 16

kˆ 18 /16 16kˆ 18 2 / 5, kˆ 1
So an unbiased estimate of k is k .
5 /16 5 14 / 5, kˆ 2

2 if y 2 14 / 5, y 1, 2
Then, since kˆ , we get k (the required function of y).
1 if y 2 2 / 5, y 3, 4,...

14 16
Note: This function could also be written as k I(y 2) (for example).
5 5

If y = 5 then k = 2/5 .

Note: The MOM estimate, kˆ 4 / y , equals 4, 2, 4/3, 1, 4/5, … , at y = 1, 2, 3, 4, 5, …. So this


estimate takes on a possible value of k (i.e. 1 or 2) only if y = 1, 2 or 4. The unbiased estimate k in
(d) always yields an impossible value of k, and sometimes this value is even negative. Although
biased, the MLE, kˆ 1 I ( y 2) , always provides a possible value of k. These observations
illustrate the kinds of trade-offs involved when choosing an estimator amongst several candidates.

Page 11
Solution to Problem 6

n n
yi yi2 ny 2
(a) Observe that y i 1
= 0.017 and s 2 i 1
= 0.10951.
n n 1
s
So the CI is y 1.96 (0.017 0.0410) = ( 0.0240, 0.0580) .
n

Y
(b) A suitable pivot is X ~ U (0,1) .

Y
So 0.8 P (0.1 X 0.9) P 0.1 0.9 P 0.1 Y 0.9

P 0.1 Y ,Y 0.9
P 1.1 Y ,Y 1.9
Y Y
P ,
1.1 1.9
Y Y
P .
1.9 1.1

y y 10 y 10 y 54 54
So the CI is , = , generally, and if y = 5.4 it is , = (2.842, 4.909) .
1.9 1.1 19 11 19 11

(c) The maximum X of Y1 ,..., Yn ~ iid U (0, c ) has cdf F ( x) P( X x) P(Y1 x) n ( x / c) n .

1/n 1/ n
Setting this to yields x c . Thus P( X c ) . Noting that X < c, we then have that

1/ n 1/ n X 1/n
1 1 P( X c ) P( X c ) P 1/n
c P X c X .

1/ n
So the 1 CI is ( x, x ) generally. If x = 2.4, n = 7 and = 0.3, then the CI is (2.4, 2.85) .

R Code for Problem 6

n=250; ydot=4.25; yp=27.34


ybar=ydot/n; s2=(1/(n-1))*(yp-n*ybar^2); s=sqrt(s2); d=1.96*s/sqrt(n)
c(ybar,s,s2,d) # 0.01700000 0.33092150 0.10950904 0.04102145
ybar+c(-1,1)*d # -0.02402145 0.05802145
c(54/19,54/11) # 2.842105 4.909091
m=2.4; n=7; alp=0.3; c(m, m*alp^(-1/n)) # 2.400000 2.850416

Page 12
Solution to Problem 7

VY1 (2c 0) 2 / 12 c2
(a) VY = 4/3 = 1.3333 if c = 6 and n = 9.
n n 3n

(b) The efficiency must be the same for all values of c. So without loss of generality, let c = 1/2.

In that case, the sample mean Y has variance 1 / (12n ) . Also, the pdf of the sample median M is

n!
f M (m) F ( m ) k 1 (1 F ( m )) n k
f (m) ,
( k 1)!( n k )!

where k ( n 1) / 2 , f ( y ) 1 and F ( y ) y (the pdf and cdf of Y ~ U (0,1) ). Thus

n 1 n 1
f M (m) m k 1 (1 m ) k 1
since n k n 1 k 1.
2 2

k k 1 1
It follows that M ~ Beta ( k , k ) with variance .
(k k ) 2 ( k k 1) 4(2k 1) 4( n 2)

VM 1 / (4( n 2)) 3n
So Eff (Y , M ) , which converges to 3 as n .
VY 1 / (12n ) n 2

Page 13
Solution to Problem 8

y 2 1 (1 y ) 2 1
(a) The conditional densities of Y are f ( y | 0) 1 and f ( y | 1) 6 y (1 y ) .
B(2, 2)
(Thus the conditional distributions are (Y | 0) ~ Beta (1,1) U (0,1) and (Y |1) ~ Beta (2, 2) .)

1
1 1
So the unconditional density of Y is f ( y ) f ( , y) f ( ) f (y | ) 1 6 y (1 y ) .
0 2 2

1 1
Thus f ( y ) 3 y (1 y ), 0 y 1 and f ( y 0.1) 3 0.1 0.9 = 0.77 , as shown below.
2 2

(1/ 2) 1 1
, 0 , 0
f ( ) f (y | ) {1 6 y (1 y )} / 2 1 6 y (1 y )
(b) f ( | y ) .
f ( y) (1/ 2) 6 y (1 y ) 6 y (1 y )
, 1 , 1
{1 6 y (1 y )} / 2 1 6 y (1 y )

1 p, 0 6x
Thus ( | y ) ~ Bernoulli ( p ) and f ( | y ) , where p and x y (1 y ) .
p, 1 1 6x

6 0.25
If y = 0.5, x 0.5(1 0.5) 0.25 and p 0.6 . So f ( 0| y 0.5) 1 0.6 = 0.4 .
1 6 0.25

Page 14
Alternative working:
1 y 1 1 (1 y ) 1 1 (2 1)! x
f ( | y) f ( ) f (y | ) where x y (1 y )
2 ( 1) ( 1) / (2 2) !2

1
, 0
1, 0 1 6x
f ( | y) .
6 x, 1 6x
, 1
1 6x

6 y (1 y )
(c) By (b), the posterior mean of is p. So E ( | y ) = 0.35065 if y = 0.1.
6 y (1 y ) 1

Next, observe that the posterior mode of is 1 if p > 1/2, and that mode is 0 if p < 1/2.

1 6x 1
Now, p 12 x 1 6 x 6x 1 6 y (1 y ) 1 6 y2 6 y 1 0
2 1 6x 2

6 36 24 1 1
y 0.5 0.2887 0.2113, 0.7887 .
12 2 12

1 1 1, 0.2113 y 0.7887
So Mode( | y ) I y = 0 if y = 0.1.
2 12 0, otherwise

1 1
Note: If y = exactly, then Mode( | y ) = 0 or 1 or {0, 1} (all correct).
2 12

Page 15
R Code for Problem 8

X11(w=8,h=5)

# (a)
plot(c(0,1),c(0,1.6) ,type="n",xlab="y",ylab="",
main="The unconditional density of the data Y (solid line))")
abline(h=seq(0,2,0.5),lty=3); abline(v=seq(0,1,0.1),lty=3)
lines(c(0,1),c(1,1),lty=2,lwd=2)
yv=seq(0,1,0.01); lines(yv,6*yv*(1-yv),lty=2,lwd=2)
lines(yv,0.5+3*yv*(1-yv),lwd=3)
fval=0.5+3*0.1*0.9; fval # 0.77
points(0.1,fval,pch=16,cex=1.5)

# (c)
c(1/sqrt(12),0.5+c(-1,1)/sqrt(12)) # 0.2886751 0.2113249 0.7886751
meanfun=function(y){ 6*y*(1-y) / ( 1 + 6*y*(1-y) ) }
meanval=meanfun(0.1); meanval # 0.3506494
plot(c(0,1),c(0,1) ,type="n",xlab="y",ylab="",
main="The posterior mean (solid line) and the posterior mode (dashed line)")
abline(h=seq(0,1,0.1),lty=3); abline(v=seq(0,1,0.1),lty=3)
yv=seq(0,1,0.01); lines(yv,meanfun(yv),lwd=3)
lines(c(0, 0.2113249),c(0,0),lty=2,lwd=3)
lines(c(0.2113249, 0.7886751),c(1,1),lty=2,lwd=3)
lines(c(0.7886751,1),c(0,0),lty=2,lwd=3)
points(c(0.1,0.1),c(meanval,0),pch=16,cex=1.5)
abline(h=0.5,lty=3,lwd=2); abline(v=c(0.2113249, 0.7886751),lty=3,lwd=2)

Page 16
Solution to Problem 9

log 0.03
If Y ~ Geo(0.08) then P(Y k) 0.92k 0.03 k log 0.92 log 0.03 k = 42.05.
log 0.92

Now, P(Y 42) 0.9242 = 0.03014 and P(Y 43) 0.9243 = 0.02773. So k = 43. So the test is:

H0 : p 0.08 , H0 : p 0.08 , TS : Y ~ Geo(0.08) , RR : y 43 , = 0.02773.

Note: The rejection region could also be written as RR = {44, 45, 46, …}.

For this test, the probability of a Type II error is


( p ) P(Y 43 | p ) 1 P (Y 43 | p ) , where (Y | p ) ~ Geo( p ) .

Thus ( p ) 1 (1 p ) 43 , 0 p 0.08 , and (0.04) 1 0.9643 = 0.8272 , as shown below.

y 1
If Y ~ Geo(0.08) then P(Y y) P (Y y 1) 0.92 .

y 1
So p-value = 0.92 . If y = 37, the p-value is 0.04970 and we do not reject H 0 (at the 0.03 SL).

Note 1: If the SL were 0.04970 or anything greater (e.g. 0.05) then we would reject H 0 at y = 37.
So 0.04970 is the smallest SL for which the observed data y = 37 implies that H 0 will be rejected.

Note 2: To clarify the RR, if y = 43 then p-value = 0.9242 = 0.03014 > 0.03, meaning that we do
not reject H 0 , and if y = 44 then p-value = 0.9243 = 0.02773 0.03 , meaning that we reject H 0 .

Page 17
R Code for Problem 9

X11(w=8,h=5)
log(0.03)/log(0.92) # 42.05433
0.92^c(42,43) # 0.03013622 0.02772532
1-0.96^43 # 0.8271525
plot(c(0,0.1),c(0,1),type="n",xlab="p",ylab="",main="Probability of a Type II error")
pv=seq(0,0.08,0.001); betav=1-(1-pv)^43
lines(pv,betav,lwd=3)
abline(v=seq(0,0.1,0.01),lty=3); abline(h=seq(0,1,0.1),lty=3)
points(0.04, 0.8271525, pch=16, cex=1.5)
0.92^(37-1) # 0.04970062

Page 18
Solution to Problem 10

n n
1 n 1
(a) f ( y1 ,..., yn ) yi x where x yi .
i 1 i 1
n
So L( ) x .
So l ( ) log L( ) n log log x .
So l ( ) n 1 log x .
ˆ n n 50
So l ( ) 0 n
= 3.6989 .
log x i 1 log yi 13.5177

(b) f ( y ) y 1.
So l log f ( y ) log ( 1) log y .
1
So l log y .
2
So l 0.
2
So I ( ) E{ l } .
(d / d )2 12 2
So G 2 ( ) .
nI ( ) n 2 n
ˆ ˆ
So ~ N (0,1) .
G( ˆ) ˆ/ n

ˆ 3.6989
So a 95% CI for is ˆ 1.96 3.6989 1.96 = (2.674, 4.724) .
n 50

Alternative solution: A second CI which uses results in (a)

ˆ ˆ
It is also true that ~ N (0,1) .
G( ) / n
ˆ
So 0.95 P z z where z 1.96
/ n

P z ˆ , ˆ z
n n
z ˆ, ˆ z
P 1 1
n n
ˆ ˆ
P ,
1 z/ n 1 z/ n
ˆ ˆ
P .
1 z/ n 1 z/ n
ˆ ˆ
So a second 95% CI for is , = (2.896, 5.117) .
1 1.96 / n 1 1.96 / n

Page 19
A third CI, one which does not use results in (a) (only for interest)

2 Y
Observe that Y ~ iid ( , ) , where , and ~ N (0,1) by the CLT.
1 S/ n

Y S S
So 0.95 P z z P Y z Y z where z 1.96 .
S/ n n n
S S
P A B where A Y z and B Y z
1 n n
P A , B P A A , B
1 1
A B A B
P A (1 A), (1 B ) B P , P .
1 A 1 B 1 A 1 B

a b s s
So a third 95% CI for is , , where a y 1.96 and b y 1.96 .
1 a 1 b n n

Numerically, we have that:


1 n
y yi = 0.78250
ni1
n
1
s2 yi2 ny 2 = 0.02673
n 1 i 1

s
a y 1.96 = 0.73719
n
s
b y 1.96 = 0.82782.
n

a b
So the third approximate 95% CI for works out as , = (2.805, 4.808).
1 a 1 b

The true overage probabilities of the three approximate 95% CIs (only for interest)

It can be shown (see the R code below) that if 3.5 (as an example), the coverage probabilities
of the three approximate 95% CIs are actually about 95.7%, 94.0 and 94.1%, respectively.

Also, approximate 95% CIs for the actual coverage probabilities themselves are, respectively,
(95.3, 96.1), (93.6, 94.5), (93.6, 94.6) (as percentages).

Thus, the first CI has a slightly higher than 95% chance of containing , and each of the last two
CIs has a slightly lower than 95% chance of containing (in the case where 3.5 and n = 50).

Page 20
R Code for Problem 10

n=50; set.seed(372); lam=3.5; y=rbeta(n,lam,1)


sumy=sum(y); sumy2=sum(y^2); sumlogy=sum(log(y)); lamhat=-n/sumlogy
c(sumy,sumy2,sumlogy,lamhat) # 39.125120 31.925163 -13.517695 3.698855

CI1=lamhat+c(-1,1)*1.96*lamhat/sqrt(n); CI1 # 2.673585 4.724126

CI2=lamhat/(1+c(1,-1)*1.96/sqrt(n)); CI2 # 2.896098 5.117298

ybar=sumy/n; s2=(1/(n-1))*(sumy2-n*ybar^2); s=sqrt(s2)


c(ybar,s2,s) # 0.78250239 0.02672782 0.16348646
a=ybar-1.96*s/sqrt(n); b=ybar+1.96*s/sqrt(n)
c(a,b) # 0.7371863 0.8278185
CI3=c(a/(1-a),b/(1-b)); CI3 # 2.804976 4.807826

# Check the coverage probabilities:

ct1=0; ct2=0; ct3=0; J=10000; set.seed(118); for(j in 1:J){


y=rbeta(n,lam,1); sumy=sum(y); sumy2=sum(y^2)
sumlogy=sum(log(y)); lamhat=-n/sumlogy
z=qnorm(0.975)
CI1=lamhat+c(-1,1)*z*lamhat/sqrt(n)
CI2=lamhat/(1+c(1,-1)*z/sqrt(n))
ybar=sumy/n; s2=(1/(n-1))*(sumy2-n*ybar^2); s=sqrt(s2)
a=ybar-1.96*s/sqrt(n); b=ybar+1.96*s/sqrt(n)
CI3=c(a/(1-a),b/(1-b))
if(lam>CI1[1]) if(lam<CI1[2]) ct1=ct1+1
if(lam>CI2[1]) if(lam<CI2[2]) ct2=ct2+1
if(lam>CI3[1]) if(lam<CI3[2]) ct3=ct3+1
}
prob1=ct1/J; prob2=ct2/J; prob3=ct3/J
probs=c(prob1, prob2,prob3); probs # 0.9570 0.9402 0.9410 (all close to 0.95, so OK)
LBs=probs-1.96*sqrt(probs*(1-probs)/J)
UBs=probs+1.96*sqrt(probs*(1-probs)/J)
rbind(LBs,UBs)
# LBs 0.953024 0.9355525 0.9363818
# UBs 0.960976 0.9448475 0.9456182

Page 21

You might also like