Homework 4

Due by 12/11/2016 (Sunday!).

Complete exercises and replicate outputs. Note that only PDF and HTML formats will be accepted. All R code you used to generate figures should be included in the document.

Word documents converted to PDF will no longer be accepted. Only documents with proper math typesetting ($\LaTeX$, $MathJax$, ...) are permitted. That means you either have to use $\LaTeX$ or one of knitr, sweave (part of RStudio) or jupyter.

If you decide to use pure $\LaTeX$ with listings package, you can use the following initialization code in the header

\usepackage{listings}
\lstset{language=R,
basicstyle=\footnotesize\ttfamily,
commentstyle=\ttfamily\color{gray},
numberstyle=\color{gray}\footnotesize,
numbers=left,
stepnumber=1,
frame=leftline,
breaklines=true}

and include blocks of code like this

\begin{lstlisting}[firstnumber=last]
...R-code...
\end{lstlisting}

If you are having troubles installing $\LaTeX$, you can use one of the online editors such as Overleaf or ShareLatex.

1. Moments of poisson distribution

Prove that both expected value and variance of random variable $X \sim Po(\lambda)$ is equal to $\lambda$.

Hint: use the fact that all probabilities sum to 1

2. Poisson distribution

Let $X$ be a number of deaths caused by horse kick in Prussian army forces (Bortkiewicz 1898) and let's assume it follows Poisson distribution with parameter $\lambda$, i.e. $X \sim Poiss(\lambda)$. We have data for 10 army units for 20 years with total sample size $M = 200$ ($200 = 10 \times 20$). Number of deaths in a single unit over one year is given in the following table, where $n$ is number of deaths and $m_n$ number of units with $n$ deaths. Calculate expected frequencies under the assumption that $X \sim Poiss(\lambda)$, where $\lambda = \frac{\sum_n n m_n}{\sum_n m_n}$.

$n$ 0 1 2 3 4 $\geq$ 5
$m_n$ 109 65 22 3 1 0

Display expected and observed frequencies in a table and calculate probability that there will be 4 or more deaths from theoretical model, i.e. $Pr(X \geq 4)$.

3. Finish exercise 29 (Normal distribution, simulation study I)

Don't forget to calculate $Pr(\bar{X}_n > 151)$ and make a comparison between theoretical probability and observed probability from simulated data.

In addition to that, prove that if $X \sim N(\mu, \sigma^2)$, then $ \overline{X}_n \sim N(\mu, \frac{\sigma^2}{n}) $.

4. Finish exercise 30 (Normal distribution, simulation study II)

Same as before, don't forget to compare theoretical probability with observed probability.

In addition to that, prove that if $X\sim N(\mu_1,\sigma^2_1)$ and $Y$ $\sim N(\mu_2,\sigma^2_2)$, then $\overline{X}_{n_1}-\overline{Y}_{n_2} \sim N(\mu_1-\mu_2,\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2})$.