% \VignetteIndexEntry{Encephalitis - Loglinear Poisson Model and Normal Distribution Model}
%\VignetteEngine{knitr::knitr}
%\VignetteEncoding{UTF-8}

\documentclass[a4paper]{article}

\title{Encephalitis - Loglinear Poisson Model and Normal Distribution Model}

\begin{document}

\maketitle
First of all, the encephalitis data are loaded:
<<results='hide',eval=TRUE>>=
library(catdata)
data(encephalitis)
attach(encephalitis)
@


Some variables are renamed and recoded before fitting the model.
<<eval=TRUE>>=
BAV <- country
BAV[BAV==2] <-0
TIME <- year
@
%
The number of infections (count) is modeled in dependence on country and TIME.
A Loglinear Poisson Model is fitted.
<<eval=TRUE>>=
enc1 <- glm(count ~ TIME+I(TIME^2)+BAV+TIME*BAV, family = poisson)
summary(enc1)
@
%
For comparison the linear Normal Model with the identity link is fitted.
<<eval=TRUE>>=
enc2 <- glm(count ~ TIME+I(TIME^2)+BAV+TIME*BAV, family = gaussian("identity"))
summary(enc2)
@
%
Fit of loglinear Normal Model. That means a normal model with log-link.
<<eval=TRUE>>=
enc3 <- glm(count ~ TIME+I(TIME^2)+BAV+TIME*BAV, family = gaussian("log"), 
            start=enc1$coef)
summary(enc3)
@

\end{document}


