A Longer Example - Continued

Say X1, .., Xn iid F with f(x|a)=axa-1, x>0, a>0 (or simply X~Beta(a,1))

say we want to test H0:a=a0 vs Ha:a≠a0. From the CLT we know that

similarly for 1-α/2. So we have the following test for H0:a=a0 vs Ha:a≠a0: reject H0 if <x or >y where

This is implemented in beta1.ex(1)

One-sided tests: above we tested H0:a=a0 vs Ha:a≠a0. Often we want to test instead alternatives of the form Ha:a<a0 or Ha:a>a0. In that case choose the appropriate rejection region, with α instead of α/2

p-value: if we want to quote the p-value of this test we calculate it as follows: say we observed =t in our experiment. The p-value is the probability of repeating the experiment and observing a value of the test statistic as "unlikely" (given the null hypothesis) as that seen in the original experiment. Say we observed t>a0 and let Ybar be the sample mean of the new experiment, then

the "2" is because we do a two-sided test.

How about the likelihood ratio test? We have

and we reject H0 if -2logλ(x)>qchisq(1-α,1)
This is implemented in beta1.ex(2)

One problem with both these methods is that they are large sample methods, they rely on the CLT. Can we derive a method that also works for small samples? The basic idea of the LRT is to reject the null hypothesis if λ(x) is small, which is the same as (-2)logλ(x) is large. beta1.ex(3) draws -2logλ(x) as a function of a2hat, and it is clear that "-2logλ(x) large" is the same as "a2hat is small or large".

Here is another argument:

so h is decreasing on (0,a0) and increasing on (a0,∞), or again h is large for small or large values of a.

Now a2hat=n/T, and so "a2hat is small or large" is equivalent to "T is small or large". If H0 is true T~Γ(n,1/a0) and if we α/2 on the left and the right we find

α/2=P(T<x)=pgamma(x,n,a0)

x=qgamma(1-α/2,n,a0)

Similarly α/2=P(T>y) y=qgamma(1-α/2,n,a0) and so we reject H0 if

T<qgamma(α/2,n,a0) or T>qgamma(1-α/2,n,a0)

Note

so we reject H0 if

a0T<qgamma(α/2,n,1) or a0T>qgamma(1-α/2,n,1)

This is implemented in beta1.ex(4)

One-sided tests: Say we want to test Ha:a<a0 Then we have the rejection region a0T<qgamma(α,n,1)

p-value: p=2P(T*>t|a=a0) =2(1-pgamma(t,n,a0)) if t>a0 or p=2P(T*<t|a=a0) =2pgamma(t,n,a0) if t<a0

How about a Bayesian method? Let's use again the prior Exp(1), then we know a|x~Γ(n+1,1/(T+1)) A test could be designed as follows: reject H0 if a0<qgamma(α/2,n+1,1/(T+1)) or a0>qgamma(1-α/2,n+1,1/(T+1)). Using the derivation above we see that this is essentially the same as the test based on the mle. (except with n+1 instead of n and T+1 instead of T)

Let's go back to the two tests based on the sample mean and the likelihood ratio. Which of these is best? That depends on the power of the test. First we have

and then

beta1.ex(4) draws the power curves. Somewhat strange is that for small n and and not so small a0 the true α of the "mean" method is a little to small but it also has a larger power than the LSR, see for example beta1.ex(4,a0=3,n=4)