Takes a list of times and counts and fits a quasi-poisson model
fitted with a log link function to count data using local regression
using the package locfit
.
Usage
poisson_locfit_model(
d = i_incidence_input,
...,
window = 14,
deg = 1,
frequency = "1 day",
predict = TRUE
)
Arguments
- d
input data
A dataframe containing the following columns:
count (positive_integer) - Positive case counts associated with the specified timeframe
time (as.time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`
Ungrouped.
No default value.
- ...
not used and present to allow proportion model to be used in a
group_modify
- window
a number of data points defining the bandwidth of the estimate, smaller values result in less smoothing, large value in more. The default value of 14 is calibrated for data provided on a daily frequency, with weekly data a lower value may be preferred. - (defaults to
14
)- deg
polynomial degree (min 1) - higher degree results in less smoothing, lower values result in more smoothing. A degree of 1 is fitting a linear model piece wise. - (defaults to
1
)- frequency
the density of the output estimates as a time period such as
7 days
or2 weeks
. - (defaults to"1 day"
)- predict
result is a prediction dataframe. If false we return the
locfit
models (advanced). - (defaults toTRUE
)
Value
A dataframe containing the following columns:
time (as.time_period + group_unique) - A (usually complete) set of singular observations per unit time as a
time_period
incidence.fit (double) - an estimate of the incidence rate on a log scale
incidence.se.fit (double) - the standard error of the incidence rate estimate on a log scale
incidence.0.025 (positive_double) - lower confidence limit of the incidence rate (true scale)
incidence.0.5 (positive_double) - median estimate of the incidence rate (true scale)
incidence.0.975 (positive_double) - upper confidence limit of the incidence rate (true scale)
growth.fit (double) - an estimate of the growth rate
growth.se.fit (double) - the standard error the growth rate
growth.0.025 (double) - lower confidence limit of the growth rate
growth.0.5 (double) - median estimate of the growth rate
growth.0.975 (double) - upper confidence limit of the growth rate
No mandatory groupings.
No default value.
Details
This results is an incidence rate estimate plus an absolute exponential growth rate estimate both based on the time unit of the input data (e.g. for daily data the rate will be cases per day and the growth rate will be daily).
Examples
growthrates::england_covid %>%
growthrates::poisson_locfit_model(window=21) %>%
dplyr::glimpse()
#> Rows: 26,790
#> Columns: 12
#> Groups: class [19]
#> $ class <fct> 00_04, 00_04, 00_04, 00_04, 00_04, 00_04, 00_04, 00_0…
#> $ time <time_prd> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14…
#> $ incidence.fit <dbl> -17.891227, -17.395804, -16.873590, -16.331042, -15.7…
#> $ incidence.se.fit <dbl> 1.9111699, 1.9238465, 1.9194060, 1.9000358, 1.8681012…
#> $ incidence.0.025 <dbl> 4.010032e-10, 6.419738e-10, 1.091671e-09, 1.950766e-0…
#> $ incidence.0.5 <dbl> 1.698004e-08, 2.786752e-08, 4.697785e-08, 8.081996e-0…
#> $ incidence.0.975 <dbl> 7.190010e-07, 1.209705e-06, 2.021596e-06, 3.348359e-0…
#> $ growth.fit <dbl> 0.4798757, 0.4792888, 0.4776793, 0.4752744, 0.4723010…
#> $ growth.se.fit <dbl> 0.05395200, 0.05584978, 0.05729669, 0.05835042, 0.059…
#> $ growth.0.025 <dbl> 0.3741317, 0.3698252, 0.3653799, 0.3609097, 0.3565117…
#> $ growth.0.5 <dbl> 0.4798757, 0.4792888, 0.4776793, 0.4752744, 0.4723010…
#> $ growth.0.975 <dbl> 0.5856197, 0.5887523, 0.5899788, 0.5896391, 0.5880903…