# compute_expected: Compute expected counts for each day In excessmort: Excess Mortality

## Description

Compute the expected death count for each unit of time. We assume counts are ovedsispersed Poisson distributed with a trend that accounts for changes in death rate across time and a seasonal effect. The function take data frame with dates and counts and returns the data frame with the expected counts as a new column. It also returns a logical column that is 'TRUE' if that entry was used in the estimation procedure.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ```compute_expected( counts, exclude = NULL, trend.knots.per.year = 1/7, harmonics = 2, frequency = NULL, weekday.effect = FALSE, keep.components = FALSE, verbose = TRUE ) ```

## Arguments

 `counts` A data frame with dates, counts, and population size `exclude` A list of dates to exclude when fitting the model `trend.knots.per.year` Number of knots per year used for the time trend `harmonics` Number of harmonics to include in the seasonal effect `frequency` Number of data points per year. If not provided, the function attempts to estimate it `weekday.effect` A logical that determines if a day of the week effect is included in the model `keep.components` A logical that if 'TRUE' forces the function to return the estimated trend, seasonal model, and weekday effect, if included in the model. `verbose` A logical that if 'TRUE' makes function prints out updates on the estimation procedure

## Value

The 'counts' data.frame with two columns added: 'expected' and 'excluded'. The 'expected' column is the estimated expected value of the counts for that date. The 'excluded' column is a logical vector denoting if that date was excluded when estimating the expected value.

If the argument 'keep.components' is 'TRUE' a list is returned with 'counts' data.frame in the first component, the estimated trend in the second, the estimated seasonal effect in the third and the estimated weekday effects in the fourth.

## Examples

 ```1 2 3 4 5``` ```data(new_jersey_counts) exclude_dates <- as.Date("2012-10-29") + 0:180 counts <- compute_expected(new_jersey_counts, exclude = exclude_dates, weekday.effect = TRUE) library(ggplot2) expected_plot(counts) ```

excessmort documentation built on Oct. 11, 2021, 9:06 a.m.