desc_year: Compute yearly epidescriptors

View source: R/desc_year.R

desc_yearR Documentation

Compute yearly epidescriptors

Description

Compute yearly epi descriptors based on weekly case counts.

Usage

desc_year(
  data,
  cases,
  time,
  space,
  descriptors,
  pop = NULL,
  sweek = 1,
  collapse53 = TRUE
)

Arguments

data

Data frame with the input data.

cases

Character. Name of the variable in data that contains the case counts.

time

Character. Name of the variable in data that contains the epiyearweek date temporal identifier (see epiyearweek). It must be of type character.

space

Character. Name of the variable in data that contains the spatial identifier for which a case count time series is available.

descriptors

A named list with the descriptor function and their arguments. See details.

pop

Character. Name of the variable in data that contains the population counts. Only required if the descriptor 'Inc' (incidence) is used.

sweek

Integer between 1-52 that determines the first week of the season for which the descriptors will be calculated; e.g. sweek=40 will compute descriptors between week 40 and week 39 next year. Defaults to 1.

collapse53

If TRUE (default), collapse week 53 such that half of the cases are assigned to the previous (w52) and next (w01) weeks. It is recommended so that all years have the same number of weeks.

Details

The argument descriptors consists of a nested list where:

  • The name of the first level will determine the name of the descriptor.

  • The elements of the first levels should also be a list with elements fun (descriptor type) and the parameters n, x or p if necessary.

Please see the example to see it in practice.

Value

A data frame with the resulting descriptors for every epidemiological year.

See Also

desc_list to access the list of descriptors and its parameters.

Examples

# Spatiotemporal
data(dengueRio)
dengue <- dengueRio

# Prepare epiyearweeks
dengue$yearweek <- epiyearweek(dengue$date)

# List of descriptors to be computed
descriptors <- list(
  "Ap" = list(fun = "Ap"),
  "Tp" = list(fun = "Tp"),
  "Cnf" = list(fun = "Cnf", n = 3, x = 5),
  "Cnf2" = list(fun = "Cnf", n = 6, x = 5),
  "Cmax" = list(fun = "Cmax", x = 5),
  "Cmed" = list(fun = "Cmed", x = 5),
  "p" = list(fun = "p", x = 5),
  "Cwf" = list(fun = "Cwf", n = 3),
  "Cwf2" = list(fun = "Cwf", n = 6),
  "Cwmax" = list(fun = "Cwmax"),
  "Cwmed" = list(fun = "Cwmed"),
  "Inc" = list(fun = "Inc", p = 1e5)
)

# Compute them
res <- desc_year(
  dengue,
  cases = "cases",
  time = "yearweek",
  space = "muni_code",
  pop = "pop",
  sweek = 40,
  descriptors = descriptors
)

epidesc documentation built on Aug. 8, 2026, 1:06 a.m.