The goal of epichannel is to create classical endemic channel for Epidemiological Surveillance in Public Health.
if(!require("devtools")) install.packages("devtools")
devtools::install_github("avallecam/epichannel")
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()
#> Rows: 468
#> Columns: 12
#> $ season <chr> "2000/2001", "2000/2001", "2000/2001", "2...
#> $ season_week <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13...
#> $ week_start_date <date> 2000-07-01, 2000-07-08, 2000-07-15, 2000...
#> $ denv1_cases <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
#> $ denv2_cases <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
#> $ denv3_cases <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
#> $ denv4_cases <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
#> $ other_positive_cases <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,...
#> $ total_cases <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,...
#> $ year <dbl> 2000, 2000, 2000, 2000, 2000, 2000, 2000,...
#> $ epiweek <dbl> 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 3...
#> $ adm <chr> "iquitos", "iquitos", "iquitos", "iquitos...
# population dataset
popdb <-
readr::read_csv("https://dengueforecasting.noaa.gov/PopulationData/Iquitos_Population_Data.csv") %>%
janitor::clean_names() %>%
mutate(adm="iquitos")
popdb %>% glimpse()
#> Rows: 15
#> Columns: 3
#> $ year <dbl> 2000, 2001, 2002, 2003, 2004, 2005, 2006,...
#> $ estimated_population <dbl> 386666, 393355, 399770, 405988, 412095, 4...
#> $ adm <chr> "iquitos", "iquitos", "iquitos", "iquitos...
epi_adapted <-
epi_adapt_timeserie(db_disease = denv,
db_population = popdb,
var_admx = adm, # common in denv and popdb
var_year = year, # common in denv and popdb
var_week = season_week, # only in denv
# var_year = year,
# var_week = epiweek,
var_event_count = total_cases, # only in denv
var_population = estimated_population) # only in popdb
#> Joining, by = c("var_admx", "var_year")
disease_now <- epi_adapted %>%
filter(var_year==max(var_year))
disease_pre <- epi_adapted %>%
filter(var_year!=max(var_year))
Fourth, create the endemic channel
here you can choose between three available methods (Bortman 1999):
"gmean_1sd"
is geometric mean with 1 standard deviation
(default)."gmean_2sd"
is geometric mean with 2 sd."gmean_ci"
is geometric mean with 95 percent confidence
intervals.disease_channel <-
epi_create_channel(time_serie = disease_pre,
disease_name = "denv",
method = "gmean_1sd")
#> Joining, by = "var_admx"
disease_channel
#> # A tibble: 52 x 6
#> var_admx var_week median low_95 upp_95 key
#> <fct> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 iquitos 1 2.80 0.267 6.80 denv
#> 2 iquitos 2 2.64 0.484 5.82 denv
#> 3 iquitos 3 2.78 0.259 6.75 denv
#> 4 iquitos 4 2.86 0.424 6.62 denv
#> 5 iquitos 5 2.72 0.454 6.12 denv
#> 6 iquitos 6 2.25 0.127 5.44 denv
#> 7 iquitos 7 2.22 0.0474 5.52 denv
#> 8 iquitos 8 2.34 0.167 5.61 denv
#> 9 iquitos 9 1.82 -0.420 5.44 denv
#> 10 iquitos 10 2.66 -0.513 8.65 denv
#> # ... with 42 more rows
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()
#> Joining, by = c("var_admx", "var_week")
Feel free to fill an issue with a
reprex
or implement new methods
through a pull request. Here are some alternatives:
For a more advanced approach into surveillance algorithms refer to the
surveillance
R package and associated publications:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.