%ANswer key to econometrics QE question 3, Jan. 2014
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%I) DEFINE DOCUMENTCLASS AND LOAD ALL REQUIRED PACKAGES
\documentclass[11pt,reqno]{article} %keep it simple
\usepackage{graphicx} % for fancy graphics
\usepackage{setspace} % for basic formatting
\usepackage{enumerate} % for more flexibility with numbered lists
\usepackage{amsmath}
\usepackage{float}
% You may need to load all or some of these packages -
%follow the instructions on our course web site under "Help with LaTex"
%II) PREAMBLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{plain} %puts page number center bottom
\setlength{\topmargin}{-0.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{.0in}
\setlength{\evensidemargin}{.0in}
\setlength{\textwidth}{6.5in}
\setlength{\footskip}{.5in}
\setlength{\parindent}{0in} %suppress indentation
\setcounter{MaxMatrixCols}{20} %allow for more columns in bmatrix
%\onehalfspacing
\newcommand{\mlt}[1]{\mathbf{#1}} %matrix bold for Latin symbols
\newcommand{\mgr}[1]{\boldsymbol{#1}}%matrix bold for Greek symbols
\newcommand{\chp}[1]{\textbf{\textsl{#1}}}
\newcommand{\km}[1]{\textsf{\small{#1}}} %special font for my own comments
\newcommand{\dhat}[1]{\hat{\hat{#1}}}
\newcommand{\kl}{\left(}
\newcommand{\kr}{\right)}
\newcommand{\kll}{\left\{}
\newcommand{\krr}{\right\}}
\newcommand{\kmu}{\mgr{\mu}}
\newcommand{\kt}{^{\prime}}
\newcommand{\kdel}{\partial}
\newcommand{\kdot}{\kl . \kr}
\newcommand{\keps}{\epsilon}
\newcommand{\kpi}{\mgr{\pi}}
\newcommand{\kx}{\mlt{x}}
\newcommand{\kq}{\mlt{q}}
\newcommand{\kX}{\mlt{X}}
\newcommand{\kV}{\mlt{V}}
\newcommand{\kW}{\mlt{W}}
\newcommand{\kM}{\mlt{M}}
\newcommand{\kP}{\mlt{P}}
\newcommand{\kA}{\mlt{A}}
\newcommand{\kI}{\mlt{I}}
\newcommand{\ki}{\mlt{i}}
\newcommand{\kR}{\mlt{R}}
\newcommand{\kkr}{\mlt{r}}
\newcommand{\ky}{\mlt{y}}
\newcommand{\kb}{\mlt{b}}
\newcommand{\klam}{\lambda}
\newcommand{\kp}{\mlt{p}}
\newcommand{\kprob}{\text{prob}}
\newcommand{\kz}{\mlt{z}}
\newcommand{\kZ}{\mlt{Z}}
\newcommand{\ke}{\mlt{e}}
\newcommand{\kgam}{\gamma}
\newcommand{\kGam}{\Gamma}
\newcommand{\kkgam}{\mgr{\gamma}}
\newcommand{\ktau}{\mgr{\tau}}
\newcommand{\kbeta}{\mgr{\beta}}
\newcommand{\kdelta}{\mgr{\delta}}
\newcommand{\kpsi}{\mgr{\psi}}
\newcommand{\knu}{\mgr{\nu}}
\newcommand{\ksig}{\sigma^2}
\newcommand{\kkeps}{\mgr{\keps}}
\newcommand{\kOm}{\mgr{\Omega}}
\newcommand{\kzero}{\mlt{0}}
%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%
%III) TOP MATTER INFORMATION
\title{Conjugate Bayes: Poisson plus Gamma}
\date{}
\maketitle %this comes at the end of the top matter to set it.
\vspace{-0.5in}
Consider the Poisson model for a random variate $y$ with parameter $\klam$, given as
%
\begin{equation}
\label{equ1}
\begin{split}
&p\kl y | \klam \kr=\frac{\klam^{y}exp(-\klam)}{y !}, \quad \text{with}\\
&E\kl y | \klam \kr = V\kl y | \klam \kr = \klam, \quad \klam>0, y \in \kll 0,1,2,3,.... \krr
\end{split}
\end{equation}
\vspace{0.25in}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{Part (a)}\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Now consider a sample of $n$ observations from this distribution, with each observation generically labeled $y_i, i=1 \ldots n$. Write down the joint distribution for the sample data (in \emph{un}-logged form). Call it $p\kl \ky | \klam\kr$.
\vspace{0.1in}
\emph{Solution}:\\
%%%%%%%%%%%%%%%%%%%
%
\begin{equation*}
p\kl \ky | \klam\kr = \prod_{i=1}^n{\frac{\klam^{y_i}exp(-\klam)}{y_i!}}=\kl \prod_{i=1}^n{\frac{1}{y_i!}} \kr \klam^{\kl\sum_{i=1}^n y_i\kr} exp\kl -n\klam\kr
\end{equation*}
\vspace{0.25in}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{Part (b)}\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Suppose you stipulate a \emph{gamma} prior density for $\klam$ with shape parameter $a$ and inverse scale (``rate'') parameter $b$, given as
%
\begin{equation}
\label{equ1}
\begin{split}
&p\kl \klam \kr=g\kl a,b\kr = \frac{b^a}{\kGam\kl a\kr}\klam^{\kl a-1\kr}exp\kl -b\klam\kr, \quad \text{with}\\
&E\kl \klam \kr = \frac{a}{b}, \medspace V\kl \klam \kr = \frac{a}{b^2}, \quad \klam,a,b>0,
\end{split}
\end{equation}
%
Show that the posterior distribution of $\klam$, given your collected data from the Poisson, is also a gamma. Show the form of the posterior shape and rate parameters (you can call them $a^*$ and $b^*$).
\vspace{0.1in}
\emph{Solution}:\\
%%%%%%%%%%%%%%%%%%%
%
\begin{equation*}
\begin{split}
p\kl \klam | \ky\kr \propto &\klam^{\kl a-1\kr}exp\kl -b\klam\kr \klam^{\kl\sum_{i=1}^n y_i\kr} exp\kl -n\klam\kr =\\
&\klam^{\kl a+\sum_{i=1}^n y_i-1\kr}exp\kl-\kl b+n\kr\klam\kr
\end{split}
\end{equation*}
%
This describes the kernel of another gamma density with posterior shape $a^*=a+\sum_{i=1}^n y_i$ and posterior rate $b^*=b+n$. Therefore, we can deduce that $\klam|\ky \sim g\kl a+\sum_{i=1}^n y_i, b+n\kr$.
\vspace{0.25in}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{Part (c)}\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Show that the posterior expectation can be written as a weighted average of the prior expectation and the sample mean. What happens to this posterior expectation as $n\rightarrow \infty$?
\vspace{0.1in}
\emph{Solution}:\\
%%%%%%%%%%%%%%%%%%%
%
\begin{equation*}
E\kl \klam | \ky\kr = \frac{a+\sum_{i=1}^n y_i}{b+n}=\kl\frac{b}{b+n}\kr\frac{a}{b}+\kl\frac{n}{b+n}\kr\frac{\sum_{i=1}^n y_i}{n}
\end{equation*}
%
The limit of the first weight is 0, and that of the second weight is 1, so as the sample size increases the posterior expectation will converge to the sample mean.
\vspace{0.25in}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{Part (d)}\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Suppose you are an investor on ``\emph{Shark Tank}'' (popular TV show where wealthy entrepreneurs are solicited to finance new products), and you are asked to invest in a product with weekly sales of $y$ units. The inventor (person who is asking you for money) reports that, at the beginning of last year, he expected to sell 10 units per week with a variance of 5 units. He then sold 898 units over the entire year, that is over 52 weeks. He shows you a histogram chart of weekly sales, and it looks exactly like a Poisson distribution.\\
You quickly realize that the inventor's prior expectation and variance correspond to a gamma with shape $a=20$ and rate $b=2$. Letting the actual weekly sales follow a Poisson with parameter $\klam$, you quickly compute the posterior expectation and variance for weekly sales. You would be comfortable investing in this deal if you could expect at least 20 sales per week for the coming year. Would you invest or not? Explain.\\
Now suppose the inventor had sold all 898 units in 40 weeks instead of 52. How, if at all, would this change your decision? Explain.
\vspace{0.1in}
\emph{Solution}:\\
%%%%%%%%%%%%%%%%%%%
%
Based on the results from the previous section, the posterior expectation can be computed as $\frac{20+898}{2+52}=\frac{918}{54}=17$ - not enough to invest.\\
In the second scenario, we have a posterior expectation of $\frac{20+898}{2+40}=\frac{918}{42}\approx 21.86$, so now you would go for it.
\end{document}