\begin{center}
{\bf \colorbox{grey}{3. TESTING HYPOTHESES}}
\end{center}

{\bf \color{dblue} 3.1 Hypothesis testing: basic setting}

Statistical estimation and tests address {\sl different kind} of practical problems.


We work with a family of distributions $f(\bx;\btheta)$, where
$\btheta\in\Theta$, and $f(\bx ;\btheta)$ is completely known apart from
$\btheta$.

\underline{\color{dred}Basic setting}:\\
A statistical test make a decision between two sets of  hypotheses on unknown
parameter $\btheta$, namely
\[
H_0: \, \btheta \in \Theta_0 \quad {\rm vs}  \quad
H_1: \, \btheta \in  \Theta_1 ,
\]
where $\Theta_0, \Theta_1$ are  subsets of $\Theta$.
We always  assume
\[
\Theta_0\cap\Theta_1=\O \mbox{ (empty set)},
\]
i.e. $H_0$ and $H_1$ are distinct, mutually
exclusive,
although we do not always require $\Theta_0 \cup \Theta_1 = \Theta$.

Based on a sample
$\bX = (X_1, \cdots, X_n)^\tau$, a
statistical test is to make a decision
either
\vspace{-6mm}
\begin{quote}
 {\bf \color{dgreen}to reject} $H_0$, or \\
{\bf \color{dgreen}not to reject} $H_0$.
\end{quote}
\vspace{-6mm}
In latter case, we claim that there is {\bf \color{blue} no
significant difference} between the null hypothesis and the underlying
distribution according to the  observed data.

{\bf Remark}. The setting is {\bf \color{dmagenta}not symmetric} in the sense that
the two hypotheses {\color{blue} $H_0$ and $H_1$ will be treated differently}.

\newpage
{\small
Some specific terms used statistical tests are now in order:
\begin{itemize}
\item
A {\em \color{blue} Hypothesis} is an assumption made about the value of $\btheta$.
\item
A {\em  \color{blue}Simple Hypothesis} completely specifies $\btheta$ to
a known constant such as
H: $\btheta = \btheta_0$.
\item
A {\em  \color{blue}Composite Hypothesis} is any hypothesis that is not simple.  For
instance the hypothesis H: $\btheta \in [1, \infty)$.
\item
A {\em  \color{blue}Test Statistic} is a statistic based on which the decision
is made.

\item
A {\em  \color{blue}Null Hypothesis}, usually denoted as $H_0$, is the basic or
default hypothesis.

\item
The {\em  \color{blue}Alternative Hypothesis}, usually denoted as $H_1$, is a
hypothesis that is to be compared with
the Null Hypothesis.
\end{itemize}
}

\newpage
Mathematically speaking, a statistical test is equivalent to
define a binary function
\[
\phi(\bX) = \left\{
\begin{array}{ll}
1 \quad & {\rm when  \; reject \; } H_0,\\
0 & {\rm when  \; not \; reject \; } H_0.
\end{array}
\right.
\]
$\phi(\cdot)$ is called a {\bf decision rule}, which practically divides
the sample space of $\bX$ into two subspaces: {\sl \color{blue} rejection region}
(which is also called `{\bf \color{blue}critical region}') and
its compliment which is often \underline{imprecisely} labelled as
{\sl `acceptance' region}.

There are two types of errors
that can be made in a statistical test, which are displayed in the table below.
\begin{center}
\begin{tabular}{ll|c|c|} \cline{3-4}
&&\multicolumn{2}{c|}{Decision Made}\\ \cline{3-4}
&&\multicolumn{1}{c|}{$H_0$ not rejected}&\multicolumn{1}{c|}{$H_0$ rejected}\\
&&$\Theta_0$&$\Theta_1$\\ \hline
\multicolumn{1}{|c|}{True State}&$H_0$&Correct&Type I\\
\multicolumn{1}{|c|}{of}&$\Theta_0$&Decision&Error\\ \cline{2-4}
\multicolumn{1}{|c|}{Nature}&$H_1$&Type II&Correct\\
\multicolumn{1}{|c|}{}&$\Theta_1$&Error&Decision\\ \hline
\end{tabular}
\end{center}
 
Ideally we
would like
to have a test that minimises the probabilities of making
both types of errors, which unfortunately is not feasible.

\underline
{\color{blue}Construction of a statistical test}:\\
we control the probability of Type I error under a given level, say, $\alpha$, and
then we
minimize the probability of Type II error.


{\bf Definition}.
A test is said to have {\sl\color{dred} significance level} $\alpha$ if
\[
\sup_{\btheta\in \Theta_0}
P_\btheta(H_0 \; {\rm is \; rejected} ) \le \alpha.
\]

{\bf Definition}.
A test $T$ is said to be of {\sl\color{dred} size} $\alpha$ if
\[
\sup_{\btheta\in \Theta_0}
P_\btheta(H_0 \; {\rm is \; rejected} ) = \alpha.
\]
{\small
{\bf Remark}. (i) In practice, we usually take the significance level
 $\alpha = 0.1, 0.05 $ or 0.01.\\
(ii)
The size of the test is no greater than the significance level.
}


{\bf Definition}.
The {\em \color{dred}power function} of a test is defined as
\[
 \beta(\btheta) = P_\btheta (H_0 \; {\rm is \; rejected} ), \quad
\btheta \in \Theta_1.
\]

In practice, it is useful to extend $ \beta(\btheta)$ for all
 $\btheta\in\Theta$.
For $\btheta\in\Theta_0$, $\beta(\btheta)$ must be smaller than the
prescribed significance level, and
is the probability of making a Type I error at the parameter value
$\btheta$. For $\btheta\in\Theta_1$, $1 - \beta(\btheta)$ is the
probability of making a Type II error.


If a test is defined in terms of decision rule $\phi$, then
\[
\beta(\btheta) = E_\btheta[\phi(\bX)],
\]
because
\begin{align*}
&E[\phi(\bX)] = \int \phi(\bx) f(\bx;\btheta)d\bx\\
&= P_\btheta\{ \phi(\bX) =1 \} = P_\btheta\{ H_0 \; {\rm is \; rejected} ).\\
\end{align*}

\newpage

{\bf Example 1}.
Suppose that we have a random sample of size $5$ from a normal
distribution with mean $\mu$ and variance 1.  Let us consider:
\begin{center}
\begin{tabular}{ll}
$H_0$:& $\mu = 1$\\
$H_1$:& $\mu > 1$
\end{tabular}
\end{center}
One possible test statistic is $\bar{X}$. Intuitively we would
reject $H_0$ for large values of $\bar{X}$, say, $\bar{X} > K$.
The constant $K$ is determined by the prescribed significance level
$\alpha$. Let $\alpha =0.025$. Since $\sqrt{5}(\bar{X}-1) \sim N(0,1)$,
$K = 1 +1.96/\sqrt{5}$.
We reject
$H_0$ if $\bar{X}> 1 +1.96/\sqrt{5}$. The power function is shown below.\\

\centerline{\psfig{figure=figure/fig31.ps}}

The power is small for $\mu=1$, and rises
quite fast as $\mu$ increases past 1.

\underline{Question}:
What should we do if we change the alternative hypothesis to
$H_1: \mu < 1$ or $H_1: \mu \ne 1$.

The above null hypothesis is simple, because
$\Theta_0=\{1\}$, but the alternative hypothesis is composite because
$\Theta_1 = (1,\infty)$.  If instead we used the Null Hypothesis $H_0$:
$\mu\le 1$, that would be a composite null hypothesis.  It is convenient to
have one value to summarise the probability of Type I error, even when the
hull hypothesis is composite.

\underline{Question}:
Is the test constructed above still reasonable for testing
\[
H_0: \; \mu \le 1 \quad {\rm vs} \quad H_1: \mu > 1 \; ?
\]
If so, at which value of $\mu$ under $H_0$ does the probability of type
I error obtain the maximum?

\newpage

{\bf \color{dblue} 3.2 Neyman-Pearson Lemma
for testing simple hypotheses}


\underline{\color{blue} Most powerful test (MPT)}: among
all the tests of size $\alpha$, the one with
maximum power  $\beta (\btheta)$ for all $\btheta\in\Theta_1$
is called the MPT. When $\Theta_1$ consists of more than one
point, it is often called the {\color{blue} uniformly MPT (UMPT)}.

{\bf Note}. UMPT may not exist.

Let $L(\btheta; \bX)$ be the likelihood function with observation $\bX$.

{\bf Theorem 1}. ({\color{dred}\sl Neyman-Pearson Lemma})\\
The MPT for hypotheses
\[ 
H_0:\; \btheta=\btheta_0 \quad
{\rm against} 
 \quad H_1: \;\btheta=\btheta_1
\]
rejects $H_0$ when
\[
L(\btheta_1 ; \bX) > K L(\btheta_0 ; \bX),
\]
and does not reject $H_0$ when
\[
L(\btheta_1 ; \bX) < K L(\btheta_0 ; \bX),
\]
where constant $K$ is determined by the size of the test.


{\bf Remark}. In general the MPT rejects $H_0$
if the {\bf \color{blue} likelihood ratio}
\[
LR(\bX) = \frac{L(\btheta_1 ; \bX)}{L(\btheta_0 ; \bX)} > K,
\]
which indicates that $\btheta_1$ is relatively favoured over $\btheta_0$
according to the likelihood function.


{\bf Proof}.
For each test $T$, we
define the decision rule $\phi_T (\bx)$ as follows
\[
\phi_T(\bX)=\begin{cases}1& \text{Reject $H_0$}\\
                          0& \text{Do not Reject $H_0$}.
             \end{cases}
\]
The power $\beta(\btheta)$ is equal to $E\phi_T(\bX)$.


Suppose that $T$ is a test of size $\alpha$ that satisfies the conditions of the Neyman-Pearson Lemma, and $S$ is some other test of size $\alpha$.
Then

{\small
\begin{align*}
\beta_S (\btheta_1) &= E \phi_S(\bx) = \int \phi_S(\bx)f(\bx ; \btheta_1) d\bx\\
&=\int \phi_S(\bx)f(\bx ; \btheta_1) d\bx -K\int \phi_S(\bx)f(\bx ; \btheta_0) d\bx + K\alpha\\
&=\int \phi_S (\bx)[f(\bx ; \btheta_1)-Kf(\bx ; \btheta_0)]d\bx +K\alpha\\
&=\int \phi_S (\bx)[L( \btheta_1; \bx)-KL(\btheta_0;\bx)]d\bx +K\alpha\\
&\le \int_{\{L(\btheta_1; \bx) > KL(\btheta_0;\bx)\}}
\phi_S (\bx)[L( \btheta_1; \bx)-KL(\btheta_0;\bx)]d\bx +K\alpha\\
&\le \int \phi_T (\bx)[L( \btheta_1; \bx)-KL(\btheta_0;\bx)]d\bx + K\alpha\\
&=\int \phi_T (\bx)[f(\bx ; \btheta_1)-Kf(\bx ; \btheta_0)]d\bx + K\alpha\\
&=\int \phi_T (\bx)f(\bx ; \btheta_1)d\bx -K\int \phi_T f(\bx ; \btheta_0)d\bx+ K\alpha\\
&=\beta_T (\btheta_1) -K\alpha +K\alpha\\
&=\beta_T (\btheta_1).
\end{align*}
}

\newpage
{\bf Example 2}.
Suppose that $X_1, X_2,\ldots ,X_n$ are a random sample from $N(\mu, \sigma^2)$, where we treat $\sigma^2$ as a known quantity. Suppose we want to test:
\[
H_0: \mu = 0 \quad {\rm against} \quad
H_1: \mu = 5.
\]
The likelihood ratio is
\begin{align*}
LR  &=\frac{ \left(\frac{1}{\sqrt{2\pi\sigma^2}}\right)^n \exp \left(-\sum_{i=1}^n (X_i-5)^2/(2\sigma^2)\right)} { \left(\frac{1}{\sqrt{2\pi\sigma^2}}\right)^n \exp \left(-\sum_{i=1}^n X_i^2/(2\sigma^2)\right)}\\
&= \exp \left(5n(2\bar{X}-5)/(2\sigma^2)\right).
\end{align*}
We can look for a most powerful test by noting that $LR > K$ is
equivalent to $\bar{X} > K_1$, and {\sl the critical value}
$K_1$ is determined by the size of the test.
So, if we find
a test of this form which has size $\alpha$, it will be a most powerful
test of size $\alpha$.  It is easy to see that the test that rejects
$H_0$ iff $\bar{X}>z_\alpha\sigma/\sqrt{n}$
is of this form and is therefore a most powerful test of size $\alpha$.

\underline{Question}: If we change the alternative hypothesis to
$H_1: \mu = 50$, what is the MPT then?


\newpage
{\bf Example 3}.
Let $(X_1, \cdots, X_n)$ be a sample from Poisson distribution with mean
$\mu$. To test
\[
H_0: \; \mu = 2 \quad {\rm against}\quad
H_1: \; \mu =6,
\]
the likelihood ratio is
\[
LR=
{ 6^{\sum X_i } e^{-6n} /(X_1! \cdots X_n!) \over
2^{\sum X_i } e^{-2n} /(X_1! \cdots X_n!)}
= 3^{\sum X_i }e^{-4n}.
\]
According to the N-P lemma, the MPT will reject $H_0$ if
$LR > K$, or equivalently, $\sum_i X_i > K_1$, where
the critical value  $K_1$
is determined by the significance level of the test.

Suppose $n=4$, then $\sum_{i=1}^4 X_i \sim Poisson(8)$ under $H_0$.
From the table for Poisson CDFs, the size of test $\alpha = 0.064 $ with
$K_1 = 12$, and $\alpha = 0.034$ with $K_1 = 13$.

When $n=8$, $\sum_{i=1}^8 X_i \sim Poisson(16)$ under $H_0$.
The size of test $\alpha = 0.058 $ with $K_1 = 22$, and
$\alpha = 0.037$ with $K_1 = 23$.

\newpage

{\bf \color{dblue} 3.3 Uniformly Most Powerful Tests}

Although the Neyman-Pearson Lemma was designed for
testing simple hypotheses, it is possible to
use it to construct the UMPT for, for example, {\sl \color{blue}one-sided
null hypothesis} against {\sl \color{blue} one-sided alternative}. 

{\bf \color{dred} A general setting}:
For hypotheses
\begin{equation} \label{ump1}
H_0: \;  \theta \in \Theta_0 \quad
{\rm vs} \quad H_1: \;  \theta \in \Theta_1,
\end{equation}
$\phi(\bX)$ is the decision rule of a test at significant level
$\alpha$, i.e.
\[
E_\theta\{ \phi(\bX) \} \le \alpha \quad \mbox{ for all }
\theta \in \Theta_0.
\]
If $\phi(\bX)$ is also the MPT of size $\alpha$ for {\sl simple hypotheses}
\[
H_0: \;  \theta =\theta_0
\quad
{\rm vs} \quad H_1: \; \theta =\theta_1
\]
for \underline{\color{dmagenta}some} $\theta_0 \in \Theta_0$ and
\underline{\bf \color{dmagenta}all}
$\theta_1 \in \Theta_1$.
Then $\phi(\bX)$  is the UMPT for hypotheses (\ref{ump1}).

\newpage

We look at a simple scenario first --- {\sl \color{dred}
UMPTs for simple $H_0$ and one-sided $H_1$}.

Suppose the MPT for simple hypotheses
\[
H_0: \; \theta = \theta_0 \quad
{\rm against} \quad
H_1: \; \theta = \theta_1
\]
{\sl \color{red} does not change its form for all $\theta_1\in\Theta_1$}.
Then it is also the UMPT for
\[
H_0: \; \theta = \theta_0 \quad
{\rm against}
H_1: \; \theta \in \Theta_1.
\]
Such an UMPT often exists for 
$\Theta_1 = (\theta_0, \infty)$ or
$\Theta_1 = (- \infty, \theta_0)$.


\newpage
{\bf Example 4}.
If $X_1, X_2,\ldots ,X_n$ is a random sample from $N(\mu, 1)$, then the
most powerful test for testing
\[
H_0: \mu=1\quad {\rm vs} \quad
H_1: \mu=2
\]
is obtained by rejecting $H_0$ if and only if $\bar{X}>1+z_{\-\alpha}/\sqrt{n}$.
The same test is obtained for
\[
H_0: \mu=1\quad {\rm vs} \quad
H_1: \mu=\mu_1
\]
for every $\mu_1 > 1$.  So this test is uniformly most powerful for
\[
H_0: \mu=1\quad {\rm vs} \quad
H_1: \mu>1.
\]

Although the UMPT does not depend on the value
$\mu_1$ specified under $H_1$, its power varies over
$\{ \mu | \mu>1\}$. In fact
\begin{eqnarray*}
&&\beta(\mu) = P_\mu\{ \bar X > 1 + z_\alpha/\sqrt{n} \}\\
&=&  P_\mu\{ \sqrt{n}(\bar X - \mu) > \sqrt{n}(1-\mu) + z_\alpha\}\\
&=&
 1 - \Phi\{ z_\alpha - \sqrt{n}(\mu -1) \}
= \Phi\{\sqrt{n}(\mu -1) - z_\alpha\},
\end{eqnarray*}
where $\Phi(\cdot)$ is the CDF of N(0,1). Thus the power increases
as $\mu$ increases.

Note that the test is not the UMPT for $H_1:\mu\not =1$.

{\bf Note}. The UMPT usually does not exist for two-sided (composite)
alternative hypothesis.

\newpage

{\bf Example 5}. Let $Y$ have the binomial distribution $Bin(n,p)$.
Find the UMPT for testing
\[
H_0: p = p_0 \quad
{\rm vs} \quad
H_1: p> p_0.
\]

Let $p_1 >p_0$. The LR for testing the $H_0$ above against $H_1: p = p_1$ is
\begin{eqnarray*}
LR &=& {
\left(
\begin{array}{c}
n\\
Y
\end{array}
\right)
p_1^Y (1-p_1)^{n-Y}
\over
\left(
\begin{array}{c}
n\\
Y
\end{array}
\right)
p_0^Y (1-p_0)^{n-Y}
}\\
&=&
\left(
{p_1(1-p_0) \over p_0 (1-p_1)}
\right)^Y
\left(
{1-p_1\over 1-p_0}
\right)^n
\end{eqnarray*}
Note that $p_1(1-p_0)>p_0 (1-p_1)$ since $p_1 > p_0$. Thus
$LR>K$ is equivalent to $Y>K_1$. Thus the UMPT rejects $H_0$
iff $Y>K_1$ with the size
\[
P(Y>K_1|p=p_0).
\]


\newpage
{\bf Example 6}. Let $(X_1, \cdots, X_n)$ be a random sample from an
exponential distribution with mean $1/\lambda$. We are interested in
testing
\[
H_0: \; \lambda \le \lambda_0 \quad
\mbox{vs} \quad H_1: \; \lambda > \lambda_0.
\]

For
\[
H_0: \; \lambda = \lambda_0 \quad
\mbox{vs} \quad H_1: \; \lambda = \lambda_1,
\]
the MPT rejects $H_0$ iff $\sum_{i=1}^n X_i \le K$ for
any $\lambda_1>\lambda_0$, where
$K$ is determined by
\[
P_{\lambda_0} \{ \sum_{i=1}^n X_i < K \} = \alpha.
\]
It is easy to verify that for $\lambda < \lambda_0$,
\[
P_{\lambda} \{ \sum_{i=1}^n X_i < K \} < \alpha.
\]
Hence the MPT for the simple null hypothesis against simple
alternative is also the UMPT for the composite hypotheses.

\newpage
{\bf \color{dblue} 3.4 Likelihood Ratio Tests}

We now deal with the most popular ways of constructing tests when both
null and alternative hypotheses are composite.
There are no guaranteed
optimality properties in small samples for these tests,
but in regular cases they usually have good power for large sample sizes.

Let $\bX \sim f(\cdot, \btheta)$. Consider hypotheses
\[
H_0: \; \btheta \in \Theta_0 \quad
{\rm vs} \quad
H_1: \; \btheta \in \Theta - \Theta_0.
\]
{\rm \color{blue} The likelihood ratio test} will reject $H_0$
for the large values of 
the  statistic
{\color{blue}
\begin{eqnarray*}
{LR \;} = \; {LR}(\bX) \;
& \equiv &\; { \sup_{\btheta \in \Theta} f(\bX, \btheta) \over
\sup_{\btheta \in \Theta_0} f(\bX, \btheta)}\\
&=& 
 f(\bX, \wh \btheta) \big/ f(\bX, \wt \btheta),
\end{eqnarray*}
}
where $\wh \btheta$ the (unconstrained) MLE, and $\wt \btheta$ is the
constrained MLE under hypothesis $H_0$.

\newpage

{\bf Remark}. (i) It is easy to see that $LR\ge 1$.

(ii) The exact sampling distributions of $LR$ are usually unknown, except
in a few special cases.\\


{\bf Example 7}. {\bf \color{blue} (One-sample $t$-test)}\\
Let $\bX =(X_1, \cdots, X_n)^\tau$ be a random sample
from $N(\mu, \sigma^2)$. We are interested in testing hypotheses
\[
H_0: \; \mu = \mu_0 \quad {\rm against}
\quad
H_1: \; \mu \ne \mu_0,
\]
where $\mu_0$ is given, and $\sigma^2$ is unknown and is a nuisance 
parameter. Now both $H_0$ and $H_1$ are composite.
The likelihood function is
\[
L( \mu, \sigma^2) = C \sigma^{-n} \exp 
\big\{ - {1 \over 2 \sigma^2} \sum_{j=1}^n (X_i - \mu)^2 \big\}.
\]
The unconstrained MLEs are 
\[
\wh \mu = \bar X, \quad
\wh \sigma^2 = {1 \over n} \sum_{j=1}^n (X_i - \bar X)^2,
\]
and the constrained MLE is
\[
\wt \sigma^2 = {1 \over n} \sum_{j=1}^n (X_i - \mu_0)^2.
\]
The LR-ratio statistic is then
\begin{eqnarray*}
LR = {L(\wh \mu, \wh \sigma^2) \over L (\mu_0, \wt \sigma^2) }
= (\wt \sigma^2 / \wh \sigma^2)^{n/2}.
\end{eqnarray*}
Since 
\[
n\wt \sigma^2 = n \wh \sigma^2 + n (\bar X - \mu_0)^2,
\]
it holds that
$
\wt \sigma^2 / \wh \sigma^2 = 1 + T^2/(n-1)
$, where
\[
T = \sqrt{n} (\bar X - \mu_0)\big/ \big\{{1 \over n-1} \sum_{j=1}^n (X_i
- \bar X)^2 \big\}^{1/2}.
\]
Note that $T\sim t_{n-1}$ under $H_0$.
The LRT will reject $H_0$ iff
$|T|> t_{n-1, \alpha/2}$, where $t_{k, \alpha}$ is the upper $\alpha$-point of
the $t$-distribution with  $k$  degrees of freedom.




\newpage

{\bf \color{dred} Asymptotic Distribution of Likelihood ratio test statistic}\\
Let $\bX=(X_1, \cdots, X_n)^\tau$, and 
assume certain regularity conditions.
Then as $n\to \infty$,
{\color {blue}the distribution
of $2 \log  (LR)$ under $H_0$ converges to the $\chi^2$-distribution} with $d-d_0$
degrees of freedom, where
$d$ is the `dimension' of $\Theta$ and $d_0$ is the `dimension'
of $\Theta_0$.


\newpage

To make the computation of `dimension' easy, {\bf reparametrisation} is
often adopted. Suppose that the parameter $\theta$ may be written in two parts
\[
\btheta = (\bpsi, \blambda)
\]
where $\bpsi$ is ${\color{dblue}k }\times 1$ parameter of interest, and 
$\blambda$ is of little interest and is called  {\sl \color{dmagenta}
nuisance parameters}.
The hypotheses to be tested may be expressed as
\[
H_0: \; \bpsi = \bpsi_0 \quad 
{\rm vs} \quad H_1: \; \bpsi \ne \bpsi_0 .
\]
Now the LR-statistic is of the form
\[
LR = { L(\wh \bpsi, \wh \blambda; \bX) \over L(\bpsi_0, \wt \blambda; \bX) },
\]
where $(\wh \bpsi, \wh \blambda)$ is unconstrained MLE while 
$\wt \blambda$ is the constrained MLE of $\blambda$ subject to $\bpsi=\bpsi_0$.
Then  as $n\to \infty$,
{\color{dblue}
\[
2 \log (LR) \wcon \chi^2_k \quad  \mbox{under } H_0.
\] }

\newpage
{\bf Example 8}. Let $X_1, \cdots , X_n$ be independent, and
$X_j \sim N(\mu_j, 1)$. Consider the null hypothesis
\[
H_0: \; \mu_1 = \cdots = \mu_n.
\]
The likelihood function is
\[
L(\mu_1, \cdots, \mu_n) = C\, \exp
\big \{ - {1 \over 2} \sum_{j=1}^n (X_j - \mu_j)^2 \big\},
\]
where $C>0$ is a constant independent of $\mu_j$.
Then the unconstrained MLE are $\wh \mu_j = X_j$ and the constrained
MLE is $\wt \mu = \bar X$. 
Hence
\begin{eqnarray*}
LR &=&  { L(\wh \mu_1, \cdots, \wh \mu_n)  \over
L(\wt \mu, \cdots, \wt \mu) }\\
&=&
\exp \big\{ {1 \over 2} \sum_{j=1}^n (X_j - \bar X)^2\big\}.
\end{eqnarray*}
Hence
\[
2 \log(LR) = \sum_{j=1}^n (X_j - \bar X)^2 \sim \chi^2_{n-1} \quad
{\rm under} \; H_0,
\]
which is true for any finite $n$ as well.\\

How to {\sl \color{dgreen}calculate the degree of freedom}?

Since
\[
d= n, \quad \quad d_0 =1,
\]
the d.f. is $d-d_0 = n-1$.

Alternatively we may adopt the following\\ reparametrisation:
\[
\mu_j = \mu_1 + \psi_j \quad {\rm for} \; 2 \le j \le n.
\]
Then the null hypothesis can be expressed as
\[
H_0: \; \psi_2 = \cdots = \psi_n =0.
\]
Therefore $\bpsi = (\psi_2, \cdots, \psi_n)^\tau$ has $n-1$
component, i.e. $k=n-1$.




