Example Problems on Hypothesis Testing
ST702 Homework 7 on Hypothesis Testing
8.2
In a given city it is assumed that the number of automobile accidents in a given year follows a Poisson distribution. In past years the average number of accidents per year was 15, and this year it was 10. Is it justified to claim that the accident rate has dropped?
Since λ is also the mean of the Poisson distribution, we want to test
P(X=10|λ=15)=10∑i=0e−1515ii!.We can do this in R.
> ppois(10, 15)
[1] 0.1184644
8.6
Suppose that we have two independent random samples: X1,…,Xniid∼exp(θ) and Y1,…,Ymiid∼exp(μ).
a
Find the LRT of H0:θ=μ vs. H1:θ≠μ.
Our LRT looks like
λ(x,y)=supθ∏ni=11θe−xi/θ∏mj=11θe−yj/θsupθ,μ∏ni=11θe−xi/θ∏mj=11μe−yj/μ=supθ1θne−∑ni=1xi/θ1θme−∑mj=1yj/θsupθ,μ1θne−∑ni=1xi/θ1μme−∑mj=1yj/μ=supθ1θn+me−∑ni=1xi+∑mj=1yiθsupθ,μ1θne−∑ni=1xi/θ1μme−∑mj=1yj/μWe can take the derivative of the top and set it equal to zero to find the supremum.
∂top∂θ=e∑xi+∑yjθθ−(m+n+2)(∑xi+∑yj−(m+n)θ)=0⇒ˆθ=∑xi+∑yjm+nWe can do the same to the bottom. In Mathematica:
Solve[∂∂te−xte−yμμmtn=0∧∂∂μe−xte−yμμmtn=0,{μ,t}].This gives
ˆμ=¯y, ˆθ=¯x.Thus,
λ(x,y)=(m+n)m+n(∑ni=1xi)n(∑mj=1yj)mnnmm(∑ni=1xi+∑mj=1yj)m+n.b
Show that the test in part (a) can be based on the statistic
T=∑Xi∑Xi+∑Yi. λ(x,y)=(m+n)m+n(∑ni=1xi)n(∑mj=1yj)mnnmm(∑ni=1xi+∑mj=1yj)m+n=(m+n)m+nnnmm(∑ni=1xi∑ni=1xi+∑mj=1yj)n(∑mj=1yj∑ni=1xi+∑mj=1yj)m=(m+n)m+nnnmmTn(1−T)mc
Find the distribution of T when H0 is true.
If H0 is true then θ=μ
T=∑ni=1xi∑ni=1xi+∑mj=1yj∼∑ni=1gamma(1,θ)∑ni=1gamma(1,θ)+∑mj=1gamma(1,θ)=gamma(n,θ)gamma(n,θ)+gamma(m,θ)=gamma(n,θ)gamma(n+m,θ)=beta(n,m)8.8
A special case of a normal family is one in which th mean and the variance are related, that n(θ,aθ) family. If we are interested in testing this relationship regardless of the value of θ, we are again faced with a nuisance parameter problem.
a
Find the LRT of H0:a=1 vs. H1:a≠1 based on a sample X1,…,Xn from a n(θ,aθ) family, where θ is unknown.
We will start by finding our MLEs (since we can follow the same process for top and bottom).
ℓ(θ,a)=−nlog(√2π)−2nlog(aθ)−∑x2i−2θ∑xi+nθ22aθ∂ℓ∂a=−n2a+∑x2i−2θ∑xi+nθ22a2θ∂ℓ∂θ=−n2θ+∑x2i−2θ∑xi+nθ22aθ2+∑xi−nθaθWe can then set these equal to 0 and solve. In Mathematica:
Solve[-n/(2 a) + (x2 - 2 \[Theta] x1 + n \[Theta]^2)/(
2 \[Theta] a^2) ==
0 && -n/(2 \[Theta]) + (x2 - 2 \[Theta] x1 +
n \[Theta]^2)/(
2 a \[Theta]^2) + (x1 - n \[Theta])/(a \[Theta]) ==
0, {a, \[Theta]}]
Which gives
ˆθ=¯x,ˆa=(∑xi)2+n∑(x2i)n∑xi.When a=1,
Solve[-n/(2 \[Theta]) +
(x2 - 2 \[Theta] x1 + n \[Theta]^2)/(
2 *1 *\[Theta]^2) +
(x1 - n \[Theta])/(1* \[Theta]) == 0, \[Theta]]
Thus,
λ(x)=(12πˆθ1)n/2e−∑(xi−ˆθ1)22ˆθ1(12πˆaˆθ)n/2e−∑(xi−ˆθ)22ˆaˆθ=(12π−n+√n√n+4∑(x2i)2n)n/2e−∑(xi−−n+√n√n+4∑(x2i)2n)22ˆθ1(12π(∑xi)2+n∑(x2i)n∑xi¯x)n/2e−∑(xi−¯x)22(∑xi)2+n∑(x2i)n∑xi¯xb
A similar question can be asked about a related family, the n(θ,aθ2) family. Thus, if X1,…,XNiid∼n(θ,aθ2), where θ is unknown, find the LRT of H0:a=1 vs. H1:a≠1.
We will follow the same process as above.
∂ℓ∂a=−n2a+∑x2i−2θ∑xi+nθ22a2θ2∂ℓ∂θ=−−2θn−2x12aθ2+θ2(−n)−2θx1+x2aθ3+nθSolve[-(n/\[Theta]) - (-2 x1 - 2 n \[Theta])/(2 a \[Theta]^2)
+ ( x2 - 2 x1 \[Theta] - n \[Theta]^2)/(a \[Theta]^3)
== 0 && -n/(2 a) + (x2 - 2 \[Theta] x1 +
n \[Theta]^2)/(2 \[Theta]^2 a^2) == 0, {\[Theta], a}]
This gives
ˆθ=¯x, ˆa=−∑(x2i)+n(∑xi)2∑(x2i).With a=1
Solve[-(n/\[Theta]) - (- x1 - n \[Theta])/\[Theta]^2
+ ( x2 - 2 x1 \[Theta] - n \[Theta]^2)/\[Theta]^3
== 0 , \[Theta]]
8.9
Stefanski (1996) establishes the arithmetic-geometric-harmonic mean inequality (see Example 4.7.8 and Miscellanea 4.9.2) using a proof based on likelihood ratio tests. Suppose that Y1,…,Yn are independent with pdfs λie−λiyi, and we want to test H0:λ1=⋯=λn vs. H1λi are not all equal.
a
Show that the LRT statistic is given by (¯Y)−n/(∏Yi)−1 and hence deduce the arithmetic-geometric mean inequality.
Notice that Yi∼exponential(1/λi). The MLE of ˆλiis1Yi. Under H0, all of these are the same, so we have an iid sample and can say that ˆλ=1¯Y. Thus, the LRT statistic is
λ(x)=∏1¯ye−yi¯y∏1yie−yiyi=(1¯y)e−∑yi¯y∏(1yi)e−∑1=(1¯y)ne−−n¯y¯y∏(1yi)e−n=(1¯y)n∏1yi.Recall that the LRT is bounded above by 1.
1≥(1¯y)n∏1yi(1¯y)n≤∏1yi¯y≥(∏yi)1/nb
Make the transformation Xi=1/Yi, and show that the LRT statistic based on X1,…,Xn is given by [n/∑(1/Xi)]n/∏Xi and hence deduce the geometric-harmonic mean inequality.
First we can find the PDF of X.
P(X≤y)=P(1Y≤y)=P(1/y≤Y)=1−P(Y≤1/y)FX=1−e−λxifx=−λx2e−λxThen we can find the MLEs.
L(λ|x)=∏λix2ie−λixiℓ(λ|x)=log(λi)−2log(xi)−λixi∂ℓ∂λ=1λi−1xiunder H00=nλ−∑1xi1xi=nλˆλ=n∑1xiunder H10=1λi−1xiˆλi=xiThen, as above, we can calculate our LRT.
λ(x)=∏−n∑1xix2ie−n∑1xixi∏−xix2ie−xixi=[n∑(1/Xi)]n∏XiAgain, this is bounded by 1, which gives us
¯x≥(∏xi)1/n