\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 Three}}\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 part of this assignment is not to be handed in. It is practice for Quiz 3 on January 28th. The R part may be handed in as part of the quiz. \textbf{Bring hard copy of your printout to the quiz}. Do not write anything on your printout in advance except possibly your name and student number.

\begin{enumerate} 

%%%%%%%%%%%%%%%%%%%%%%%%%%% Log normal: paper and pencil %%%%%%%%%%%%%%%%%%%%%%%%%%%

\item In an earlier assignment, you proved that the log-normal distribution has density
\begin{displaymath}
    f(t|\mu,\sigma^2) = \frac{1}{\sigma \sqrt{2\pi}} \,  
    \exp -\left\{{\frac{(\log(t)-\mu)^2} {2\sigma^2}}\right\} \, \frac{1}{\log(t)} 
\end{displaymath} 
    \begin{enumerate} 
        \item Derive formulas for the maximum likelihood estimates of $\mu$ and $\sigma^2$.  Show your work. 
        
        Start with $\mu$. Since your answer is the same for every value of $\sigma^2>0$, you can apply the one-variable second derivative test. Do so.
        
        Now derive $\widehat{\sigma}^2$. Holding $\mu$ fixed at $\widehat{\mu}$, you have another one-variable problem, and again you can apply the one-variable second derivative test. Because of the special form of this distribution (and the ordinary normal), you don't need to examine the eigenvalues of the Hessian matrix.
        \item Based on the R output below, give numerical values of the MLE. This is something you could do with a calculator, if you had the output.
\begin{verbatim}
 length(x); mean(log(x)); var(log(x))
[1] 17
[1] -1.263583
[1] 5.114263
\end{verbatim}

    \end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%% Weibull, mostly with R. %%%%%%%%%%%%%%%%%%%%

\item The Weibull distribution, which is never mentioned in most statistics classes, will play an important role in this course. The Weibull is written (parameterized) in quite a few different ways, even in the same book. Here is the density of the Weibull from p.~16 of our text.
\begin{displaymath}
    f(t|\alpha,\lambda) = \left\{ \begin{array}{ll} % ll means left left
   \alpha\lambda(\lambda t)^{\alpha-1} \, \exp\{-(\lambda t)^\alpha \} 
   & \mbox{for $ t \geq 0$}  \\
   0     & \mbox{for } t < 0 
   \end{array}  \right. , % Need that crazy invisible period
\end{displaymath}
where the parameters $\alpha$ and $\lambda$ are both greater than zero.
    \begin{enumerate}
        \item Verify that $f(t|\alpha,\lambda)$ above really is a density, by showing that it integrates to one.
        \item The Weibull density reduces to an exponential for one particular value of $\alpha$. What is that value?
        \item Prove that if $T$ has a Weibull distribution, $ \displaystyle E(T^k) = \frac{\Gamma(1+\frac{k}{\alpha})}{\lambda^k}$.
        \item The median of a continuous distribution is the point with 50\% of the probability above and 50\% below. Find the median of the Weibull distribution. Show your work. 
        
 \pagebreak %%%%%%%%%%%%%%%%%%%%%%%%%%%%

        \item The file 
\href{http://www.utstat.toronto.edu/~brunner/data/legal/Weibull.data1.txt}
     {\texttt{http://www.utstat.toronto.edu/$\sim$brunner/data/legal/Weibull.data1.txt}}
contains a random sample from a Weibull distribution.
            \begin{enumerate}
                \item Use R to find the MLE. The answer is a pair of numbers from your printout. 
                \item Calculate a 95\% confidence interval for $\alpha$. The answer is a pair of numbers from your printout. My lower confidence limit is \texttt{1.780622}.
                \item Give a point estimate of the expected value for the Weibull data. The answer is a number that you calculate with R. It should appear on your printout. The answer should be fairly close to the sample mean. Why?
                \item Calculate a 95\% confidence interval for the expected value. Hint: to apply the delta method, you will need the derivative of the gamma function. See \texttt{help(digamma)}. 
                \item Give a point estimate of the median for the Weibull data. The answer is a number that you calculate with R. It should appear on your printout. The answer should be fairly close to the sample median.
                \item Give a 95\% confidence interval for the median. The answer is a pair of numbers on your printout, the lower confidence limit and the upper confidence limit.
                \item This is the last question, and you should do it last. Using the usual 0.05 significance level, test whether the expected value equals the median. What do you conclude? There is more than one right way to do this. I did it three ways, obtaining $Z=9.92$, $Z=-22.71$ and $G^2=381.89$. Note that the $Z$-tests are 2-sided, so the difference in sign is not a problem.
            \end{enumerate} % End of numerical Weibull questions
    \end{enumerate} % End of Weibull questions
\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.



