Loading [MathJax]/jax/output/HTML-CSS/jax.js

Equal Variance

Example (7.3.1)

say we have samples X1,..,Xn iid N(μx,σx) and Y1,..,Ym iid N(μy,σy) and we want to test

H0:σx=σy vs H1:σxσy

We will assume μx and μy are known, in which case we can assume μx=μy=0.

Let’s derive the likelihood ratio test. We will do this in terms of the variances vx=σ2x and vy=σ2y , which is of course the same test.

First we find the joint density, using (2.3.14)

f(xx,yy|vx,vy)=(2πvx)n/2exp{12vxx2i}(2πvy)m/2exp{12vyy2i}=(2πvx)n/2exp{ntx2vx}(2πvy)m/2exp{mty2vy}

where we define tx=1nx2i and ty=1my2i.

Now

l(vx,vy)=n2log(2πvx)ntx2vxm2log(2πvy)nty2vydldvx=n2vx+tx2v2x=0 yields ˆvx=tx, and similarly ˆvy=ty

Under H0 we have vx=vy=:v, and so

L(v,v)=(2πv)n/2exp{ntx2v}(2πv)m/2exp{mty2v}=(2πv)(n+m)/2exp{ntx+mty2v}

l(v,v)=n+m2log(2πv)ntx+mty2v

and so ˆv=ntx+mtyn+m.

λ(xx,yy)=L(ˆv,ˆv)L(^vx,^vy)=(2πˆv)(n+m)/2exp{ntx+mty2ˆv}(2πˆvx)n/2exp{ntx2ˆvx}(2πˆvy)m/2exp{mty2ˆvy}=(2πntx+mtyn+m)(n+m)/2exp{ntx+mty2ntx+mtyn+m}(2πtx)n/2exp{ntx2tx}(2πty)m/2exp{mty2ty}=(ntx+mtyn+m)(n+m)/2exp{n+m2}(tx)n/2exp{n2}(ty)m/2exp{m2}=(n+m)(n+m)/2(ntx+mty)(n+m)/2(tx)n/2(ty)m/2=(n+m)(n+m)/2(ntx+mtytx)n/2(ntx+mtyty)m/2=(n+m)(n+m)/2(n+m(ty/tx))n/2(n(tx/ty)+m)m/2=(n+m)(n+m)/2(n+n(mty/ntx))n/2(m(ntx/mty)+m)m/2=(n+m)(n+m)/2nn/2mm/2(1+1/F))n/2(1+F)m/2

where F=(ntx)/(mty)

Now LRT is small is equivalent to F is small or large, as we can see here:

n<-10; m<-15
fun <- function(x)  
  (n+m)^((n+m)/2)/n^(n/2)/m^(m/2)*
   (1+1/x)^(-n/2)*(1+x)^(-m/2)
ggcurve(fun=fun, A=0.1, B=3)

and so under the null hypothesis

XiN(0,σ)Xi/σN(0,1)X2i/vχ2(1)=ntx/v=ni=1X2i/vχ2(n)F=(ntx/v)/(mty/v)F(n,m)

and we reject the null if F<qf(α/2,n,m) or F>qf(1α/2,n,m).

n <- 10; m <- 14
x <- rnorm(n, 0, 1)
y <- rnorm(m, 0, 1)
tx <- mean(x^2)
ty <- mean(y^2)
(n*tx)/(m*ty)
## [1] 1.131456
qf(c(0.025, 0.975), n, m)
## [1] 0.2816576 3.1468612
n <- 10; m <- 14
x <- rnorm(n, 0, 1)
y <- rnorm(m, 0, 3)
tx <- mean(x^2)
ty <- mean(y^2)
(n*tx)/(m*ty)
## [1] 0.2153921