| calculate_rollmean | R Documentation |
Calculation of the rolling means of infection numbers for infections panel data.
calculate_rollmean(
object,
k = 7,
align = "center",
fill = NA,
col_name = NULL,
overwrite = FALSE,
verbose = FALSE
)
object |
object of class |
k |
|
align |
|
fill |
|
col_name |
|
overwrite |
|
verbose |
|
Calculates the rolling mean of the infections panel data for all time points for each region.
Set the rolling window by the parameter k (default: 7).
Set the fill value for the observations left/within/right to the data range with parameter fill (default: NA).
Parameter align defines whether the index of the result should be left- or right-aligned or centered (default).
If col_name is NULL, the column is defined as "<Column name of cases>_rm".
Set overwrite to TRUE, if an existing column should be overwritten.
The method uses the function rollmean from the zoo package (see the corresponding documentation).
infpan object including column with rolling means in the infections panel data
Thomas Wieland
Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. Journal of Public Health 33(11), 2497-2511. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.1007/s10389-024-02218-x")}
infpan-class, load_infections_paneldata, calculate_rollsum,
calculate_Rt, calculate_cum, calculate_incidence
data(COVID19Cases_geoRegion)
# Get SWISS COVID19 cases at NUTS 3 level
COVID19Cases_geoRegion <-
COVID19Cases_geoRegion[!COVID19Cases_geoRegion$geoRegion %in% c("CH", "CHFL"),]
# Exclude CH = Switzerland total and CHFL = Switzerland and Liechtenstein total
COVID19Cases_geoRegion <-
COVID19Cases_geoRegion[COVID19Cases_geoRegion$datum <= "2020-05-31",]
# Extract first COVID-19 wave
infpan_CH <- load_infections_paneldata(
data = COVID19Cases_geoRegion,
col_cases = "entries",
col_date = "datum",
col_region = "geoRegion",
other_cols = c("Population" = "pop"),
verbose = TRUE
)
# Import as infections panel data set (class infpan)
infpan_CH <- calculate_rollmean(
infpan_CH,
col_name = "RollingMean",
verbose = TRUE
)
# Calculate rolling mean of cases as "RollingMean"
summary(infpan_CH)
# Summary of infpan object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.