The function fits a Poisson regression model (GLM) with mean predictor $$\log \mu_t = \alpha + \beta t$$ as specified by the Farrington procedure. If requested, Anscombe residuals are computed based on an initial fit and a 2nd fit is made using weights, where base counts suspected to be caused by earlier outbreaks are downweighted.

## Usage

algo.farrington.fitGLM(response, wtime, timeTrend = TRUE,
reweight = TRUE, ...)
algo.farrington.fitGLM.fast(response, wtime, timeTrend = TRUE,
reweight = TRUE, ...)
algo.farrington.fitGLM.populationOffset(response, wtime, population,
timeTrend=TRUE,reweight=TRUE, ...)

## Arguments

response

The vector of observed base counts

wtime

Vector of week numbers corresponding to response

timeTrend

Boolean whether to fit the $$\beta t$$ or not

reweight

Fit twice -- 2nd time with Anscombe residuals

population

Population size. Possibly used as offset, i.e. in algo.farrington.fitGLM.populationOffset the value log(population) is used as offset in the linear predictor of the GLM: $$\log \mu_t = \log(\texttt{population}) + \alpha + \beta t$$ This provides a way to adjust the Farrington procedure to the case of greatly varying populations. Note: This is an experimental implementation with methodology not covered by the original paper.

...

Used to catch additional arguments, currently not used.

## Details

Compute weights from an initial fit and rescale using Anscombe based residuals as described in the anscombe.residuals function.

Note that algo.farrington.fitGLM uses the glm routine for fitting. A faster alternative is provided by algo.farrington.fitGLM.fast which uses the glm.fit function directly (thanks to Mikko Virtanen). This saves computational overhead and increases speed for 500 monitored time points by a factor of approximately two. However, some of the routine glm functions might not work on the output of this function. Which function is used for algo.farrington can be controlled by the control\$fitFun argument.

## Value

an object of class GLM with additional fields wtime,

response and phi. If the glm returns without convergence NULL is returned.

anscombe.residuals,algo.farrington