knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
knitr::opts_chunk$set(fig.width=10, fig.height=4)
options(tidyverse.quiet = TRUE)

epichannel

DOI Lifecycle: experimental CRAN status

The goal of epichannel is to create classical endemic channel for Epidemiological Surveillance in Public Health.

Installation

if(!require("devtools")) install.packages("devtools")
devtools::install_github("avallecam/epichannel")

Example

This is a basic example which shows you how to solve a common problem:

library(epichannel)
## basic example code
library(tidyverse)

# disease dataset
denv <-
  readr::read_csv("https://dengueforecasting.noaa.gov/Training/Iquitos_Training_Data.csv") %>%
  mutate(year = lubridate::year(week_start_date),
         epiweek = lubridate::epiweek(week_start_date)) %>%
  mutate(adm="iquitos") %>%
  # cases per season - replace wiht a dummy year
  mutate(year = str_replace(season,"(.+)/(.+)","\\1") %>% as.double())

denv %>% glimpse()

# population dataset
popdb <-
  readr::read_csv("https://dengueforecasting.noaa.gov/PopulationData/Iquitos_Population_Data.csv") %>%
  janitor::clean_names() %>%
  mutate(adm="iquitos")

popdb %>% glimpse()
# denv %>% count(year,season,lag_year)
# denv %>%
#   ggplot(aes(x = week_start_date,y = total_cases)) +
#   geom_col()
# popdb %>% count(year)
# denv %>% count(year)
# denv %>% left_join(popdb)
epi_adapted <-
  epi_adapt_timeserie(db_disease = denv,
                      db_population = popdb,
                      var_admx = adm,
                      var_year = year, # must be a common variable name between datasets
                      var_week = season_week,
                      # var_year = year, 
                      # var_week = epiweek,
                      var_event_count = total_cases,
                      var_population = estimated_population)
disease_now <- epi_adapted %>%
  filter(var_year==max(var_year))

disease_pre <- epi_adapted %>%
  filter(var_year!=max(var_year))
disease_channel <-
  epi_create_channel(time_serie = disease_pre,
                     disease_name = "denv",
                     method = "gmean_1sd")

disease_channel
epi_join_channel(disease_channel = disease_channel,
                 disease_now = disease_now) %>%
  # ggplot
  epi_plot_channel() +
  labs(title = "Dengue virus Endemic Channel. Iquitos, Peru 2008/2009",
       caption = "Source: https://dengueforecasting.noaa.gov/",
       # x = "epiweeks",
       x = "Seasonal week",
       y = "Number of cases") +
  theme_bw()

Contribute

Feel free to fill an issue with a reprex or implement new methods through a pull request. Here are some alternatives:

More

For a more advanced approach into surveillance algorithms refer to the surveillance R package and associated publications:

References



avallecam/epichannel documentation built on Dec. 26, 2020, 10 p.m.