\documentclass[11pt]{article} 
%\usepackage{amsbsy} % for \boldsymbol and \pmb 
\usepackage{graphicx} % To include pdf files!
\usepackage{amsmath}
\usepackage{amsbsy}
\usepackage{amsfonts}
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref} % For links
\usepackage{fullpage}
%\pagestyle{empty} % No page numbers


\begin{document}
%\enlargethispage*{1000 pt} 

\begin{center}   
{\Large \textbf{STA 312s19 Assignment Two}}\footnote{This assignment was prepared by  \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner},
Department of Mathematical and Computational Sciences, University of Toronto. It is licensed under a 
\href{http://creativecommons.org/licenses/by-sa/3.0/deed.en_US}
     {Creative Commons Attribution - ShareAlike 3.0 Unported License}. Use any part of it as you like and share the result freely. The \LaTeX~source code is available from the course website:
\href{http://www.utstat.toronto.edu/~brunner/oldclass/312s19} {\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/312s19}}}
\vspace{1 mm}
\end{center}

\noindent
The paper and pencil questions are not to be handed in. They are practice for Quiz 2 on January 21st. The R parts may be handed in as part of the quiz. \textbf{Bring your printout(s) to the quiz}. Do not write anything on your printout(s) in advance except possibly your name and student number.

\begin{enumerate} 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% More Review. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

\item Let $X$ have a Bernoulli distribution with parameter $\theta$. Verify the formulas for expected value and variance on the formula sheet. 

\item Let $X$ have an exponential distribution with parameter $\lambda$. Verify the formulas for expected value and variance on the formula sheet. 

\item Let $X \sim N(\mu,\sigma^2)$. Show $Z=\frac{X-\mu}{\sigma} \sim N(0,1)$. 

\item Prove that if $Z \sim N(0,1)$, then $Z^2 \sim \chi^2(1)$. 

\item Let $X_1, \ldots, X_n$ be a random sample (that is, independent and identically distributed) from a distribution with expected value $\mu$ and variance $\sigma^2$. The sample mean is $\overline{X}_n = \frac{1}{n}\sum_{i=1}^n X_i$. 
    \begin{enumerate}
        \item Calculate $E(\overline{X}_n)$. Show your work.
        \item Calculate $Var(\overline{X}_n)$. Show your work.
    \end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item Let $X_1, \ldots, X_n$ be a random sample (that is, independent and identically distributed) from a Poisson distribution with parameter $\lambda>0$. The sample mean for a sample of $n=49$ is $\overline{X} = 4.2$.
    \begin{enumerate}
        \item Derive a formula for $\widehat{\lambda}$, the maximum likelihood estimate of $\lambda$.
        \item Carry out the second derivative test.
        \item Give a point estimate of $\lambda$. Your answer is a number.
        \item Give a 95\% confidence interval for $\lambda$; the answer is a pair of numbers. My lower confidence limit is 3.63. Note that in this problem you do \emph{not} need to go through the Fisher information to get the standard error, because you can just write down the exact variance of $\widehat{\lambda}$. \vspace{50mm}

\pagebreak 

        \item Carry out a two-sided $Z$-test of $H_0:\lambda=3$. 
           \begin{enumerate}
                \item What is the critical value? The answer is a number You can use R, or just look it up on the lecture slides.
                \item Calculate the test statistic. The answer is a number. I did it two ways and got $Z=4.1$ and $Z=4.85$. The method yielding 4.1 is more similar to what we will be doing later in the course.
                \item Do you reject the null hypothesis at $\alpha=0.05$? Answer Yes or No. 
                \item Do you conclude that $\lambda$ is different from 3? Answer Yes or No. 
                \item If the answer to the last question was Yes, do you conclude that $\lambda$ is less than 3, or that $\lambda$ is greater than 3? Pick one. 
                \item Use R to calculate the two-sided $p$-value for $Z=4.1$. My answer is 4.131501e-05 = 0.00004131501.
            \end{enumerate}
    \end{enumerate}

\item Let $X_1, \ldots, X_n$ be a random sample from a distribution with density $f(x|\pi) = \pi e^{-\pi/x} \frac{1}{x^2}$ for $x>0$, and zero for $x \leq 0$. The unknown parameter $\pi$ is greater than zero.
    \begin{enumerate}
        \item Verify that this really is a density by showing that it integrates to one. To save some work, you may use the fact that all the densities on the formula sheet integrate to one.
        \item \label{mle} Derive a formula for the MLE of $\pi$. Include the second derivative test. Show your work and circle your final answer.
        \item \label{vhat} Give a formula for $\widehat{v}_n$, the estimated asymptotic variance of $\widehat{\pi}_n$. Show a little work. 
        \item The file \href{http://www.utstat.toronto.edu/~brunner/data/legal/inversegamma.data.txt}
                    {\texttt{http://www.utstat.toronto.edu/$\sim$brunner/data/legal/inversegamma.data.txt}}
has a set of raw data. Using R and your answers to Questions~\ref{mle} and~\ref{vhat}, calculate
    \begin{enumerate}
        \item The maximum likelihood estimate $\widehat{\pi}_n$.
        \item A 95\% confidence interval for $\pi$.
    \end{enumerate}
The answers are numbers on your printout.  
        \item Test $H_0: \pi = 3.14159$ with a two-sided large-sample $Z$-test, using the $\alpha=0.05$ significance level.
            \begin{enumerate}
                \item There are two critical values, one for the lower tail and one for the upper tail. What are they? The answers are numbers.
                \item What is the value of the test statistic? The answer is a number on your printout. 
                \item Use R to calculate the 2-sided $p$-value. The answer is a number on your printout. My answer is \texttt{0.01125527}.  
        \item Do you reject the null hypothesis? Answer Yes or No.
        \item Are the results statistically significant? Answer Yes or No.
        \item Do these data contradict claim that $\pi = 3.14159$? Answer Yes or No.
            \end{enumerate}
    \end{enumerate} \vspace{20mm}

\end{enumerate} % End of all the questions

\noindent
\textbf{Bring your printout(s) to the quiz.} Do not write anything on your printout(s) in advance except possibly your name and student number.


\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% See work and quiz files for R work.



