The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The R package epidesc provides the tools to easily compute a series of epidemiological indicators to characterise different transmission patterns of infectious diseases. The work is based on the publication How heterogeneous is the dengue transmission profile in Brazil? A study in six Brazilian states published in PLOS Neglected Tropical Diseases by Iasmim Ferreira de Almeida, Raquel Martins Lana and Cláudia Torres Codeço in 2022.
While epidesc includes all the descriptors proposed in the original publication, we aim to continuously expand its library of epidemiological descriptors. Contributions are always welcome! Please open an issue or contact us by email to discuss your ideas.
To show the functionality of the package, we load weekly dengue data for municipalities in Rio de Janeiro.
library(epidesc)
data(dengueRio)
head(dengueRio)
#> muni_code date cases pop
#> 1 330010 2017-01-01 4 179527
#> 2 330010 2017-01-08 6 179527
#> 3 330010 2017-01-15 21 179527
#> 4 330010 2017-01-22 13 179527
#> 5 330010 2017-01-29 17 179527
#> 6 330010 2017-02-05 9 179527epidesc has a few simple data requirements:
data.frame containing the case counts and the corresponding spatial and temporal identifiers with no missing values. In the sample dataset, these are the columns cases (number of dengue cases), date (temporal identifier), and muni_code (spatial identifier).Date format.If any of these requirements are not met, the package function will throw error messages to let you know what is happening.
The only required pre-processing step is to convert the dates into epidemiological yearweek format: yyyyww. We can easily do so by using the function epiyearweek as follows. Note that epiyearweek lets you choose whether epidemiological weeks start on a Sunday or a Monday via the start argument; Brazilian epidemiological weeks start on a Sunday:
dengue <- dengueRio
dengue$yearweek <- epiyearweek(dengue$date, start = "Sunday")
head(dengue)
#> muni_code date cases pop yearweek
#> 1 330010 2017-01-01 4 179527 201701
#> 2 330010 2017-01-08 6 179527 201702
#> 3 330010 2017-01-15 21 179527 201703
#> 4 330010 2017-01-22 13 179527 201704
#> 5 330010 2017-01-29 17 179527 201705
#> 6 330010 2017-02-05 9 179527 201706If you would like to check the start and end dates of the epidemiological weeks in the example data, you can access: https://portalsinan.saude.gov.br/calendario-epidemiologico-2017.
📝 NOTE: For years where there is an epiweek 53, cases are split between week 52 and week 1 of the following year so that all years have 52 weeks. This behaviour is controlled by the argumant
collapse53in the functiondesc_year, which is TRUE by default since it is recommended to do so.
To see the list of available descriptors and their required parameters, we can use the function desc_list():
desc_list()| class | fun | description | param1 | param2 |
|---|---|---|---|---|
| Peak | Ap | Maximum cases peak - amplitude | ||
| Peak | Tp | Week where the maximum peak occurred - time | ||
| Period with cases | Cnf | Frequency of periods of consecutive ‘n’ weeks or longer with at least ‘x’ cases | n | x |
| Period with cases | Cmax | Maximum duration in consecutive weeks with at least ‘x’ cases | x | |
| Period with cases | Cmed | Median duration in consecutive weeks with at least ‘x’ cases | x | |
| Period with cases | Isof | Number of weeks with isolated cases | ||
| Period with cases | p | Proportion of weeks with at least ‘x’ cases | x | |
| Period without cases | Cwf | Frequency of periods of consecutive weeks with at least ‘n’ weeks without cases. | n | |
| Period without cases | Cwmax | Maximum duration in consecutive weeks without cases | ||
| Period without cases | Cwmed | Median duration in consecutive weeks without cases | ||
| Incidence | Inc | Annual incidence rate per ‘p’ population | p |
In this table we can see each indicator’s class, function name, description, and required parameters. We will need this is information when we specify which descriptors we want to compute.
The first step when computing the descriptors is to decide which ones to compute and what values to use for the parameters. In our case, we are interested in computing the following indicators:
To compute these descriptors, we need to pass a nested list to the desc_year function. In the first level, we state the output descriptors names that we would like to use, and in the second level, we specify the name of the function fun as in the table above as well as the parameters (x, n or p depending on the descriptor):
descriptors <- list(
Ap = list(fun = "Ap"),
Cmax = list(fun = "Cmax", x = 5),
Cnf = list(fun = "Cnf", n = 3, x = 5),
Inc = list(fun = "Inc", p = 100000)
)The last detail we need to consider is the epidemiological week we want to use as the start of the year for computing yearly descriptors. For many diseases, such as dengue in Brazil, the start of the season does not coincide with the 1st of January but rather it occurs much later in the year, so it makes more sense to use this time point. We can specify the first epidemiological week with the argument sweek. In our example, we set it to week 41, meaning that yearly descriptors for year t will be computed starting from week 41 of year t until week 40 of year t+1.
Now we are ready to finally compute our descriptors with a call to desc_year:
res <- desc_year(
data = dengue, # Input data frame
cases = "cases", # Name of the column of the cases
time = "yearweek", # Name of the column with the epiyearweek
space = "muni_code", # Name of the column with the spatial ID
pop = "pop", # Column with population, needed because of 'Inc'
sweek = 41, # Starting epiweek 41 for dengue in Brazil
descriptors = descriptors # Descriptor list
)Our descriptors have been computed! Let’s have a look at the results of epidemiological year 2020 (from W41-2020 to W40-2021):
head(res[res$epiyear == "2020/2021", ])
#> muni_code epiyear Ap Cmax Cnf Inc
#> 369 330010 2020/2021 7 3 1 52.749921
#> 370 330015 2020/2021 1 0 0 8.873637
#> 371 330020 2020/2021 3 0 0 18.011821
#> 372 330022 2020/2021 1 0 0 8.221448
#> 373 330023 2020/2021 7 2 0 165.070563
#> 374 330025 2020/2021 2 0 0 34.445039Descriptors are calculated only for complete epidemiological years. If an epidemiological year has missing weeks or missing case records, the corresponding descriptors will be returned as NA. This typically occurs at the beginning and end of a time series, where the first or last epidemiological year is incomplete.
For example, although the dataset starts in the first SE of 2017, the epidemiological year 2016/2017 begins in epidemiological week 41 of 2016. Because data are only available from 2017 onward, this epidemiological year is incomplete and its descriptors are returned as NA. The same applies to the final epidemiological year if the dataset ends before all epidemiological weeks are available (e.g., 2022).
head(res[res$epiyear == "2016/2017", ])
#> muni_code epiyear Ap Cmax Cnf Inc
#> 1 330010 2016/2017 NA NA NA NA
#> 2 330015 2016/2017 NA NA NA NA
#> 3 330020 2016/2017 NA NA NA NA
#> 4 330022 2016/2017 NA NA NA NA
#> 5 330023 2016/2017 NA NA NA NA
#> 6 330025 2016/2017 NA NA NA NA
head(res[res$epiyear == "2022/2023", ])
#> muni_code epiyear Ap Cmax Cnf Inc
#> 553 330010 2022/2023 NA NA NA NA
#> 554 330015 2022/2023 NA NA NA NA
#> 555 330020 2022/2023 NA NA NA NA
#> 556 330022 2022/2023 NA NA NA NA
#> 557 330023 2022/2023 NA NA NA NA
#> 558 330025 2022/2023 NA NA NA NAThese binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.