This uses a generalised linear model to fit a quasi-binomial model with a time
varying rate as a natural cubic spline with approx one degree of freedom per
window
units of the time series.
Arguments
- d
Proportion model input
A dataframe containing the following columns:
denom (positive_integer) - Total test counts associated with the specified timeframe
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
)- frequency
the density of the output estimates as a time period such as
7 days
or2 weeks
. - (defaults to"1 day"
)
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
proportion.fit (double) - an estimate of the proportion on a logit scale
proportion.se.fit (double) - the standard error of proportion estimate on a logit scale
proportion.0.025 (proportion) - lower confidence limit of proportion (true scale)
proportion.0.5 (proportion) - median estimate of proportion (true scale)
proportion.0.975 (proportion) - upper confidence limit of proportion (true scale)
No mandatory groupings.
No default value.
Examples
# TODO: find out cause of the warnings
# "observations with zero weight not used for calculating dispersion"
suppressWarnings(
growthrates::england_covid %>%
growthrates::proportion_glm_model(window=21) %>%
dplyr::glimpse()
)
#> Rows: 26,790
#> Columns: 7
#> Groups: class [19]
#> $ class <fct> 00_04, 00_04, 00_04, 00_04, 00_04, 00_04, 00_04, 00_…
#> $ time <time_prd> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1…
#> $ proportion.fit <dbl> -8.889667, -8.842042, -8.794113, -8.745576, -8.69612…
#> $ proportion.se.fit <dbl> 51.296631, 48.776606, 46.264194, 43.765615, 41.28710…
#> $ proportion.0.025 <dbl> 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-…
#> $ proportion.0.5 <dbl> 0.0001377866, 0.0001445064, 0.0001516000, 0.00015913…
#> $ proportion.0.975 <dbl> 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.000000…