\documentclass[12pt,a4paper]{article}
\usepackage{amsthm,amsmath,amsfonts}
\usepackage{latexsym}
\usepackage{fancyhdr}
\usepackage{enumerate}
%\usepackage{marginnote}
\usepackage{graphicx}
\usepackage{skull}
\usepackage{hyperref}
\usepackage{fancybox}
\usepackage{xspace}

%%From web for code highlighting::
\usepackage{listings}

\usepackage{cmbright}

\addtolength{\parskip}{1ex}

\baselineskip = 6mm
%\parskip = 2mm

\textheight 23.6cm
\textwidth 16.6cm
\oddsidemargin 0.0cm
\evensidemargin 0.0cm
\topmargin -1.4cm
%\headsep -.60in

\setlength{\parindent}{0cm}

\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

\rhead{}

\newcommand{\pr}[2][]{\ensuremath{\mathrm{Pr}_{#1}\!\left(#2\right)}}
\newenvironment{myhighlight}{\textit}{}
\renewenvironment{emph}{\textbf}{}
\newcommand{\Exp}[2][]{\ensuremath{\mathrm{Exp}\left(#2\right)}}
\newcommand{\Bin}[2][]{\ensuremath{\mathrm{Bin}\left(#2\right)}}
\newcommand{\Po}[2][]{\ensuremath{\mathrm{Po}\left(#2\right)}}
\newcommand{\cov}[2][]{\ensuremath{\mathrm{Cov}\left(#2\right)}}
\newcommand{\cor}[2][]{\ensuremath{\mathrm{Cor}\left(#2\right)}}
\newcommand{\diag}[2][]{\ensuremath{\mathrm{diag}\left(#2\right)}}
\newcommand{\given}{\ensuremath{\ |\ }}
\newcommand{\stationary}{\ensuremath{\vec{\pi}}}
\newcommand{\identity}{\ensuremath{\vec{I}}}
\renewcommand{\vec}[1]{\underline{#1}}
\newcommand{\remove}[1]{}
%\newcommand{\cover}[2]{\hi{#1}}
\newcommand{\cover}[2]{#2}
\newcommand{\hi}[2][]{\textbf{#2}}
\newcommand{\bigfont}{\fontsize{1.45cm}{1.5cm}\selectfont}
\newcommand{\announce}{\setbeamercolor{structure}{fg=green!60!black}}
\newcommand{\sol}{\setbeamercolor{structure}{fg=purple!80!black}}
\newcommand{\normal}{\setbeamercolor{structure}{fg=blue!60!green}}
\newcommand{\vsp}{\vspace{0.3cm}}
\newcommand{\vspl}{\vspace{0.15cm}}
\newcommand{\xvec}{\boldsymbol{x}}
\newcommand{\yvec}{\vec{y}}
\newcommand{\Xvec}{\boldsymbol{X}}
\newcommand{\Yvec}{\vec{Y}}
\newcommand{\Evec}{\vec{E}}
\newcommand{\tvec}{\bodsymbol{t}}
\newcommand{\Tvec}{\bodsymbol{T}}
\newcommand{\mutau}{\begin{pmatrix}\mu\\\tau\end{pmatrix}}
\newcommand{\thetavec}{\vec{\theta}}
\newcommand{\thetavechat}{\vec{\hat\theta}}
\newcommand{\thetahat}{\hat\theta}
\newcommand{\xvece}{\boldsymbol{x}=(x_1,x_2,\ldots,x_n)^T}
\newcommand{\Xvece}{\boldsymbol{X}=(X_1,X_2,\ldots,X_n)^T}
\newcommand{\thetavece}{\vec{\theta}=(\theta_1,\theta_2,\ldots,\theta_p)^T}
\newcommand{\exxvec}{$x_1,x_2,\ldots,x_n$\xspace}
\newcommand{\exxvecdot}{$x_1,x_2,\ldots,x_n$.\ }
\newcommand{\exXvec}{$X_1,X_2,\ldots,X_n$\ }
\newcommand{\muvec}{\vec{\mu}}



\newtheoremstyle{exmp}% hnamei
{3pt}% hSpace abovei
{3pt}% hSpace belowi
{}% hBody fonti
{}% hIndent amounti1
{\bf}% hTheorem head fonti
{:}% hPunctuation after theorem headi
{.5em}% hSpace after theorem headi2
{}% hTheorem head spec (can be left empty, meaning `normal')i
\theoremstyle{exmp}
\newtheorem{example}{\textcolor{purple}{\textbf{Example}}}[section]

%\def \var{{\textrm{Var}}}
\newcommand{\E}[2][]{\ensuremath{\mathrm{E}\left[#2\right]}}
\def \R{\mathbb{R}}
\def \Z{\mathbb{Z}}
\def \proof{\noindent{\bf Proof:  }}
\def \eproof{\qed\vskip .3cm}
\def \union{\cup}
\def \intersect{\cap}
\newcommand{\ex}[2][]{\ensuremath{\mathrm{E}_{#1}\!\left[#2\right]}}
\newcommand{\var}[2][]{\ensuremath{\mathrm{Var}_{#1}\left(#2\right)}}
%\renewcommand{\det}[1][]{\ensuremath{\mathrm{det}\left(#1\right)}}
\newtheorem{defn}{Definition}
%\newtheorem*{example}{Example}
\newtheorem{result}{Result}[section]
\newtheorem{algorithm}{Algorithm}[section]

\usepackage{Sweave}
\usepackage[usenames, dvipsnames]{xcolor}
\begin{document}

%%From web for code/highlighting
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\definecolor{light-gray}{gray}{0.95}
\definecolor{LEEgreen}{rgb}{0.04,0.667,0.137}

\lstset{ 
  backgroundcolor=\color{light-gray},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
  basicstyle=\footnotesize,        % the size of the fonts that are used for the code
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % sets automatic line breaking
  captionpos=b,                    % sets the caption-position to bottom
  commentstyle=\color{mygreen},    % comment style
  deletekeywords={...},            % if you want to delete keywords from the given language
   escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  extendedchars=false,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  frame=single,	                   % adds a frame around the code
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  keywordstyle=\color{blue},       % keyword style
  language=R,                 % the language of the code
  morekeywords={*,...},            % if you want to add more keywords to the set
  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
  numbersep=5pt,                   % how far the line-numbers are from the code
  numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % underline spaces within strings only
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=1,                    % the step between two line-numbers. If it's 1, each line will be numbered
  stringstyle=\color{mymauve},     % string literal style
  tabsize=2,	                   % sets default tabsize to 2 spaces
  title=\lstname                   % show the filename of files included with \lstinputlisting; also try caption instead of title
}


%\SweaveOpts{concordance=TRUE}

\pagenumbering{gobble}

\setcounter{page}{-3} % to get contents page labelled (i)

%%%Practicals
%\section*{Aims}
%This introductory practical is split into two parts:
%\begin{itemize}
%\item In the first hour or so, we will focus on the basics of R, revising some of the key concepts from last year's MAS1802 material
%\item In the second hour we will focus on material from this week's lecture -- using R to simulate from standard probability distributions, as well as more complex models including mixture distributions
%\end{itemize}


%\vspace{0.25cm}

%\noindent Please read through all of this handout \textit{very carefully}, and follow the instructions \textit{meticulously}. Whenever
%you are typing commands into R, make sure you do so \textit{extremely carefully}. If you get an error message,
%try typing the code in again, just to make sure you've not made a spelling mistake or other simple typo. A
%common error is to forget that R is case sensitive, so use upper/lower cases exactly when you're told to
%do so.

%\vspace{0.25cm}

%\noindent For all R practicals, make sure you've got your lecture notes handy.


%\section*{Getting started}
%\noindent Log-in to a PC in the usual way. Now open Rstudio. If you can't remember how to do this, click on the ``Start'' button in the bottom
%left-hand-corner and search for ``rstudio''. Once you've opened Rstudio you should see four panels; if there is no text editor (usually the top-left panel), click on the green button with a white plus symbol and open a new R script. Remember -- to execute a line of code in the text editor, hit \texttt{Ctrl}-\texttt{Enter}.

%\vspace{0.25cm}

%\noindent It is good practice to always use the text editor, rather than type into the console window (bottom-
%left panel) directly. This is especially true in future practicals when you may be building large functions; it
%is much easier to de-bug and edit code in the text editor than in the console window.

%\vspace{0.25cm}

%\noindent \textbf{Hint: To commit several lines of code in one go, highlight your block of code in the text editor and hit \texttt{Ctrl}-\texttt{Enter} just once!}

%\vspace{0.25cm}

%\noindent Now you've got Rstudio open, you're ready to go!  Try out \textit{all} of the following exercises.  

%\newpage

\lhead{MAS3902}
\rhead{Bayesian Inference}

\section*{Bayesian Inference: Assignment 4}
\noindent Answers to the starred (\textbf{*}) questions should be submitted to Canvas by no later than \textcolor{red}{\bf 4pm, Friday 3rd May 2024}.  Solutions to non-assessed questions will be made available in class.  


\subsection*{Question 1*}
The following probability density function (PDF) is often used in geology, for example to model the size of meteorites:
\[
f(x|\alpha,\theta)
=\frac{\alpha\theta^\alpha}{x^{\theta+1}},\quad x>\theta
\]
where $\alpha>0$ and $\theta>0$.

Suppose \exxvec are a random sample of meteorite sizes; suppose further, from previous studies, we assume that $\alpha=1$ in the PDF above.  
\begin{itemize}
\item [(a)] Determine the Jeffreys prior for $\theta$.
\item [(b)] Determine the posterior distribution for $\theta$, assuming a very large sample.  
\end{itemize}

\subsection*{Question 2*}
  The salaries $X$ of a random sample of $n$ workers in a city follow a
  reparameterised log-normal $RLN(\mu,\alpha)$ distribution, where
  $(\mu,\alpha)\in\mathbb{R}^2$ and
\[
f(x|\mu,\alpha)=
\frac{e^{\alpha/2}}{x\sqrt{2\pi}}
\exp\left\{-\frac{e^\alpha}{2}(\log x-\mu)^2\right\},\quad x>0.
\]
Find the Jeffreys prior for $(\mu, \alpha)^{T}$.

\textcolor{gray}{
Hint: If $X\sim RLN(\mu,\alpha)$ then $E(\log X)=\mu$ and $Var(\log
X)=e^{-\alpha}$.   
}

\subsection*{Question 3}  
  A random sample $\xvece$ is taken from a log-normal
  $LN(\mu,\sigma^2)$ distribution. %Find the Jeffreys prior.
\begin{itemize}
\item [(a)] Find the Jeffreys prior.
\item [(b)] Is this a proper prior distribution?  Explain your answer.
\end{itemize}

\newpage
 
\subsection*{Question 4}
Suppose that you have a random sample $\xvece$ from a $Ga(\alpha,\lambda)$ distribution.
\begin{enumerate}[(a)]
\item Determine the asymptotic posterior distribution for
  $\thetavec=(\alpha,\lambda)^T$. Hint: you should define the maximum
  likelihood estimates $\hat\alpha$ and $\hat\lambda$ in terms of the
  equations they must satisfy, with these involving the sample mean
  $\bar x$, the geometric mean $\bar x_g$ and the digamma function
  $\psi(x)=\Gamma'(x)/\Gamma(x)$.
\item Suppose a sample of size $n=100$ gives sample mean $\bar x=3.0$
  and geometric mean $\bar x_g=2.5$ leading to maximum likelihood
  estimates $\hat\alpha=2.8983$ and $\hat\lambda=0.9661$. Determine
  the asymptotic posterior distribution for $\thetavec$. Also
  calculate the asymptotic posterior correlation between $\alpha$ and
  $\lambda$.  Hint: you will need to use the \texttt{R} functions
  \texttt{digamma} for $\psi(\cdot)$ and \texttt{trigamma} for
  $\psi'(\cdot)$.
\end{enumerate}



\newpage

\section*{Solutions}


\subsection*{Question 3}
\begin{enumerate}[(a)]
\item The likelihood function is
\begin{align*}
f(\xvec|\mu,\sigma)&=\prod_{i=1}^n\frac{1}{\sqrt{2\pi}\sigma x_i}
\exp\left\{-\frac{1}{2\sigma^2}(\log x_i-\mu)^2\right\}\\
&\propto\sigma^{-n}\exp\left\{-\frac{1}{2\sigma^2}\sum_{i=1}^n(\log x_i-\mu)^2\right\}.
\end{align*}
We have
\begin{align*}
\log f(\xvec|\mu,\sigma)&=-n\log\sigma-\frac{1}{2\sigma^2}\sum_{i=1}^n(\log x_i-\mu)^2\\
\Longrightarrow\quad&\frac{\partial}{\partial\mu} \log
f(\xvec|\mu,\sigma)=\frac{1}{\sigma^2}\sum_{i=1}^n(\log x_i-\mu)\\
&\frac{\partial}{\partial\sigma} \log
f(\xvec|\mu,\sigma)=-\frac{n}{\sigma}+\frac{1}{\sigma^3}\sum_{i=1}^n(\log x_i-\mu)^2\\
\Longrightarrow\quad&\frac{\partial^2}{\partial\mu^2} \log
f(\xvec|\mu,\sigma)=-\frac{n}{\sigma^2}\\
&\frac{\partial^2}{\partial\mu\partial\sigma} \log
f(\xvec|\mu,\sigma)=-\frac{2}{\sigma^3}\sum_{i=1}^n(\log x_i-\mu)\\
&\frac{\partial^2}{\partial\sigma^2} \log
f(\xvec|\mu,\sigma)=\frac{n}{\sigma^2}-\frac{3}{\sigma^4}\sum_{i=1}^n(\log x_i-\mu)^2.
\end{align*}
Now, given our knowledge of the log-normal distribution (would be provided as a hint in the exam), $\log X_i\sim N(\mu,\sigma^2)$ and so
\[
E(\log X_i|\mu,\sigma)=\mu\quad\text{and}\quad 
E\{(\log X_i-\mu)^2|\mu,\sigma)=Var(\log X_i|\mu,\sigma)=\sigma^2.
\]
Therefore, the elements of Fisher's information matrix are
\begin{align*}
I_{11}&=E_{\Xvec|\mu,\sigma}
\left[-\frac{\partial^2}{\partial\mu^2} \log
f(\Xvec|\mu,\sigma)\right]=\frac{n}{\sigma^2}\\
I_{12}&=E_{\Xvec|\mu,\sigma}
\left[-\frac{\partial^2}{\partial\mu\partial\sigma} \log
f(\Xvec|\mu,\sigma)\right] =\frac{2n}{\sigma^3}\,E_{X|\mu,\sigma}[\log X-\mu]=0\\
I_{22}&=E_{\Xvec|\mu,\sigma}
\left[-\frac{\partial^2}{\partial\sigma^2} \log
f(\Xvec|\mu,\sigma)\right]=-\frac{n}{\sigma^2}+\frac{3n}{\sigma^4}\,E_{X|\mu,\sigma}[(\log X-\mu)^2]=\frac{2n}{\sigma^2}.
\end{align*}
Hence, Fisher's information matrix is
\[
I(\mu,\sigma)
=\frac{n}{\sigma^2}\begin{pmatrix} 1 & 0 \\ 0 & 2 \\ \end{pmatrix},
\]
from which we obtain the Jeffreys prior density as
\begin{align*}
\pi(\mu,\sigma)&\propto|I(\mu,\sigma)|^{1/2} \\
&\propto\frac{\sqrt{2}n}{\sigma^2},\qquad-\infty<\mu<\infty,\quad\sigma>0 \\
&\propto\frac{1}{\sigma^2},\qquad-\infty<\mu<\infty,\quad\sigma>0.
\end{align*}

\item This is not a proper distribution as $\int\pi(\mu,\sigma)\,d\mu
  d\sigma$ is a divergent integral.  Also, $\mu$ and $\sigma$ are independent as the joint density can be factorised as
\[
\pi(\mu,\sigma)=\pi(\mu)\,\pi(\sigma)
\]
where 
\[
\pi(\mu)\propto 1,\quad -\infty<\mu<\infty
\qquad\text{and}\qquad
\pi(\sigma)\propto\frac{1}{\sigma^2},\quad\sigma>0.
\]
\end{enumerate}



\subsection*{Question 4}
The likelihood function is
\begin{align*}
f(\vec{x}|\alpha,\lambda)
&=\prod_{i=1}^n 
\displaystyle{\lambda^\alpha x_i^{\alpha-1}e^{-\lambda
    x_i}}{\Gamma(\alpha)}
=\displaystyle{\lambda^{n\alpha}\bar x_g^{n(\alpha-1)}e^{-n\bar x\lambda}}
{\Gamma(\alpha)^n},
\intertext{where $\bar x_g=\sqrt[n]{\prod x_i}$, and so the
  log-likelihood function is}
\log f(\vec{x}|\alpha,\lambda)
&=n\alpha\log\lambda +n(\alpha-1)\log\bar x_g -n\bar x\lambda 
-n\log\Gamma(\alpha).
\intertext{Therefore}
\frac{\partial}{\partial\alpha}\log f(\vec{x}|\alpha,\lambda)
&=n\log\lambda+n\log\bar x_g-n\psi(\alpha)\\
\frac{\partial}{\partial\lambda}\log f(\vec{x}|\alpha,\lambda)&=\frac{n\alpha}{\lambda}-n\bar x
\intertext{and so the maximum likelihood estimates
  $(\hat\alpha,\hat\lambda)$ satisfy}
\log\hat\lambda+\log\bar x_g-\psi(\hat\alpha)&=0\qquad\text{and}\qquad
\frac{\hat\alpha}{\hat\lambda}-\bar x=0,
\intertext{that is,}
\log\hat\lambda+\log\bar x_g-\psi(\hat\lambda\bar x)&=0\qquad\text{and}\qquad
\hat\alpha=\hat\lambda\bar x.
\end{align*}

The second derivatives are
\begin{align*}
\frac{\partial^2}{\partial\alpha^2}\log f(\vec{x}|\alpha,\lambda)
&=-n\psi'(\alpha)\\
\frac{\partial^2}{\partial\lambda^2}\log f(\vec{x}|\alpha,\lambda)
&=-\frac{n\alpha}{\lambda^2}\\
\frac{\partial^2}{\partial\alpha\partial\lambda}\log f(\vec{x}|\alpha,\lambda)
&=\frac{n}{\lambda}.
\end{align*}
Therefore
\begin{align*}
J_{11}(\hat\alpha,\hat\lambda)&=n\psi'(\hat\alpha),\qquad
J_{12}(\hat\alpha,\hat\lambda)=-n/\hat\lambda,\qquad
J_{22}(\hat\alpha,\hat\lambda)=n\hat\alpha/\hat\lambda^2
\intertext{and so}
J(\hat\alpha,\hat\lambda)&=
\begin{pmatrix}
n\psi'(\hat\alpha) & -n/\hat\lambda \\ 
-n/\hat\lambda & n\hat\alpha/\hat\lambda^2 \\
\end{pmatrix}
=n\begin{pmatrix}
\psi'(\hat\alpha) & -1/\hat\lambda \\ 
-1/\hat\lambda & \hat\alpha/\hat\lambda^2 \\
\end{pmatrix}
\end{align*}
whence
\begin{align*}
J(\hat\alpha,\hat\lambda)^{-1}&=
\displaystyle{1}{n\left\{\displaystyle{\hat\alpha\psi'(\hat\alpha)}{\hat\lambda^2}-\displaystyle{1}
{\hat\lambda^2}\right\}}
\begin{pmatrix}
\hat\alpha/\hat\lambda^2 & 1/\hat\lambda \\ 
1/\hat\lambda & \psi'(\hat\alpha) \\
\end{pmatrix}
=\frac{1}{n\{\hat\alpha\psi'(\hat\alpha)-1\}}
\begin{pmatrix}
\hat\alpha & \hat\lambda \\
\hat\lambda & \hat\lambda^2\psi'(\hat\alpha) \\
\end{pmatrix}.
\end{align*}
Therefore, the asymptotic posterior distribution distribution (as
$n\to\infty$) is
\[
\left.
\begin{pmatrix}\alpha \\ \lambda \\ \end{pmatrix}\right|\xvec\sim
N\left\{\begin{pmatrix}\hat\alpha \\ \hat\lambda \\ \end{pmatrix},~
\frac{1}{n\{\hat\alpha\psi'(\hat\alpha)-1\}}
\begin{pmatrix}
\hat\alpha & \hat\lambda \\
\hat\lambda & \hat\lambda^2\psi'(\hat\alpha) \\
\end{pmatrix}
\right\}.
\]

(ii) We have $n=100$, $\bar x=3.0$ and $\bar x_g=2.5$ leading to
maximum likelihood estimates $\hat\alpha=2.8983$ and
$\hat\lambda=0.9661$. Note that the value of $\hat\lambda$ (and hence
that of $\hat\alpha$) can be found using the R code
\begin{verbatim}
zerofn=function(x){(log(x)+log(2.5)-digamma(3*x))^2}
optimise(zerofn,interval=c(0,5))
\end{verbatim}
Now $\psi'(\hat\alpha)=0.4112474$ and so
\begin{align*}
\frac{1}{n\{\hat\alpha\psi'(\hat\alpha)-1\}}
\begin{pmatrix}
\hat\alpha & \hat\lambda \\
\hat\lambda & \hat\lambda^2\psi'(\hat\alpha) \\
\end{pmatrix}
=\frac{1}{19.1918}
\begin{pmatrix}
2.8983 & 0.9661 \\
0.9661 & 0.3838 \\
\end{pmatrix}
=\begin{pmatrix}
0.1510 & 0.0503 \\
0.0503 & 0.0200 \\
\end{pmatrix}.
\end{align*}
Therefore, the asymptotic posterior distribution distribution (as
$n\to\infty$) is
\[
\left.
\begin{pmatrix}\alpha \\ \lambda \\ \end{pmatrix}\right|\xvec\sim
N\left\{\begin{pmatrix}2.8983 \\0.9661 \\ \end{pmatrix},~
\begin{pmatrix}
0.1510 & 0.0503 \\
0.0503 & 0.0200 \\
\end{pmatrix}
\right\}.
\]
The asymptotic posterior correlation between $\alpha$ and $\lambda$ is
\[
Corr(\alpha,\lambda|\xvec)=\frac{Cov(\alpha,\lambda|\xvec)}
{SD(\alpha|\xvec),SD(\lambda|\xvec)}
=\frac{0.0505}{\sqrt{0.1510\times 0.0200}}=0.9189,
\]
that is, there is very strong positive posterior correlation between
the parameters.

%\end{document}

\subsection*{Question 1}
\begin{itemize}
\item [(a)] The Jeffreys prior is given by
\[
\pi(\theta) \propto \sqrt{I(\theta)},
\]
where 
\[
I(\theta) = E_{X|\theta}\left[-\frac{\partial^{2}}{\partial \theta^{2}} \log f(\boldsymbol{x}|\theta)\right].
\]
Now
\begin{eqnarray*}
f(\boldsymbol{x}|\theta)	&=& \prod_{i=1}^{n}\frac{\theta}{x_{i}^{\theta+1}} = \theta^{n} \left(\prod_{i=1}^{n}x_{i}^{-(\theta+1)}\right), \quad \text{and}	\\
\ell = \log f(\boldsymbol{x}|\theta)	&=&n\log \theta -(\theta+1)\sum_{i=1}^{n}\log x_{i} = n\log\theta - (\theta+1)n \bar{x}_{\text{log}}.\\
						&& \text{\textcolor{red}{[2 marks, no need to express in terms of $\bar{x}_{\text{log}}$.]}}
\end{eqnarray*}
Then
\begin{eqnarray*}
\frac{\partial \ell}{\partial \theta}	&=& \frac{n}{\theta} - n\bar{x}_{\text{log}}, \quad \text{and} \quad \text{\textcolor{red}{[1 mark]}}	\\
\frac{\partial^{2} \ell}{\partial \theta^{2}}	&=& -\frac{n}{\theta^{2}}. \text{\textcolor{red}{[1 mark]}	}
\end{eqnarray*}
Then $\displaystyle E_{X|\theta}\left[-\frac{\partial^{2}\ell}{\partial \theta^{2}}\right] = \frac{n}{\theta^{2}}$, and so 
\[
\pi(\theta) \propto \sqrt{\frac{n}{\theta^{2}}} \propto \frac{1}{\theta}, \quad \theta < x. \text{\textcolor{red}{[1 mark]}	}
\]

\item [(b)] The asymptotic posterior distribution (as $n\to\infty$) is
\begin{equation*}
\theta|\xvec\sim N\left(\hat\theta,J(\hat\theta)^{-1}\right),
\end{equation*}
where
\begin{equation*}
J(\theta)=-\frac{\partial^2}{\partial\theta^2} \log
f(\xvec|\theta)=\frac{n}{\theta^2}.
\end{equation*}
Now
\begin{eqnarray*}
\frac{\partial}{\partial\theta} \log f(\xvec|\theta)=0
\quad\quad&\Longrightarrow&\quad\quad
\frac{n}{\hat\theta}-n\bar{x}_{\text{log}}=0 \\
&\Longrightarrow&\quad\quad
\hat\theta=1\left/\,\bar{x}_{\text{log}}\right. \text{\textcolor{red}{[1 mark]}}	\\
&\Longrightarrow&\quad\quad
J(\hat\theta)^{-1}=\frac{1}{n\bar{x}_{\text{log}^{2}}}.
\end{eqnarray*}
Therefore, for large $n$, the posterior distribution for $\theta$ is
\begin{equation*}
\theta|\xvec\sim N \left(\frac{1}{\bar{x}_{\text{log}}}, \frac{1}{n \bar{x}_{\text{log}}^{2}}\right) \quad\quad\text{approximately}. 
\end{equation*}
\textcolor{red}{[2 marks, must state that this is an approximate results as $n \to \infty$. Also - it is not a requirement for students to show their results in terms of $\bar{x}_{\text{log}}$; for example, it is fine to say that $\hat{\theta} = n/\sum \log x_{i}$.]}	

\end{itemize}

\subsection*{Question 2}
The likelihood function is
\begin{align*}
f(\xvec|\mu,\alpha)&=\prod_{i=1}^n\frac{e^{\alpha/2}}{x_i\sqrt{2\pi}}
\exp\left\{-\frac{e^\alpha}{2}(\log x_i-\mu)^2\right\}\\
&\propto e^{n\alpha/2}\exp\left\{-\frac{e^\alpha}{2}\sum_{i=1}^n(\log x_i-\mu)^2\right\}. \quad \text{\textcolor{red}{[1 mark]}}
\end{align*}

We have
\begin{align*}
\log f(\xvec|\mu,\alpha)&=\frac{n\alpha}{2}-\frac{e^\alpha}{2}\sum_{i=1}^n(\log x_i-\mu)^2+ const\\
\Longrightarrow\quad&\frac{\partial}{\partial\mu} \log
f(\xvec|\mu,\alpha)=e^{\alpha}\sum_{i=1}^n(\log x_i-\mu) \quad \text{\textcolor{red}{[1 mark]}}\\
&\frac{\partial}{\partial\alpha} \log
f(\xvec|\mu,\alpha)=\frac{n}{2}-\frac{e^\alpha}{2}\sum_{i=1}^n(\log x_i-\mu)^2 \quad \text{\textcolor{red}{[1 mark]}}\\
\Longrightarrow\quad&\frac{\partial^2}{\partial\mu^2} \log
f(\xvec|\mu,\alpha)=-ne^{\alpha} \quad \text{\textcolor{red}{[1 mark]}} \\
&\frac{\partial^2}{\partial\mu\partial\alpha} \log
f(\xvec|\mu,\alpha)=e^{\alpha}\sum_{i=1}^n(\log x_i-\mu) \quad \text{\textcolor{red}{[1 mark]}}\\
&\frac{\partial^2}{\partial\alpha^2} \log
f(\xvec|\mu,\alpha)=-\frac{e^{\alpha}}{2}\sum_{i=1}^n(\log x_i-\mu)^2. \quad \text{\textcolor{red}{[1 mark]}}
\end{align*}
From the hint
\[
E(\log X_i|\mu,\alpha)=\mu\quad\text{and}\quad 
E\{(\log X_i-\mu)^2|\mu,\alpha)=Var(\log X_i|\mu,\alpha)=e^{-\alpha}.
\]
Therefore, the elements of Fisher's information matrix are
\begin{align*}
I_{11}&=E_{\Xvec|\mu,\alpha}
\left[-\frac{\partial^2}{\partial\mu^2} \log
f(\Xvec|\mu,\alpha)\right]=ne^\alpha\\
I_{12}&=E_{\Xvec|\mu,\alpha}
\left[-\frac{\partial^2}{\partial\mu\partial\alpha} \log
f(\Xvec|\mu,\alpha)\right] =-ne^\alpha\,E_{X|\mu,\alpha}[\log X-\mu]=0\\
I_{22}&=E_{\Xvec|\mu,\alpha}
\left[-\frac{\partial^2}{\partial\alpha^2} \log
f(\Xvec|\mu,\alpha)\right]=\frac{ne^{\alpha}}{2}E_{X|\mu,\alpha}[(\log X-\mu)^2]=\frac{n}{2}.
\end{align*}
Hence, Fisher's information matrix is
\[
I(\mu,\alpha)
=n\begin{pmatrix} e^\alpha & 0 \\ 0 & 1/2 \\ \end{pmatrix} \quad \text{\textcolor{red}{[4 marks]}},
\]
and so Jeffreys prior density is, for $\mu\in\mathbb{R}$, $\alpha\in\mathbb{R}$
\begin{align*}
\pi(\mu,\alpha)&\propto|I(\mu,\alpha)|^{1/2} \\
&\propto\sqrt{\frac{n^2e^\alpha}{2}}\\
&\propto e^{\alpha/2}. \quad \text{\textcolor{red}{[2 marks]}}
\end{align*}


\end{document}


