\documentclass[11pt]{article}
\usepackage{amsmath,amssymb}
%\usepackage{fancyhdr}

\parindent=0cm
\parskip .2cm
\textheight 21.7cm
%\pagestyle{fancy}

%\lhead{\nouppercase{\rightmark}}
%\rhead{\nouppercase{\leftmark}}
%\fancyhead[LE,RO]{\thepage}
%\fancyfoot[]{}

\def\bo#1{\mbox{\boldmath $#1$}}
\def\rang{\mathop{\rm rang}}
\def\tr{\mathop{\rm tr}}

\newtheorem{oppgave}{Oppgave}


\begin{document}
\thispagestyle{empty}

{\bf \Large First  mandatory assignment in STK3100/STK4100-f16 }

Posted:  Thursday September 29th.

Deadline: Thursday October 20th, 14:30 pm.


This is the first out of two mandatory assignments in STK31000/STK4100-f16.
It consists of two problems. Both handwritten reports and answers
using a word processing system are acceptable. Where you use R (or some other
statistical package) the relevant part of the output must be enclosed or pasted
into the report. It is OK if you cooperate, but each student must deliver a separate
and individually formulated report. Also in case of cooperation it should be indicated
in the report whom the others are. There is more information at:
http://www.mn.uio.no/math/english/studies/admin/mandatory-assignments/index.html


The answers shall be delivered in the box in the hallway  on the 7'th floor
in  Niels Henrik Abels house. Use the standard front page which can be
downloaded from www.mn.uio.no/math/studier/admin/obligatorisk-innlevering/obligforside.pdf
and indicate whether you attend STK3100 or STK4100.


\vspace{0.5cm}
{\Large{\bf Problem 1}}

This problem is about testing of two sided fully specified
hypotheses for a scalar parameter. There are several approaches:
likelihood ratio  test, Wald test and the  score test. In the exercise
you shall compare them in a model where the variable is Poisson
distributed.


Suppose $y \sim \mbox{Po($\lambda$})$, i.e. Poisson distributed with
parameter  $\lambda$.
\begin{itemize}
\item[a)] Find the log likelihood $l(\lambda)$, score function $\frac{\partial l}{\partial \lambda}$ and
expected  information  ${\cal I}(\lambda)$ based on $y$.
\end{itemize}
Let $y_i,\; i=1,\ldots,n$ be independent, identically Poisson distributed
variables with expectation $\lambda$.
\begin{itemize}
\item[b)] Describe the approximate distribution for the
maximum likelihood estimater (MLE) $\hat \lambda = \sum_i y_i /n$ when n is large and
explain why the test statistic   for the Wald test for $\mbox{H}_0: \lambda = \lambda_0$
is given by
$$
Z_W(\lambda_0) = \frac{\hat{\lambda}-\lambda_0}{\sqrt{\hat{\lambda}}} \sqrt{n}
$$
so that the test statistic is approximately  standard normally
distributed under the null hypotheses.

\item[c)] Show that  the score test for the same null hypothesis
has test statistic
$$
Z_U(\lambda_0) = \frac{\hat{\lambda}-\lambda_0}{\sqrt{\lambda_0}} \sqrt{n} .
$$
Also explain why the distribution of $Z_U(\lambda_0) $
is approximately  standard normally
distributed under $\mbox{H}_0$.
\item[d)] Show that the  test statistic  for the  likelihood ratio test for
$\mbox{H}_0: \lambda = \lambda_0$
can be written
$$
Z_{LR}^2(\lambda_0) = 2\sum_i [ y_i \log(\frac{\hat{\lambda}}{\lambda_0})- (\hat{\lambda}-\lambda_0)].
$$
What is the approximate distribution of  $Z_{LR}^2(\lambda_0)$ when $n$ is large?


\item[e)] With  $n=100$ and  $\sum_i y_i=40$ implement and compare the three tests for
$\mbox{H}_0: \lambda=0.5$. What are the P-values?

\item[f)] With  $n=100$ and  $\sum_i y_i=10$  implement and compare the three tests for
$\mbox{H}_0: \lambda=0.2$. What are the P-values?

\item[g)] For each of the test statistics from parts
b)-d) the approximate
95\% confidence interval for $\lambda$ has the  form $\{\lambda_0: Z^2_{\cdot}(\lambda_0)<3.84\}$.
Explain why.

\item[h)] Show that when  $\mbox{se}(\hat{ \lambda})= \sqrt{\hat{\lambda}/n}$ the
95\% confidence  interval  based  on the  Wald statistic  $Z_W(\lambda_0)$ is
$\hat{\lambda} \pm 1.96 \mbox{se}(\hat{\lambda})$.

\item[i)] Show that the boundaries of the
confidence  interval  based  on the  score statistic
$Z_U(\lambda_0)$ are the solutions of a quadratic equation. \\
(Solution:$<\hat{\lambda}_L,\hat{\lambda}_U> = \hat{\lambda}+1.92/n\pm
\sqrt{(\hat{\lambda}+1.92/n)^2 -\hat{\lambda}^2}.$
\item[j)] Compute the  confidence intervals when  $n=100$ and $\sum_{i }y_i=40$.
( For the interval based on the likelihood ratio statistic $Z_{LR}^2(\lambda_0)$
there is no explicit formula for the end points of the
interval, but  you can read them off a plot of $(\lambda_0,Z_{LR}^2(\lambda_0))$).
\item[k)] Compute the  confidence intervals when  $n=100$ and $\sum_{i }y_i=10$.
\end{itemize}

\noindent
Now we consider the GLM framework and let $\mu=E[\sum_i y_i]=n\lambda$.
Then $\sum_i y_i$ is Poisson distributed.
Consider the canonical  parameter $\theta = \log \mu$, i.e. the log link.
\begin{itemize}
\item[l)] Find the approximate distribution for the  MLE  $\hat\theta$.
\item[m)] Formulate the approximate
95\% Wald confidence interval  $<\hat\theta_L,\hat\theta_U>$
for $\theta$. Explain why
$$
<\exp(\hat\theta_L)/n,
\exp(\hat\theta_U)/n>
$$
is an  approximate  95\%  confidence  interval for $\lambda$.
\item[n)] Compute this interval with $n=100$ and $\sum_{i} y_i=40$.
Compare with the other  confidence intervals for $\lambda$.
\item[o)] The variance stabilizing transform for a Poisson
variable is $\sqrt{\cdot}$, so the distribution of $\sqrt{n\hat{\lambda}}-\sqrt{n\lambda_0} $
is approximately normal with expectation zero and variance $1/4$. Use this to construct
another approximate 95\%
confidence interval for $\lambda$.
\item[p)] Let $\lambda_0=5$ and $n=10$. Write a simulation
program to investigate how often the confidence intervals in
part h) and o) contain $\lambda_0$. Do the same for
$\lambda_0=0.5$ and $n=10$. Comment on your result.
\end{itemize}


{\Large{\bf Problem 2}}

The data set "Third-party-claims" is described on page 17
in deJong and Heller. In the examples in chapter 6 the number of claims
is treated as response and the number of accidents as co-variate.
We will in this exercise also consider including the other
covariates.
\begin{itemize}
\item[a)]To check that the data are properly entered reproduce
figure 4.1 on page 50 in deJong and Heller.
\item[b)] To get an impression of how the continuous
covariates are related, use command {\tt pairs(third[,3:7])}.
What is your impression?
\item[c)] Compute the mean and empirical variance of the number
of claims in each of the 13 locations. What is the best way of
checking for over dispersion: categorize using covariates  or categorizing using groups defined by the response.
Give your reasons.
\item[d)] Start by  fitting a general negative binomial
regression model of the same type as in deJong and
Heller but with  the covariates
{\tt log(ki)}, {\tt sd}  and { \tt log(pop-density)} used in addition.
Comment on the result. How do you explain the sign of
the coefficients of {\tt  log(ki)} and {\tt log(accidents)}?
\item[e)] Check whether the covariates  {\tt sd}  and { \tt log(pop-density)} can be
dropped.
\item[f)] Compute the covariance matrix/ correlation matrix
of the estimated coefficients. Comment on the correlations
corresponding to the estimate of
the coefficients of {\tt  log(ki)} and {\tt log(accidents)}.
\item[g)] Discuss whether it is reasonable to
retain both  covariates  {\tt  log(ki)} and {\tt log(accidents)}.
If one has to be deleted,
which one is the most reasonable to keep?
\item[h)] As an alternative to the fitted negative binomial
model you chose in part g) use the same covariates to
fit a model using quasi-likelihood. Compare this
to your chosen negative binomial model.
\item[i)] Compare the residuals for the two models
from part h) with the residuals from the corresponding
Poisson model. Comment on what you find.
\end{itemize}

\end{document}
