% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.

% Make two column format for LaTex 2e.
\documentclass[10pt,twocolumn]{article} %,twocolumn
%\usepackage[dvips]{graphicx,graphics}
\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
% \documentstyle[times,twocolumn]{article}

% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{9.2in} \setlength{\textwidth}{6.875in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.1875in}  % Centers text.
\setlength{\evensidemargin}{-.1875in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-8pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-3pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand {\diff}[1] {\frac{\partial}{\partial #1}}
\newcommand{\jacob}[3]{\frac{\partial^2 #3}{\partial #1 \partial #2}}
\newcommand{\der}[2]{\frac{\partial #2}{\partial #1}}
\begin{document}

% Don't want date printed
%\date{January 23, 2003}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat312: Midterm I Solution}

% For single author (just remove % characters)
\author{Moo K. Chung, Yulin Zhang\\
mchung@stat.wisc.edu, yulin@stat.wisc.edu}
% For two authors (default example)
\maketitle
\begin{enumerate}
\item[1.] Let $X_1, \cdots, X_n$ be a random sample from Bernoulli distribution with parameter $p$.
\begin{itemize}
\item[(a)] What is $\mathbb{E}(S^2/p^2)$? $S^2$ is the sample variance. Explain your results (10 points).
\item[(b)] Find an unbiased estimator of $p^2$. Explain your results (5 points). 
\end{itemize}

{\em Solution.} (a) The sample variance is an unbiased estimator of the population variance. Hence
$\mathbb{E}(S^2/p^2) =\mathbb{E}(S^2)/p^2 = {\bf Var}(X_i)/p^2.$ The variance for a Bernoulli random variable can be esily computed as ${\bf Var} (X_i) = p(1-p)$. So $\mathbb{E}(S^2/p^2)=(1-p)/p$. (b) We know $S^2$ and $\bar X$ will be unbiased estimators of population variance $p(1-p)$ and mean $p$ respecively. So ${\bf E}(S^2) - {\bf E}(\bar X) = p(1-p) - p = -p^2$. Hence, $\bar X - S^2$ is an unbiased estimator of $p^2$.

\item[2.] Let $X_1 ,X_2$ be a random sample from $N(0, 1/\theta)$. Note that the sample size is 2 and the density function for $X_i$ is $f(x_i) = \frac{\sqrt{\theta}}{\sqrt{2\pi}}\exp(-\theta x_i^2/2)$.
\begin{itemize}
\item[(a)] Obtain an estimator of $\theta$ using the method of moments. Explain your results (5 points).
\item[(b)] Find the likelihood function and use it to obtain the maximum likelihood estimator of $\theta$.  (5 points for each question).

\end{itemize}

{\em Solution.} (a) Match the second moments from the sample and population. 
$$ (X_1^2 +X_2^2)/2 = \mathbb{E}(X_i^2) = {\bf Var} (X_i) =\frac{1}{\theta}.$$
Hence $\hat \theta = 2/(X_1^2+X_2^2)$. (b) The likelihood function is $L(\theta) =\theta/(2\pi)\exp(-\theta(x_1^2 +x_2^2)/2)$. Get log-likelihood function $\ln L(\theta) = const + \ln \theta - \theta (x_1^2+x_2^2)/2$. Differentiate with respect to $\theta$ to get the maximum: 
$$\frac{d \ln L(\theta)}{d\theta} = \frac{1}{\theta} - \frac{1}{2}(x_1^2+x_2^2)=0.$$
Solving the equation, we get $\hat \theta = 2/(x_1^2 + x_2^2)$.

\item[3.] Consider the sample of IQ of 10 dogs: 25, 21, 22, 17, 29, 25, 16, 20, 19, 22. Suppose that these are from a normal population.
\begin{itemize}
\item[(a)] Compute a $95\%$ confidence interval of the mean IQ (5 points).
\item[(b)] Somehow you figured out the variance of IQ to be $9$. Compute a $95\%$ confidence interval of the mean IQ. Explain why you have a smaller confidence interval (5 points for each question).\end{itemize}

{\em Solution.} (a) Let $X_i \sim N(\mu, \sigma^2)$. Since we do not know $\sigma$, we need $t$-statistic to construct a CI: $t=(\bar x - \mu)/(s/\sqrt{n})$. After a lengthy algebra, CI will be $\bar x \pm t_{\alpha/2,9}s/\sqrt{10}$. $\bar x = 21.6, s = \sqrt{15.6},t_{\alpha/2,9}= 2.26$. After punching a calculator, CI is $[18.8, 24.4]$. (b) Since $\sigma$ is known, we need $Z$-statistic to construc a CI: $z=(\bar x - \mu)/(\sigma/\sqrt{n})$. After a lengthy algebra, CI will be $\bar x \pm z_{\alpha/2}3/\sqrt{10}$. CI is $[19.7, 23.5]$. In (a), two parameters are unknown while in (b), only one paramter is unknown. Hence your interval estimation should be more accurate in (b).

\item[4.] 47 out of 102 doctors knew the generic name for the drug methadone. 
\begin{itemize}
\item[(a)] Compute a $98\%$ confidence interval for the propotion of all doctors who know the generic name for methadone (10 points).
\item[(b)] Compute a $98\%$ confidence interval for the propotion of all doctors who {\bf do not know} the generic name for methadone (5 points). 
\end{itemize}
\begin{verbatim}
>qnorm(0.02)
[1] -2.053749
>qnorm(0.01)
[1] -2.326348
\end{verbatim}

{\em Solution.} (a) Since the sample size is large, CI compuation will be based on $Z = (\hat p - p)/\sqrt{p(1-p)/n} \sim N(0,1)$. This requires solving a quadratic equation so we will approxmate this by substituting $p$ in the denominator to $\hat p$. Then CI becomes $\hat p \pm z_{\alpha/2}\sqrt{\hat p(1-\hat p)/n}$. $\hat p = 47/102$. So CI is $[0.35, 0.58]$. (b) The propotion of doctors who do know know is $q=1-p$. Hence CI would be $[1-0.58, 1-0.35]=[0.42, 0.65]$.

\end{enumerate}

\end{document}
