knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures" )
SEIRfansy
r badger::badge_devel("umich-biostatistics/SEIRfansy", "blue")
r badger::badge_code_size("umich-biostatistics/SEIRfansy")
r badger::badge_doi("https://doi.org/10.1101/2020.09.24.20200238", "orange")
This R
package fits Extended Susceptible-Exposed-Infected-Recovery (SEIR) Models for handling high false negative rate and symptom based administration of diagnostic tests.
If the devtools package is not yet installed, install it first:
install.packages('devtools')
# install SEIRfansy from Github: devtools::install_github('umich-biostatistics/SEIRfansy')
Once installed, load the package:
library(SEIRfansy)
For this example, we use the built-in package data set covid19
, which contains dailies and totals of cases, recoveries, and deaths from the COVID-19 outbreak in India from January 30 to September 21 of 2020.
You will need the dplyr
package for this example.
library(dplyr)
Training data set:
For training data, we use cases from April 1 to June 30
train = covid19[which(covid19$Date == "01 April "):which(covid19$Date == "30 June "),]
Testing data set:
For testing data, we use cases from July 1 to July 31
test = covid19[which(covid19$Date == "01 July "):which(covid19$Date == "31 July "),]
Data format for multinomial and Poisson distribution:
train_multinom = train %>% rename(Confirmed = Daily.Confirmed, Recovered = Daily.Recovered, Deceased = Daily.Deceased) %>% dplyr::select(Confirmed, Recovered, Deceased) test_multinom = test %>% rename(Confirmed = Daily.Confirmed, Recovered = Daily.Recovered, Deceased = Daily.Deceased) %>% dplyr::select(Confirmed, Recovered, Deceased) train_pois = train %>% rename(Confirmed = Daily.Confirmed) %>% dplyr::select(Confirmed)
Initialize parameters:
N = 1341e6 # population size of India data_initial = c(2059, 169, 58, 424, 9, 11) pars_start = c(c(1,0.8,0.6,0.4,0.2), c(0.2,0.2,0.2,0.25,0.2)) phases = c(1,15,34,48,62)
If interest is in model estimation but not prediction, then use SEIRfansy()
. Otherwise, use SEIRfansy.predict()
(see below).
?SEIRfansy
cov19est = SEIRfansy(data = train_multinom, init_pars = pars_start, data_init = data_initial, niter = 1e3, BurnIn = 1e2, model = "Multinomial", N = N, lambda = 1/(69.416 * 365), mu = 1/(69.416 * 365), period_start = phases, opt_num = 1, auto.initialize = TRUE, f = 0.15)
Inspect the results:
names(cov19est) class(cov19est$mcmc_pars) names(cov19est$plots)
Plot the results:
plot(cov19est, type = "trace") plot(cov19est, type = "boxplot")
If interest is in model estimation and prediction, then use SEIRfansy.predict()
, which first runs SEIRfansy()
internally, and then predicts.
?SEIRfansy.predict
cov19pred = SEIRfansy.predict(data = train_multinom, init_pars = pars_start, data_init = data_initial, T_predict = 60, niter = 1e3, BurnIn = 1e2, data_test = test_multinom, model = "Multinomial", N = N, lambda = 1/(69.416 * 365), mu = 1/(69.416 * 365), period_start = phases, opt_num = 1, auto.initialize = TRUE, f = 0.15)
Inspect the results:
names(cov19pred) class(cov19pred$prediction) class(cov19pred$mcmc_pars) names(cov19pred$plots)
Plot the results:
plot(cov19pred, type = "trace") plot(cov19pred, type = "boxplot") plot(cov19pred, type = "panel") plot(cov19pred, type = "cases")
Ritwik Bhaduri, Ritoban Kundu, Soumik Purkayastha, Mike Kleinsasser, Lauren J Beesley, Bhramar Mukherjee. "EXTENDING THE SUSCEPTIBLE-EXPOSED-INFECTED-REMOVED(SEIR) MODEL TO HANDLE THE HIGH FALSE NEGATIVE RATE AND SYMPTOM-BASED ADMINISTRATION OF COVID-19 DIAGNOSTIC TESTS: SEIR-fansy." medRxiv 2020.09.24.20200238; doi: https://doi.org/10.1101/2020.09.24.20200238
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.