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)
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() # 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))
Fourth, create the endemic channel
here you can choose between three available methods [@bortman1999elaboracion]:
"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") 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()
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.