% 302f16Assignment1.tex                 REVIEW
\documentclass[12pt]{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 302f16 Assignment Two}}\footnote{Copyright information is at the end of the last page.}
\vspace{1 mm}
\end{center}

\noindent
Please bring your R printout from Question~\ref{R} to Quiz Two; you may be asked to hand it in, or maybe not. The other problems are preparation for the quiz in tutorial, and are not to be handed in. Starting with Problem~\ref{mgfstart}, you can play a little game. Try not to do the same work twice. Instead, use results of earlier problems whenever possible. 

\vspace{3mm}


\begin{enumerate} 

%%%%%%%%%%%%%%%% Stats

        \item This problem is more review. Let $Y_1, \ldots, Y_n$ be a random sample\footnote{Random sample means independent and identically distributed.} from a normal distribution with mean $\mu$ and variance $\sigma^2$, so that $T = \frac{\sqrt{n}(\overline{Y}-\mu)}{S} \sim t(n-1)$. This is something you don't need to prove, for now. 
    \begin{enumerate}
        \item Derive a $(1-\alpha)100\%$ confidence interval for $\mu$. ``Derive" means show all the high school algebra. Use the symbol $t_{\alpha/2}$ for the number satisfying $Pr(T>t_{\alpha/2})= \alpha/2$.
        \item \label{ci} A random sample with $n=23$ yields $\overline{Y} = 2.57$ and a sample variance of $S^2=5.85$. Using the critical value $t_{0.025}=2.07$, give a 95\% confidence interval for $\mu$. The answer is a pair of numbers.
        \item Test $H_0: \mu=3$ at $\alpha=0.05$. 
            \begin{enumerate}
                \item Give the value of the $T$ statistic. The answer is a number.
                \item State whether you reject $H_0$, Yes or No.
                \item Can you conclude that $\mu$ is different from 3? Answer Yes or No.
                \item If the answer is Yes, state whether $\mu>3$ or $\mu<3$. Pick one.
            \end{enumerate}
    \end{enumerate}

%%%%%%%%%%%%%%%% Text on simple regression

    \item In the textbook \emph{Regression Analysis}, please read pages 1-7 for general ideas. Then read Section 1.4 on pages 7-9. The chapter has an appendix with some derivations, too.
        \begin{enumerate}
            \item In formula (1.5), assume $E(\epsilon_i) = 0$. What is $E(y_i)$? 
            \item Partially differentiate expression (1.8) to obtain formulas (1.11) and (1.13) for $b_0$ and $b_1$. 
            \item Prove that (1.13) and (1.14) are equal.
            \item For the centered model (1.15), partially differentiate to obtain the the least squares estimates of $\gamma_0$ and $\beta_1$. Is the least-squares estimate of the slope affected by centering?
            \item For the simple regression model (1.5), show that the residuals add to zero.
            \item Do Exercise 1.6. See the definition of least squares estimation in the lecture slides.
            \item \label{R} Do Exercise 1.9 using R. I got the data in using the \texttt{c()} function -- \texttt{c} for collect. The problem is asking you to calculate $b_0$ and $b_1$. \textbf{Bring your printout to the quiz. You may be asked to hand it in.}
        \end{enumerate}
  
    \item Please read Section 1.5 in the textbook \emph{Regression Analysis}. Assume $E(\epsilon_i) = 0$.
        \begin{enumerate}
            \item In formula (1.5), what is $E(y_i)$? 
            \item Obtain the least squares estimator of $\beta_1$ for this model. Show all your work. 
            \item Do Exercise 1.1. 
            \item What is $\sum_{i=1}^n e_i$ for this model? Must it be equal to zero? Answer Yes or No.
            \item What is $E(e_i)$? What is $E(\sum_{i=1}^n e_i)$?
        \end{enumerate}
  
% \pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%% MGF %%%%%%%%%%%%%%%%%%%%%%%%%

    \item \label{mgfstart} Denote the moment-generating function of a random variable $Y$ by $M_Y(t)$. The moment-generating function is defined by $M_Y(t) = E(e^{Yt})$.
    \begin{enumerate}
        \item Let $a$ be a constant. Prove that $M_{aX}(t) = M_X(at)$.
        \item Prove that $M_{X+a}(t) = e^{at}M_X(t)$.
        \item Let $X_1, \ldots, X_n$ be \emph{independent} random variables. Prove that 
\begin{displaymath}
    M_{\sum_{i=1}^n X_i}(t) = \prod_{i=1}^n M_{X_i}(t).
\end{displaymath}
For convenience, you may assume that $X_1, \ldots, X_n$ are all continuous, so you will integrate. This is not the way I did it in class. 
    \end{enumerate} 

     \item Recall that if $X\sim N(\mu,\sigma^2)$, it has moment-generating function $M_X(t) = e^{\mu t + \frac{1}{2}\sigma^2t^2}$. 
    \begin{enumerate}
        \item Let $X\sim N(\mu,\sigma^2)$ and $Y=aX+b$, where $a$ and $b$ are constants. Find the distribution of $Y$. Show your work. 
        \item Let $X\sim N(\mu,\sigma^2)$ and $Z = \frac{X-\mu}{\sigma}$. Find the distribution of $Z$.  Show your work.        
        \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. Find the distribution of $Y = \sum_{i=1}^nX_i$.  Show your work.
        \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. Find the distribution of the sample mean $\overline{X}$. Show your work.
        \item Let $X_1, \ldots, X_n$ be a random sample from a $N(\mu,\sigma^2)$ distribution. Find the distribution of $Z = \frac{\sqrt{n}(\overline{X}-\mu)}{\sigma}$. Show your work. 
        \item Let $X_1, \ldots, X_n$ be independent random variables, with $X_i \sim N(\mu_i,\sigma_i^2)$. Let $a_1, \ldots, a_n$ be constants.   
Find the distribution of $Y = \sum_{i=1}^n a_iX_i$. Show your work. 
    \end{enumerate}

\item For the model of formula (1.20) in the text, suppose that the $\epsilon_i$ are normally distributed and independent, which is the usual assumption. What is the distribution of $y_i$?  What is the distribution of $b_1$? You should be able to just write down the answers based on your earlier work.

\pagebreak

    \item A Chi-squared random variable $X$ with parameter $\nu>0$ has moment-generating function $M_X(t) = (1-2t)^{-\nu/2}$. 
    \begin{enumerate}
        \item Let $X_1, \ldots, X_n$ be independent random variables with $X_i \sim \chi^2(\nu_i)$ for $i=1, \ldots, n$. Find the distribution of $Y = \sum_{i=1}^n X_i$. 
        \item Let $Z \sim N(0,1)$. Find the distribution of $Y=Z^2$.  For this one, you need to integrate. Recall that the density of a normal random variable is $f(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}$. You will still use moment-generating functions.
        \item Let $X_1, \ldots, X_n$ be random sample from a $N(\mu,\sigma^2)$ distribution. Find the distribution of $Y = \frac{1}{\sigma^2} \sum_{i=1}^n\left(X_i-\mu \right)^2$. 
        \item Let $Y=X_1+X_2$, where $X_1$ and $X_2$ are independent, $X_1\sim\chi^2(\nu_1)$ and $Y\sim\chi^2(\nu_1+\nu_2)$, where $\nu_1$ and $\nu_2$ are both positive. Show $X_2\sim\chi^2(\nu_2)$. 
        \item Let $X_1, \ldots, X_n$ be random sample from a $N(\mu,\sigma^2)$ distribution. Show
\begin{displaymath}
    \frac{(n-1)S^2}{\sigma^2} \sim \chi^2(n-1),
\end{displaymath}
where $S^2 = \frac{\sum_{i=1}^n\left(X_i-\overline{X} \right)^2 }{n-1}$.
Hint: $\sum_{i=1}^n\left(X_i-\mu \right)^2 = \sum_{i=1}^n\left(X_i-\overline{X} + \overline{X} - \mu \right)^2 = \ldots$

For this question, you may use the independence of $\overline{X}$ and $S^2$ without proof. We will prove it later.  
    \end{enumerate}
    
\end{enumerate}

\vspace{60mm}

\noindent
\begin{center}\begin{tabular}{l}
\hspace{6in} \\ \hline
\end{tabular}\end{center}
This assignment was prepared by  \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner},
Department of Statistical 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/302f16} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/302f16}}

\end{document}

