\frame{

\vspace{1cm}

\huge
\textbf{Chapter 2}

\vspace{1cm}

\Large
\textbf{Inference for a Normal population}

}

\slidecolour\slidecolour
\mysection{Inference for a normal population}
\subsection{Bayes Theorem for many parameters}

\begin{frame}
\frametitle{Chapter \thesection. Inference for a normal population}
\begin{block}{{\thesubsection} Bayes Theorem for many parameters}
Data: $\xvece$

\medskip
Model: depends on many parameters $\thetavece$

pdf/pf $f(\xvec|\thetavec)\to$ Likelihood function
$f(\xvec|\thetavec)$ 

\medskip
\alert{Prior beliefs}: pdf/pf $\pi(\thetavec)$

\bigskip
Combine using Bayes Theorem

\medskip
\alert{Posterior beliefs}: pdf/pf $\pi(\thetavec|\xvec)$

\bigskip
Posterior distribution summarises all our current knowledge
about the parameter $\thetavec$
\end{block}
\end{frame}

\begin{frame}
\begin{block}{Bayes Theorem}
The posterior probability (density) function for $\thetavec$ is
\begin{align*}
\pi(\thetavec|\xvec)&=\frac{\pi(\thetavec)\,f(\xvec|\thetavec)}{f(\xvec)} 
\intertext{where}
f(\xvec)&=
\begin{cases}
\int_\Theta\pi(\thetavec)\,f(\xvec|\thetavec)\,d\thetavec & \text{if
$\thetavec$ is continuous}, \\ \\
\sum_\Theta\pi(\thetavec)\,f(\xvec|\thetavec) & \text{if
$\thetavec$ is discrete}.
\end{cases}
\end{align*}
As before, this can be rewritten as
\begin{align*}
\pi(\thetavec|\xvec)&\propto \pi(\thetavec)\times f(\xvec|\thetavec) \\
i.e.~~\text{posterior}&\propto\text{prior}\times\text{likelihood}
\end{align*}
\end{block}
\end{frame}


\begin{frame}
\begin{block}{Generalised $t$ distribution: $X\sim t_a(b,c)$}
\begin{itemize}
\item Density for $x\in\mathbb{R}$
\vspace*{-5mm}
\[
f(x|a,b,c)=\frac{\Gamma\left(\frac{a+1}{2}\right)}
{\sqrt{ac\pi}\,\Gamma\left(\frac{a}{2}\right)}
\left\{1+\frac{(x-b)^2}{ac}\right\}^{-\frac{a+1}{2}}
\]
\item Parameters: $a>0$, $b\in\mathbb{R}$, $c>0$
\item $E(X)=Mode(X)=b$ and $Var(X)=\dfrac{ac}{a-2}$, if $a\geq 2$
\item Generalisation of the standard $t$-distribution since
  $(X-b)/\sqrt{c}\sim t_a$ 
\item $t_a(0,1)\equiv t_a$
\item $\lim_{a\to\infty}t_a(b,c)=N(b,c)$
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\begin{myexample}
\begin{itemize}
\item \label{ex:student} If $X\sim t_a(b,c)$ then show that
  $Y=(X-b)/\sqrt{c}\sim t_a$, with density
\[
f(y)=\frac{\Gamma\left(\frac{a+1}{2}\right)}
{\sqrt{a\pi}\,\Gamma\left(\frac{a}{2}\right)}
\left\{1+\frac{y^2}{a}\right\}^{-\frac{a+1}{2}},\quad\quad 
-\infty<y<\infty,
\]
Recall the general result: if $X$ is a random variable with
probability density function $f_X(x)$ and $g$ is a bijective (1--1)
function then the random variable $Y=g(X)$ has probability density
function
\begin{equation}
\label{eq:trans1}
f_Y(y)=f_X\left\{g^{-1}(y)\right\}\left|\frac{d}{dy}\,g^{-1}(y)\right|.
\end{equation}
\end{itemize}
\end{myexample}

\begin{soln}{}\end{soln}
\end{frame}

\begin{frame}
\begin{block}{Comments}
\begin{itemize}
\item \R{R} functions \R{pgt} and \R{dgt} in the package \R{nclbayes}
  give values for $F_X(x)$ and $f_X(x)$ when $X\sim t_a(b,c)$
\item Relationship between the generalised $t$ distribution and the
  standard $t$ distribution is similar to that of the normal
  distribution and the standard normal distribution:
\end{itemize}
\begin{center}
\begin{tabular}{lcl}
$X\sim N(b,c)$ & $\Longrightarrow$ & $\dfrac{X-b}{\sqrt{c}}\sim N(0,1)$\\
\\
$X\sim t_a(b,c)$ & $\Longrightarrow$ & $\dfrac{X-b}{\sqrt{c}}\sim t_a$
\end{tabular}
\end{center}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{Inverse Chi distribution: $Y\sim \textit{Inv-Chi}(a,b)$}
\begin{itemize}
\item Density
\[
f(y|a,b)=\frac{2b^ay^{-2a-1}e^{-b/y^2}}{\Gamma(a)},\quad y>0
\]
\item Parameters: $a>0$, $b>0$
\item $E(Y)=\dfrac{\sqrt{b}\,\Gamma(a-1/2)}{\Gamma(a)}$
\item $Var(Y)=\dfrac{b}{a-1}-E(Y)^2$, if $a\geq 1$
\item The name of the distribution comes from the fact that $1/Y^2\sim
Ga(a,b)\equiv \chi^2_{2a}/(2b)$
\end{itemize}
\end{block}
\end{frame}

\subsection{Prior to posterior analysis}
\label{sec:nrs}
\slidecolour
\begin{frame}
\frametitle{{\thesubsection} Prior to posterior analysis}
\vspace*{-4mm}
\begin{block}{}
\begin{itemize}
\item Data: $X_i|\mu,\tau\sim N(\mu,1/\tau)$, $i=1,2,\ldots,n$ (indep)
\item Prior: $\mu|\tau\sim N\left(b,\frac{1}{c\tau}\right),~~
\tau\sim Ga(g,h)$, with joint density, for $\mu\in\mathbb{R}, ~\tau>0$
\begin{align}
\pi(\mu,\tau)&=
\pi(\mu|\tau)\pi(\tau) \notag \\
&=\left(\frac{c\tau}{2\pi}\right)^{1/2}\exp\left\{-\frac{c\tau}{2}(\mu-b)^2\right\}
\times
\frac{h^g\tau^{g-1}e^{-h\tau}}{\Gamma(g)}\notag\\
\label{eq:nogaprior}
&\propto\tau^{g-\frac{1}{2}}\exp\left\{-\frac{\tau}{2}
\left[c(\mu-b)^2+2h\right]\right\}
\end{align}

\pause
\item We write $\mutau\sim NGa(b,c,g,h)$
\vspace*{-3mm}
\item Determine the posterior distribution for $\mutau$\\
Hint:
\vspace*{-3mm}
\[
c(\mu-b)^2+n(\bar x-\mu)^2
=(c+n)\left\{\mu-\left(\frac{cb+n\bar x}{c+n}\right)\right\}^2
+\frac{nc(\bar x-b)^2}{c+n}
\]
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\begin{soln}{\tiny\color{white}\begin{align}\label{eq:nogapostpara}
%\label{eq:nogaposterior}
\end{align}}\end{soln}
\end{frame}

\begin{frame}
\begin{block}{{\thesubsection}.1 Marginal distributions}
\begin{itemize}
\item If $\mutau\sim NGa(b,c,g,h)$ then $\tau\sim Ga(g,h)$
\item The (marginal) density for $\mu$ is, for $\mu\in\mathbb{R}$
\scriptsize
\begin{align*}
\pi(\mu)&=\int_0^\infty \pi(\mu,\tau)\,d\tau \\
&\propto\int_0^\infty \tau^{g-\frac{1}{2}}\exp\left\{-\frac{\tau}{2}
\left[c(\mu-b)^2+2h\right]\right\}\,d\tau\\
&\propto\int_0^\infty \tau^{g+\frac{1}{2}-1}\exp\left\{-\frac{\tau}{2}
\left[c(\mu-b)^2+2h\right]\right\}\,d\tau\\
&\propto\frac{\Gamma\left(g+\frac{1}{2}\right)}
{\left[\left\{c(\mu-b)^2+2h\}/2\right\}\right]^{g+\frac{1}{2}}}
\quad \alert{\text{using $\int_0^\infty\theta^{a-1}e^{-b\theta}\,d\theta
=\frac{\Gamma(a)}{b^a}$}} \\
&\propto h^{-g-1/2}\left\{1+\frac{c(\mu-b)^2}{2h}\right\}^{-g-1/2}\\
&\propto\left\{1+\frac{c(\mu-b)^2}{2h}\right\}^{-\frac{2g+1}{2}}
\end{align*}
\vspace*{-5mm}
\begin{equation}
\label{eq:margprior}
\text{i.e.}\quad\mu\sim t_{2g}\left(b,\frac{h}{gc}\right)
\end{equation}
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{Summary of marginal distributions}
\begin{itemize}
\item The data: $X_{i}|\mu, \tau \sim N(\mu, 1/\tau)$ 
\item Priors: $\mu|\tau \sim N(b, 1/c\tau)$, $\tau\sim Ga(g, h)$
\item The joint prior $\mutau\sim NGa(b,c,g,h)$ has marginal distributions
\begin{itemize}
\item $\mu\sim t_{2g}\left(b,\frac{h}{gc}\right)$  \textcolor{red}{(Proven in today's lecture)}
\medskip
\item $\tau\sim Ga(g,h)$
\end{itemize}
\medskip
Also $\sigma=1/\sqrt\tau\sim\textit{Inv-Chi}(g,h)$ \textcolor{red}{(One for you in assignment 3!)}
\medskip
\item The posterior $\left.\mutau\right|\xvec\sim NGa(B,C,G,H)$ has
  marginal distributions
\begin{itemize}
\item $\mu|\xvec\sim t_{2G}\left(B,\frac{H}{GC}\right)$ \textcolor{red}{(Exactly the same proof as for $\mu\sim t_{2g}$)}
\medskip
\item $\tau|\xvec\sim Ga(G,H)$
\end{itemize}
\medskip
Also $\sigma|\xvec\sim\textit{Inv-Chi}(G,H)$ \textcolor{red}{(One for you in assignment 3!)}
\end{itemize}
\end{block}
\end{frame}

\slidecolour
\begin{frame}
\vspace*{-4mm}
\begin{myexample}
\label{ex:cavbiv}
\begin{itemize}
\item The 18th century physicist Henry Cavendish made 23 experimental
  determinations of the earth's density, and these data (in $g/cm^3$)
  are
{\small
\begin{center}
\begin{tabular}{|cccccccc|}
\hline
5.36&5.29&5.58&5.65&5.57&5.53&5.62&5.29\\
5.44&5.34&5.79&5.10&5.27&5.39&5.42&5.47\\
5.63&5.34&5.46&5.30&5.78&5.68&5.85&\\
\hline
\end{tabular}
\end{center}}
\item[] with sufficient statistics $n=23$, $\bar x=5.4848$, $s=0.1882$
\item We consider $X|\mu,\tau\sim N(\mu,1/\tau)$, with $\tau$ unknown
\item In Example~1.\ref{ex:cavendish} we assumed $X_i|\mu\sim
  N(\mu,0.2^2)$ with $\mu\sim N(5.41,0.4^2)$ and $\tau$ known  with $\tau=1/0.2^2=25$.
\item Must specify the parameters in the $NGa(b,c,g,h)$ prior distribution for $(\mu,\tau)^T$. Suppose we choose $Var(\tau)=250$.
\item Choice of $b$ and $c$: the $NGa$ prior distribution has
  $\mu|\tau\sim N\{b,1/(c\tau)\}$.
  Matching the prior for $\mu|\tau=25$ gives $b=5.41$ and $c=0.25$

  \smallskip 
  Choice of $g$ and $h$: the $NGa$ prior distribution has $\tau\sim
  Ga(g,h)$. Choose $E(\tau)=25$, giving
  $g=2.5$ and $h=0.1$
\end{itemize}
\end{myexample}
\end{frame}


\begin{frame}
\begin{block}{}
\begin{itemize}
\item Summary: take prior
\[
\mutau\sim NGa(b=5.41,c=0.25,g=2.5,h=0.1)
\]

\item Is the marginal prior distribution for $\mu$ close to what we
  used in Example~1.\ref{ex:cavendish}? \alert{Yes, see plot below}
\end{itemize}
\begin{figure}[ht]
\vspace*{-8mm}
\includegraphics[width=0.7\textwidth]{cav-prior-mu}
\vspace*{-8mm}
\caption{Marginal prior density for $\mu$: new version (solid) and
  previous version (dashed)}
\end{figure}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{}
\begin{itemize}
\item Determine the posterior distribution for $(\mu,\tau)^T$. Also
  determine the marginal prior distribution for $\tau$ and for
  $\sigma$, and the marginal posterior distribution for each of
  $\mu$, $\tau$ and~$\sigma$.
\end{itemize}
\end{block}

\begin{soln}{}\end{soln}
\end{frame}

\begin{frame}
\vspace*{-4mm}
\begin{block}{Comparison of prior and posterior marginal distributions}
\begin{figure}[ht]
\includegraphics[width=0.5\textwidth]{cav-post-mu}\\ \vspace*{-4mm}
\includegraphics[width=0.5\textwidth]{cav-post-tau}
\includegraphics[width=0.5\textwidth]{cav-post-sigma}
\caption{Prior (dashed) and posterior (solid) densities for $\mu$,
  $\tau$ and $\sigma$}
\label{fig:cav-post}
\end{figure}
\end{block}
\end{frame}

\begin{frame}
\vspace*{-4mm}
\begin{block}{Review of contour plots for bivariate distribution}
\begin{itemize}
\item Bivariate normal: $\left(\begin{array}{c}
X\\
Y
\end{array}\right)\sim N\left\{ \left(\begin{array}{c}
0\\
0
\end{array}\right),\left(\begin{array}{cc}
\sigma_{x}^{2} & \rho\sigma_{x}\sigma_{y}\\
\rho\sigma_{x}\sigma_{y} & \sigma_{y}^{2}
\end{array}\right)\right\} $, with density
$\frac{1}{2\pi\sigma_{x}\sigma_{y}\sqrt{1-\rho^{2}}}\exp\left\{ -\frac{1}{2(1-\rho^{2})}\left(\frac{x^{2}}{\sigma_{x}^{2}}+\frac{y^{2}}{\sigma_{y}^{2}}-2\rho\frac{xy}{\sigma_{x}\sigma_{y}}\right)\right\}. $
\end{itemize}
\begin{figure}[ht]
\includegraphics[width=0.5\textwidth]{Bivariate_Normal_Rev.png}
\caption{Contour plots for different bivariate normal densities}
\end{figure}
\end{block}
\end{frame}


\begin{frame}
\vspace*{-3mm}
\begin{block}{Comparison of prior and posterior distributions}
\begin{itemize}
\item Can plot their contours using \R{R} command \R{NGacontour}:\\ \vspace*{1mm}
{\scriptsize
\R{mu=seq(4.5,6.5,len=1000);} \R{tau=seq(0,71,len=1000)}\\ \vspace*{-1mm}
\R{NGacontour(mu,tau,b,c,g,h,lty=3);} \R{NGacontour(mu,tau,B,C,G,H,add=TRUE)}}
\end{itemize}

\begin{figure}
\begin{center}
\vspace*{-8mm}
\includegraphics[width=0.6\textwidth]{cav-post-joint}
\vspace*{-7mm}
\caption{\scriptsize Contour plot of the prior (dashed) and posterior (solid)
densities for $(\mu,\tau)^T$.} 
\label{fig:cav-post-joint}
\end{center}
\end{figure}
\end{block}
\end{frame}

\begin{frame}
\vspace*{-3mm}
\begin{block}{Comments}
\begin{itemize}
\item Wikipedia tells us that the actual mean density of the earth is
$5.515\,g/cm^3$
\item What is the (posterior) probability that the mean density is
  within 0.1 of this value?
\[
\mu|\xvec\sim t_{28}(5.484,0.001561)\quad\Rightarrow\quad
Pr(5.415<\mu<5.615|\xvec)=0.9529
\]
using \R{pgt(5.615,28,5.484,0.001561)-pgt(5.415,28,5.484,0.001561)}
\pause
\item Without the data, the only basis for determining the earth's density
is via the prior distribution
\[
\mu\sim t_5(5.41,0.16)\quad\Rightarrow\quad
Pr(5.415<\mu<5.615)=0.1802
\]
using \R{pgt(5.615,5,5.41,0.16)-pgt(5.415,5,5.41,0.16)}
\item These probability calculations demonstrate that the data have
  been very informative and changed our beliefs about the earth's
  density
% \item Over to an \texttt{R} demo \ldots  \R{demo(cavendish)}
\end{itemize}
\end{block}
\end{frame}

\slidecolour
\subsection{Confidence intervals and regions}
\begin{frame}
\frametitle{{\thesubsection} Confidence intervals and regions}
\begin{myexample}
  Determine the $100(1-\alpha)\%$ highest density interval (HDI) for
  the population mean~$\mu$ in terms of quantiles of the standard
  $t$-distribution
\end{myexample}

\begin{soln}{}\end{soln}
\end{frame}

\begin{frame}
\begin{block}{Calculating 95\% posterior confidence intervals using R}
\begin{itemize}
\item $\mu|\xvec\sim t_{2G}\{B,H/(GC)\}$\\
Symmetric distribution $\to$ HDI and equi-tailed intervals are the same\\
\R{c(qgt(0.025,2*G,B,H/(G*C)),qgt(0.975,2*G,B,H/(G*C)))}
\medskip
\item $\tau|\xvec\sim Ga(G,H)$\\ 
Skewed distribution $\to$ HDI and equi-tailed intervals are different\\
\R{hdiGamma(0.95,G,H)}\\
\R{c(qgamma(0.025,G,H),qgamma(0.975,G,H))}
\medskip
\item $\sigma|\xvec\sim\textit{Inv-Chi}(G,H)$\\  
Skewed distribution $\to$ HDI and equi-tailed intervals are different\\
\R{hdiInvchi(0.95,G,H)}\\
\R{c(qinvchi(0.025,G,H),qinvchi(0.975,G,H))}
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{Results from this data analysis \ldots}
\begin{center}
\begin{tabular}{cccl}
& Prior & Posterior \\
$\mu$: & $(4.3818,6.4382)$ & $(5.4031,5.5649)$ \\
\noalign{\medskip}
$\tau$: & {\d}$(1.4812,55.9573)$ & $(14.0193,42.2530)$ & $\gets$ HDI\\
& {\d}$(4.1561,64.1625)$ & $(15.0674,43.7625)$ \\
\noalign{\medskip}
$\sigma$: & $(0.1062,0.4246)$ & $(0.1466,0.2505)$ & $\gets$ HDI\\
& $(0.1248,0.4905)$ & $(0.1512,0.2576)$
\end{tabular}
\end{center}

\begin{itemize}
\item Posterior HDI and equi-tailed intervals for~$\tau$ are fairly similar but 
prior intervals are not
\item Ditto for $\sigma$
\item Why?
\pause
\item[] \alert{The prior distributions are quite skewed but the
    posterior distributions are fairly symmetric}
\end{itemize}

\end{block}
\end{frame}

\begin{frame}
\begin{block}{Confidence regions}
\begin{itemize}
\item We have looked at (marginal) HDIs
\item Can be useful to also look at (joint) confidence regions
\end{itemize}
\end{block}

\begin{myexample}
Determine a joint $\alpha$ confidence region for $(\mu,\tau)^T$ by calculating $k$ satisfying $P(\pi(\mu,\tau)>k)=\alpha$ or $P(\pi(\mu,\tau)>k\mid\xvec)=\alpha$.
\end{myexample}

\begin{soln}{}\end{soln}

\begin{block}{}
\begin{itemize}
\item Can plot these regions using \R{NGacontour} by using the
  appropriate value for the contour level

\R{mu=seq(3.5,7.5,len=1000)}\\
\R{tau=seq(0,80,len=1000)}\\
\R{NGacontour(mu,tau,b,c,g,h,p=c(0.95,0.9,0.8),lty=3)}\\
\R{NGacontour(mu,tau,B,C,G,H,p=c(0.95,0.9,0.8),add=TRUE)}

\bigskip
\item Over to an \texttt{R} demo \ldots
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{Confidence regions for $(\mu,\tau)^T$}
\begin{figure}
\begin{center}
\includegraphics[width=0.6\textwidth]{cav-conf1}
%\includegraphics[width=0.7\textwidth]{cav-conf2}
\vspace*{-3mm}
\caption{95\%, 90\% and 80\% prior (dashed) and posterior (solid)
  confidence regions for $(\mu,\tau)^T$; 95\%
  (outer), 80\% (inner).}
\end{center}
\end{figure}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{Focusing on central part of plot \ldots}
\begin{figure}
\begin{center}
\includegraphics[width=0.6\textwidth]{cav-conf2}
\vspace*{-3mm}
\caption{95\%, 90\% and 80\% prior (dashed) and posterior (solid)
  confidence regions for $(\mu,\tau)^T$; 95\%
  (outer), 80\% (inner).}
\end{center}
\end{figure}
\end{block}
\end{frame}

\slidecolour



\subsection{Predictive distributions}
\begin{frame}
\begin{block}{{\thesubsection} Predictive distributions}
\begin{itemize}
\item In this model we can determine the predictive distribution via
\[
f(y|\xvec)=\int f(y|\mu,\tau)\,\pi(\mu,\tau|\xvec)\,d\mu\,d\tau
\]
or by using Candidate's formula (as this is a conjugate analysis)
\item But, for this model, there is a more straightforward way
\end{itemize}
\end{block}
\begin{block}{}
{\LARGE $\ldots$}
\end{block}
\pause
\begin{block}{}
\begin{itemize}
\item These predictive intervals can be calculated easily using the
  \R{R} function \R{qgt}
\item In Example 2.2, the prior and posterior predictive
  HDIs for a new value $Y$ from the population are $(4.2604,6.5596)$
  and $(5.0855,5.8825)$ respectively, calculated using
\end{itemize}
{\small
\R{c(qgt(0.025,2*g,b,h*(c+1)/(g*c)),qgt(0.975,2*g,b,h*(c+1)/(g*c)))}\\
\R{c(qgt(0.025,2*G,B,H*(C+1)/(G*C)),qgt(0.975,2*G,B,H*(C+1)/(G*C)))}
}
\end{block}
\end{frame}

\subsection{Summary}
\begin{frame}
\begin{block}{{\thesubsection} Summary}
Suppose we have a normal random sample with $X_i|\mu,\tau\sim
N(\mu,1/\tau)$, $i=1,2,\ldots,n$ (independent)
\bigskip
\begin{enumerate}[(i)]
\item $(\mu,\tau)^T\sim NGa(b,c,g,h)$ is a conjugate prior
  distribution
\item The posterior distribution is $(\mu,\tau)^T|\xvec\sim
  NGa(B,C,G,H)$ where the posterior parameters are given in the proof in Section 2.2.
\item The marginal prior distributions are $\mu\sim t_{2g}\{b,h/(gc)\}$,
  $\tau\sim Ga(g,h)$, $\sigma=1/\sqrt\tau\sim\textit{Inv-Chi}(g,h)$
\item The marginal posterior distributions are $\mu|\xvec\sim
  t_{2G}\{B,H/(GC)\}$, $\tau|\xvec\sim Ga(G,H)$,
  $\sigma|\xvec\sim\textit{Inv-Chi}(G,H)$
\item Prior and posterior means and standard deviations for $\mu$,
  $\tau$ and $\sigma$ can be calculated from the properties of the
  $t$, $Gamma$ and \textit{Inv-Chi} distributions
\item Prior and posterior probabilities and densities for $\mu$,
  $\tau$ and $\sigma$ can be calculated using the \R{R} functions
  \R{pgt, dgt, pgamma, dgamma, pinvchi, dinvchi}
\end{enumerate}
\end{block}
\end{frame}

\begin{frame}
\begin{block}{}
Suppose we have a normal random sample with $X_i|\mu,\tau\sim
N(\mu,1/\tau)$, $i=1,2,\ldots,n$ (independent)
\bigskip
\begin{enumerate}
\item[(vii)] HDIs or equi-tailed CIs for $\mu$, $\tau$ and $\sigma$
  can be calculated using \R{qgt, hdiGamma, hdiInvchi, qgamma,
    qinvchi}
\item[(viii)] Contour plots of the prior and posterior densities for
  $(\mu,\tau)^T$ can be plotted using the \R{NGacontour} function
\item[(ix)] Prior and posterior confidence regions for $(\mu,\tau)^T$
  can be plotted using the \R{NGacontour} function
\item[(x)] The predictive distribution for a new observation $Y$ from
  the population is $Y|\xvec\sim t_{2G}\{B,H(C+1)/(GC)\}$ and its HDI
  can be calculated using the \R{qgt} function
\end{enumerate}
\end{block}
\end{frame}

\subsection{Why do we have so many different distributions?}
\slidecolour\slidecolour
\begin{frame}
\frametitle{{\thesubsection} Why do we have so many different distributions?}
\begin{block}{}
\begin{itemize}
\item So far we have used many distributions, some you will have met before
and some will be new 
\item After a while the variety and sheer number of 
different distributions can become overwhelming
\item Why do we need so many distributions and why do we name so many of them? 
\end{itemize}
\end{block}

\begin{block}{Justification}
\begin{itemize}
\item Statistics studies the random variation in experiments, samples and
processes
\item The variety of applications leads to their randomness being
described by many different distributions
\item In many applications, bespoke distributions need to be formulated
\item However, some distributions come up time and time again for modelling
random variation in data and for describing prior beliefs
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\vspace*{-3mm}
\begin{block}{Justification (continued)}
\begin{itemize}
\item It is helpful for us to be able to refer to these distributions -- and so we
give each one a name -- and be able to quote known results for these
distributions such as their mean and variance \pause
\item For example, in this chapter
you have been introduced to 
\begin{itemize}
\item a generalisation of the $t$-distribution
\item the inverse chi distribution
\item The Normal-Gamma distribution \pause
\end{itemize}
\item We have been able to use results
for their mean and variance to study prior and posterior distributions
and have been able to plot these distributions using functions in the
\texttt{R} package \pause
\item You will meet several other new distributions in the remainder of the
module
\end{itemize}
\end{block}
\end{frame}

\begin{frame}
\vspace*{-3mm}
\begin{block}{Justification (continued)}
\begin{itemize}
\item Obviously it's useful to have a
working knowledge of each of these distributions \alert{but not vital
to remember all their properties} 
\pause
\item \alert{The exam paper will contain} a list of all the
distributions used in the exam, together with their density (or
probability function) and any useful proprieties such as their mean
and variance (as needed for the exam)
\end{itemize}
\end{block}
\end{frame}

\subsection{Learning objectives}
\slidecolour
\begin{frame}
\frametitle{{\thesubsection} Learning objectives}
\vspace*{-3mm}
\begin{block}{}
By the end of this chapter, you should be able to:
\begin{itemize}
\item[1.] Determine the posterior distribution for $(\mu,\tau)^T$ 
\item[2.] Determine and use the univariate prior and posterior distributions
\item[3.] Determine confidence intervals, HDIs and confidence regions
\item[4.] Determine the predictive distribution of another value from the
  population, and its predictive interval
\item[5.] Determine the predictive distribution of the mean of another
  random sample from the population
\end{itemize}
\alert{both in general and for a particular prior and data set}. 

Also you should be able to:
\begin{itemize}
\item [6.] Appreciate the benefit of naming distributions and for having
  lists of properties for these distributions
\end{itemize}


\end{block}
\end{frame}
