\documentclass[11pt]{article}
\usepackage{amsmath,amssymb}
%\usepackage{fancyhdr}

\parindent=0cm
\parskip .2cm
\textheight 21.7cm
%\pagestyle{fancy}

%\lhead{\nouppercase{\rightmark}}
%\rhead{\nouppercase{\leftmark}}
%\fancyhead[LE,RO]{\thepage}
%\fancyfoot[]{}

\def\bo#1{\mbox{\boldmath $#1$}}
\def\rang{\mathop{\rm rang}}
\def\tr{\mathop{\rm tr}}
\newtheorem{oppgave}{Oppgave}


\begin{document}
%\thispagestyle{empty}
{\bf \Large Solution of assignment in STK4011/STK9011-f17 }

\noindent \textbf{Problem 1}\\
\vspace{0.25 cm} 

\begin{itemize}
\item[a)]
X and Y has probability density $f_X(x)=I_{[0,1]}$, where $I_A(\cdot) $ is the indicator function of the set $A$. 
Also $0\leq X+Y \leq 1$.  Let $U=X+Y$. Then 
\begin{eqnarray*}
f_U(u) &=& \int_{-\infty}^{\infty}I_{[0,1]}(u-x)I_{[0,1]}(x)dx =\int_{0}^{1}I_{[0,1]}(u-x)dx \\
&=&\left \{ \begin{array}{cc} 
\int_{0}^{u}I_{[0,1]}(u-x)dx & \mbox{ if }  0 \leq u \leq 1       \\
\int_{u-1}^{1}I_{[0,1]}(u-x)dx & \mbox{ if }  1 \leq u \leq 2 
\end{array} \right. \\
&=&\left \{ \begin{array}{cc} 
u & \mbox{ if }  0 \leq u \leq 1       \\
2-u & \mbox{ if }  1 \leq u \leq 2 
\end{array} \right.
\end{eqnarray*}
\item[b)] The moment generating function of X is $M_X(t)=E[e^{tX}]= \int_{0}^{1} e^{tx}dx= \frac{1}{t}(e^{t}-1) $.
Hence $M_U(t)=M_{X+Y}(t)= [\frac{1}{t}(e^{t}-1)][\frac{1}{t}(e^{t}-1)]=
(e^{2t}-2e^{t}+1)/t^2 $.

On the other hand also 
\begin{eqnarray*}M_U(t) =&\int_{0}^{2}e^{tu}f_U(u)du=
\int_{0}^{1}ue^{tu}du + \int_{1}^{2}(2-u)e^{tu}du \\
=& 2\frac{1}{t}e^{tu}\vert_{u=1}^{u=2}+
u\frac{1}{t}e^{tu}\vert_{u=0}^{u=1} - \int_{0}^{1}\frac{1}{t} e^{tu}du - u\frac{1}{t}e^{tu}\vert_{u=1}^{u=2} 
+\int_{1}^{2}\frac{1}{t} e^{tu}du \\
 =& \frac{2}{t} e^{2t}- \frac{2}{t}  e^{t} + \frac{1}{t}  e^{t}- \frac{1}{t^2}  e^{t} +\frac{1}{t^2} 
 -\frac{2}{t}  e^{2t} +\frac{1}{t}  e^{t} +\frac{1}{t^2}  e^{t2} - \frac{1}{t^2}  e^{t} \\
  =&(e^{2t}-2e^{t}+1)/t^2.
\end{eqnarray*}
\item[c)] Let $V=U+Z=X+Y+Z$. Then $0 \leq V \leq 3$  and 
\begin{eqnarray*}
f_V(v) &=& \int_{-\infty}^{\infty}f_U(v-z) f_Z(z)dz \\ \\
&=&\left \{ \begin{array}{ll} 
\int_{0}^{v}(v-z)I_{[0,1]}(v-z)dz & \mbox{ if }  0 \leq v \leq 1       \\
\int_{v-1}^{1}(v-z)I_{[0,1]}(v-z)dz +  \int_{0}^{v-1}[2-(v-z)]I_{(1,2]}(v-z)dz & \mbox{ if }  1 \leq v\leq 2 \\
\int_{v-2}^{1}[2-(v-z)]I_{(1,2]}(v-z)dz & \mbox{ if }  2 \leq v\leq 3
\end{array} \right. \\ \\
&=&\left \{ \begin{array}{ll} 
v^2- v^2/2 = v^2/2 & \mbox{ if }  0 \leq v \leq 1       \\
v(2-v) - \frac{1}{2} +  \frac{1}{2}(v-1)^2 + (v-1)(2-v) + \frac{1}{2} (v-1)^2 & \mbox{ if }  1 \leq v\leq 2 \\
(3-v)(2-v) +  \frac{1}{2} - \frac{1}{2}(v-2)  & \mbox{ if }  2 \leq v\leq 3
\end{array} \right.\\ \\
&=&\left \{ \begin{array}{ll} 
v^2- v^2/2 = v^2/2 & \mbox{ if }  0 \leq v \leq 1       \\
-v^2 +3v-1- \frac{1}{2} & \mbox{ if }  1 \leq v\leq 2 \\
\frac{1}{2} v^{2}- 3v +4 + \frac{1}{2}& \mbox{ if }  2 \leq v\leq 3
\end{array} \right.
\end{eqnarray*}
\end{itemize}

\newpage
\noindent \textbf{Problem 2}\\
\vspace{0.25 cm} 

\begin{itemize}
\item[a)] 
\[
F_X(x)= 
\beta \alpha^{\beta} \int_{\alpha}^{x}\frac{1}{y^{\beta + 1}}dy=
\beta \alpha^{\beta}\frac{1}{-\beta} y^{-\beta}\vert_{y=\alpha}^{x}=
1- (\frac{\alpha}{x})^{\beta} \mbox{   for }    x> \alpha.  
\]
\item[b)] 
\[
E[X^k]= \beta \alpha^{\beta} \int_{\alpha}^{\infty}\frac{x^{k}}{x^{\beta + 1}}=
\beta \alpha^{\beta}\frac{1}{k-\beta} x^{k-\beta}\vert_{x=\alpha}^{\infty}= \left \{
\begin{array} {cc} \frac{\beta    \alpha^{k}}{\beta-k}  & \mbox{ if } k<\beta. \\
\infty & \mbox{else} \end{array} \right.
\]
\item[c)] 
\begin{eqnarray*}
f(x\vert \alpha, \beta)&=& \left \{ \begin{array}{cl}  \frac{\beta\alpha^{\beta}}{x^{\beta+1}} & \mbox{ if } \alpha \leq x <\infty
\;\;\alpha, \beta >0 
\\
0 & \mbox{  else }\end{array} \right. \\
&=& \exp(-(\beta +1)\log x)\beta \alpha^{\beta}I_{[\alpha,\infty)}(x).
\end{eqnarray*}
By defining  
$h(x)=I_{[\alpha,\infty)}(x)$ which is not involving unknown parameters since $\alpha$ 
is known, $c(\beta)= \beta \alpha^{\beta}$, $t(x)= \log x$  and $w(\beta)= -(\beta+1)$
$f(x\vert \beta)$ can be written on the form $h(x)c(\beta)\exp[w(x)t(x)]$ 
which is the definition of an exponential family.

If $U=\log X / \alpha$, the inverse transformation is $X=\alpha\exp(U)$. Hence the density
of U is $g_U(u\vert \beta)= \beta \alpha^{\beta} \exp(-(\beta+1)u)\alpha^{-\beta-1}\alpha \exp (u)= \beta\exp(-\beta u)$  for $u >0$ since $x > \alpha$. 



\item[d)] The likelihood equals
\[
L(\alpha,\beta \vert x_1,\ldots,x_n)=  \prod_{i=1}^n \beta \alpha^{\beta}\frac{1}{x_i^{\beta +1}}
I_{[\alpha,\infty)}(x_i)= 
\alpha^{n\beta} \exp( n \log \beta - (\beta +1)
\Sigma_{i=1}^{n} \log x_i  )I_{[\alpha,\infty)}(x_{(1)})
\]
where $x_{(1)}= \min_{i=1,\ldots,n} x_i$. Because $\beta \alpha^{\beta}I_{[\alpha,\infty)}(x_{(1)})$ 
is increasing for   $\alpha \leq x_{(1)}$ and equal to $0$ for $\alpha > x_{(1)}$, $\hat{\alpha}=x_{(1)} $
and 
\begin{eqnarray*}
L(\hat{\alpha}(\beta),\beta \vert x_1,\ldots,x_n)&=&
\exp( n \log \beta - (\beta +1)
\Sigma_{i=1}^{n} \log x_i   -[(n(\beta+1) -n] \log x_{(1)})\\
&=& \exp( n \log \beta - (\beta +1)
\Sigma_{i=1}^{n} \log x_i / x_{(1)}   -n \log x_{(1)})
\end{eqnarray*}
Hence
\[
\log L(\hat{\alpha}(\beta),\beta \vert x_1,\ldots,x_n)=\exp( n \log \beta - (\beta +1)
\Sigma_{i=1}^{n}  \log x_i / x_{(1)}   -n \log x_{(1)})
\]
so
\[
\frac{\partial }{ \partial \beta} \log L(\hat{\alpha}(\beta),\beta \vert x_1,\ldots,x_n)= \frac{n}{\beta} - 
\Sigma_{i=1}^{n}  \log x_i / x_{(1)} 
\]
and $\hat{\beta}= n/\Sigma_{i=1}^{n}  \log x_i / x_{(1)}$.  Also $\frac{\partial^{2} }{ \partial \beta^{2}} \log L(\hat{\alpha}(\beta),\beta \vert x_1,\ldots,x_n)= -n/\beta^{2} <0$ so the stationary point is a maximum since
there is only one stationary point.
%%
\item[e)]  Because $U_i= \log X_i -\alpha,\; i=1,\ldots, n$ are independent and exponentially distributed random variables, $(\log X_{(1)}-\alpha, \log X_{(2)}/X_{(1)},\ldots, \log X_{(n)}/X_{(1)})$ has the same distribution
as $(U_{(1)}, U_{(2)}-U_{(1)},\ldots, U_{(n)}-U_{(1)})$ where $(X_{(1)},\ldots, X_{(n)})$ and 
$(U_{(1)},\ldots, U_{(n)})$ are the order statistics.
Hence independence of $X_{(1)} $ and 
$\Sigma_{i=1}^{n}  \log X_i / X_{(1)} =\Sigma_{i=2}^{n}  \log X_{(i)} / X_{(1)} $ will follow fram independence of $U_{(1)}$ and $\Sigma_{i=2}^{n} (U_{(i)}-U_{(1)})$.

To show that consider the transformation $V_1=U_{(1)}, V_{i}= (n-i+1)(U_{(i)}-U_{(i-1)}),
,\;i=2,\ldots,n$
with inverse transformation 
\begin{eqnarray*}
U_{(1)}&=&V_1\\ 
U_{(2)} &=& V_2/(n-1)+ V_1 \\
U_{(3)} &=& V_3/(n-2)+ U_{(2)} = V_3/(n-2)+ V_2/(n-1)+ V_1\\
\vdots \\
U_{(n)}&=&  \Sigma_{i=2}^{n}V_i/(n-i+1) +V_1
\end{eqnarray*}
Because $\Sigma_{i=1}^{n} U_{(i)}=\Sigma_{i=2}^{n} V_i +nV_1$ and the Jacobian is equal to $1/(n-1)!$,
the simultanous density of $(V_1,\ldots,V_n)$ is 
$n !\exp(-\beta (v_2+\cdots+v_n)- n\beta v_1)/(n-1)!$.
Thus the simultanous density factorizes, so $V_1=U_{(1)}$ and  $(V_2,\ldots,V_n)= (n-2)(U_{(2)}-U_{(1)}),\ldots, U_{(n)}-U_{(1)})$ are independent and therefore also $U_{(1)}$ and $\Sigma_{i=2}^{n} (U_{(i)}-U_{(1)})$.


The  cumulative distribution function of a Pareto distributed random variable is $F_X(x)= \int_{\alpha}^{x}
\frac{\beta\alpha^{\beta}}{y^{\beta+1}}dy= - \alpha^{\beta}y^{-\beta}\vert_{\alpha}^{x}= 1-(\frac{\alpha}{x})^{\beta}$.

The cumulative distribution function of $\hat{\alpha}$ is $F_{\hat{\alpha}} = P(\hat{\alpha} \leq x)= P( X_{(1)} \leq x)= 1-P(X_{(1)} > x)= 1-P(X_1>x, \cdots,X_n>x)= 1- [1-F_X(x)]^{n}= 1-(\frac{\alpha}{x})^{n\beta}$,
so $\hat{\alpha}$  is Pareto distributed with parameters $\alpha$ and $n\beta $.

From the results above $\Sigma_{i=2}^{n}  \log X_{(i)} / X_{(1)} $  has the same distribution as
$\Sigma_{i=2}^{n}( U_{(i)}-U_{(1)})=\Sigma_{i=2}^{n} V_i $.
The random variables $V_2,\cdots,V_n$ are independent gamma$(1,1/\beta)$ distributed variables,
so $2\beta V_1,\cdots,2 \beta V_n $ are independently  distributed  $\chi^{2}_{2}$  random variables.
Then $2\beta \Sigma_{i=2}^{n} V_i$ 
is $ \chi_{2(n-1)}^{2}$ distributed and so is  $2n\beta/\hat{\beta}= 2\beta \Sigma_{i=2}^{n}  \log X_{(i)} / X_{(1)} $.  
\item[f)]
The joint probability density is
\begin{eqnarray*}
&f(x_1,\ldots,x_n\vert \alpha,\beta)\\= & \prod_{i=1}^n \beta \alpha^{\beta}\frac{1}{x_i^{\beta +1}}
I_{[\alpha,\infty)}(x_i)\\
=&\exp( n\beta \log \alpha + n \log \beta - (\beta +1)
\Sigma_{i=1}^{n} \log x_i  )I_{[\alpha,\infty)}(x_{(1)})\\
=&\exp(- (\beta +1)
\Sigma_{i=1}^{n} \log x_i/x_{(1 )} - n(\beta +1)  \log x_{(1 )} /\alpha + n \log \beta \alpha + n\log x_{(1 )} )I_{[\alpha,\infty)}(x_{(1)}).
\end{eqnarray*}
The density can therefore be expressed as a function of the parameters $\alpha$ and $\beta $
 and  the functions $\Sigma_{i=1}^{n} \log x_i/x_{(1 )}$ and $x_{(1 )}$.
 From the factorization theorem, it then follows that the statistic $(X_{(1 )},\Sigma_{i=1}^{n} \log X_i/X_{(1 )}) $
is sufficient for the parameters $\alpha$ and $\beta $.
\item[g)] 
From part d) $2n\beta/\hat{\beta}$ is $\chi^{2}_{2(n-1)}$ distributed so
$E[ \frac{1}{2n\beta/\hat{\beta}}]=1/2(n-2)$
since $E[X]=1/(k-2) $  when $X \sim \chi^{2}_k,\; k>2$, see Casella and Berger p.130.
 Thus $E[\hat{\beta}]= 2n\beta/2(n-2)=n\beta/(n-2)$. Therefore 
$(n-2)\hat{\beta}/n$ is an unbiased estimator of $\beta$. Since it is a function of the complete and 
sufficient statistic   $(X_{(1 )},\Sigma_{i=1}^{n} \log X_i/X_{(1 )}) $ it is UMVUE or the best unbiased
estimator.        
\item[h)] 
For $\hat{\alpha}$, write
\[
X_{(1)}[1- \frac{1}{(n-1)} \frac{1}{\hat{\beta}}]=
X_{(1)}[1- \frac{1}{(n-1)} \frac{2n \beta}{\hat{\beta}}\frac{1}{2n \beta}].
\]
Using that $2n\beta/\hat{\beta}$ is $ \chi_{2(n-1)}^{2}$ distributed and that $X_{(1)}$ and 
 $\hat{\beta}$ are independent it follows that
 \[
E\{X_{(1)}[1- \frac{1}{(n-1)} \frac{1}{\hat{\beta}}]\}=
\frac{n\beta \alpha }{n\beta-1}[1- \frac{1}{(n-1)} \frac{2(n-1)}{2n \beta}]=
\frac{n\beta \alpha }{n\beta-1}\frac{n\beta-1}{n\beta} = \alpha .
\]
Hence, $X_{(1)}[1- \frac{1}{(n-1)} \frac{1}{\hat{\beta}}]$ is an unbiased estimator of $\alpha$.
It is also a function of the complete and 
sufficient statistic   $(X_{(1 )},\Sigma_{i=1}^{n} \log X_i/X_{(1 )}) $ and is therefore UMVUE or the best unbiased estimator for $\alpha$. 
\end{itemize}

\noindent \textbf{Problem 3}\\
\vspace{0.25 cm} 
\begin{itemize}

\item[a)] The probability density function of the logistic distribution is $f(x\vert \theta)=
\frac{\exp(-(x-\theta))}{[1+\exp(-(x-\theta))]^{2}}=
\frac{1}{[\exp((x-\theta)/2)+ \exp(-(x-\theta)/2))]^{2}}$ which is symmetric about $\theta$.
Hence $E[X]=\theta$ and  the method of moment estimator is therefore
 $\theta_n^{*}= \frac{1}{n}\Sigma_{i=1}^{n} X_i$. Because $Var{X_i} = \pi^{2}/3$,
$E[X_i]=\theta$ and $X_1,\ldots, X_n$ are independent, it follows from the central limit theorem
that 
\[
\frac{\sqrt{n}(\bar{X}- \theta)}{\sqrt{\pi^{2}/3}}=\frac{\sqrt{3n}(\bar{X}- \theta)}{\pi} \rightarrow n(0,1).
\]
\item[b)] The logarithm of the likelihood is
\[
\log L(\theta \vert x_1,\ldots, x_n)= -\Sigma_{i=1}^{n}(x_i - \theta)-2 \log[1+\exp(-(x_i-\theta))].
\]
The first order condition  for maximisation of $\log L(\theta \vert x_1,\ldots, x_n)$ is
\[
n- \Sigma_{i=1}^{n}\frac{2\exp(-(x_i-\theta))}{1+\exp(-(x_i-\theta)}= 2[\frac{n}{2}- \Sigma_{i=1}^{n}  
\frac{1}{1+\exp(x_i -\theta)}  ]= \Sigma_{i=1}^{n} \frac{1-\exp(-(x_i-\theta))}{1+\exp(-(x_i-\theta))}=0.
\]  
One more differentiation yields
\[
 -2 \Sigma_{i=1}^{n} \frac{\exp(-(x_i-\theta))}{[1+\exp(-(x_i-\theta))]^{2}} <0.
\]
which shows that $ \partial log L(\theta \vert x_1,\ldots, x_n)/ \partial \theta $ is decreasing.
But \\ 
$\lim_{\theta \rightarrow -\infty} \partial log L(\theta \vert x_1,\ldots, x_n)/ \partial \theta = n$ 
and $\lim_{\theta \rightarrow \infty} \partial log L(\theta \vert x_1,\ldots, x_n)/ \partial \theta = -n$
so the solution exists and is unique.
%%
\item[c)] The properties of the MLEs imply that  $\frac{\sqrt{n}(\hat{\theta}_n- \theta)}{{\sqrt{I(\theta)^{-1}} }}   $ 
where $I(\theta)$ is the Fisher information of one observation, converges in distribution toward a standard normal variable.
But 
\[
I(\theta)= \int_{-\infty}^{\infty} [\frac{\partial }{\partial \theta} \log f(x\vert \theta)]^{2} f(x\vert \theta) dx = 1/3.
\]
so $\sqrt{n}(\hat{\theta}- \theta)\rightarrow n(0,3)$ in distribution. The asymptotic relative efficiency of
$\theta_n^{*}$ with respect to $\hat{\theta}_n$ is therefore $3/(\pi^{2}/3)= 9/\pi^{2}$.
\item[d)] Based on one observation, $X_1$, we will test
\[
H_0: \theta=\theta_0 \mbox{    versus the alternative hypothesis   } H_1: \theta>\theta_0.
\]
Consider first
\[
H_0: \theta=\theta_0 \mbox{    versus the alternative hypothesis   } H_1: H_1^{\prime}: \theta =\theta_1.
\]
where $\theta_1 > \theta_0$. From the Neyman-Pearson lemma it follows that the rejection region for the uniformly most powerful, UMP, test is give by
\[
\frac{f(x\vert \theta_1)}{f(x\vert \theta_0)}=
\frac{\frac{\exp(-(x-\theta_1))}{[1+\exp(-(x-\theta_1))]^{2}}}
{\frac{\exp(-(x-\theta_0))}{[1+\exp(-(x-\theta_0))]^{2}}}
=
(\frac{ \exp(x)+ \exp(\theta_0)  }{ \exp(x)+ \exp(\theta_1) })^{2} \exp(\theta_1-\theta_0)>k.
\]



Because $\theta_1 > \theta_0$, $\exp(\theta_1 - \theta_2)>1$ and 
$[\exp(x)+ \exp(\theta_0)]/[\exp(x)+ \exp(\theta_1)]$ is increasing in x.
Therefore $\frac{f(x\vert \theta_1)}{f(x\vert \theta_0)} >k$ is equivalent to $x>k^{\prime}$.
The UMP test with level $\alpha$ for 
\[
H_0: \theta=\theta_0 \mbox{    versus the alternative hypothesis   } H_1^{\prime}: \theta =\theta_1.
\]
rejects if $x > k_{\alpha}$ where $k_{\alpha}$ is the $1-\alpha$ quantile of the logistic
distribution when $\theta=\theta_0$, i.e  $1/[1+ \exp(-(k_{\alpha}-\theta_0))]= \alpha$ or
$k_{\alpha}= \theta_0- \log \frac{\alpha}{(1-\alpha)}$.

The UMP test has therefore rejection region $\{ x_1 : x_1 > \theta_0- \log \frac{\alpha}{(1-\alpha)}\}$. 
This region is the same for all $\theta_1 > \theta_0$ and the test must therefore be UMP also for 
\[
H_0: \theta=\theta_0 \mbox{    versus the alternative hypothesis   } H_1: \theta>\theta_0.
\]
%%
\item[e)] The power function for the test in part d) is
\[
\beta(\theta)= P_{\theta}(X_1> \theta_0 -\log \frac{\alpha}{(1-\alpha)}) = 
\frac{\exp(-\theta_0 +\theta  +\log \frac{\alpha}{(1-\alpha)})}
{1+\exp(-\theta_0 +\theta  +\log \frac{\alpha}{(1-\alpha)})   }
\]
which is an increasing function in $\theta$. The test from part d) therefore has level $\alpha$
for 
\[
H_0: \theta \leq \theta_0 \mbox{    versus the alternative hypothesis   } H_1: \theta>\theta_0.
\]
The tests with level $\alpha$ for $H_0: \theta \leq \theta_0$  is a subset of the tests 
with level $\alpha$ for $H_0: \theta =\theta_0$. But the test from part d) is UMP in the larger set.
Since it also is an element in the smaller set, it must be UMP in this set.
Thus it is also UMP for 
\[
H_0: \theta \leq \theta_0 \mbox{    versus the alternative hypothesis   } H_1: \theta>\theta_0.
\]

Alternatively, one can show that the logistic density has a monotone likelihood ratio, and appeal to
results for tests for set of distributions satisfying this requirement.

\end{itemize}


\end{document}
