Skip to content
Snippets Groups Projects
Commit 65058422 authored by Christina Azodi's avatar Christina Azodi
Browse files

update description and namespace

parent cb2c845e
No related branches found
No related tags found
No related merge requests found
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sirPlus-functions.R
\name{progress.seiqhrf.icm}
\alias{progress.seiqhrf.icm}
\title{Progress icm}
\usage{
progress.seiqhrf.icm(dat, at)
}
\arguments{
\item{dat}{Object containing all data}
\item{at}{?}
}
\value{
progress
}
\description{
Function to get progress of icms
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sirPlus-functions.R
\name{saveout.seiqhrf.icm}
\alias{saveout.seiqhrf.icm}
\title{Save icm}
\usage{
saveout.seiqhrf.icm(dat, s, out = NULL)
}
\arguments{
\item{dat}{Object containing all data}
\item{out}{?}
\item{at}{?}
}
\value{
out to save
}
\description{
Function to save icm
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/epi-functions.R
\name{set.control}
\alias{set.control}
\title{Set control params}
\usage{
set.control(
type = "SEIQHRF",
nsteps = 366,
nsims = 8,
ncores = 4,
prog.rand = FALSE,
rec.rand = FALSE,
fat.rand = TRUE,
quar.rand = FALSE,
hosp.rand = FALSE,
disch.rand = TRUE
)
}
\arguments{
\item{type}{Type of model: SI, SIR, SIS, SEIR, SEIQHR and
SEIQHRF available, but only SEIQHRF is likely to work in the
current version of the code.}
\item{s.num}{Initial number of *S compartment individuals in
the simulated population. An overall population of 10,000 is a good
compromise. A set of models will still take several minutes or more
to run, in parallel.}
\item{e.num}{Initial number of E compartment individuals in
the simulated population.}
\item{i.num}{Initial number of I compartment individuals in
the simulated population.}
\item{q.num}{Initial number of Q compartment individuals in
the simulated population.}
\item{h.num}{Initial number of H compartment individuals in
the simulated population.}
\item{r.num}{Initial number of R compartment individuals in
the simulated population.}
\item{f.num}{Initial number of F compartment individuals in
the simulated population.}
}
\value{
control.icm object
}
\description{
Sets the controls for stochastic individual contact models simulated with
icm.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/epi-functions.R
\name{set.init}
\alias{set.init}
\title{Set init params}
\usage{
set.init(
s.num = 9997,
e.num = 0,
i.num = 3,
q.num = 0,
h.num = 0,
r.num = 0,
f.num = 0
)
}
\arguments{
\item{s.num}{Initial number of *S compartment individuals in
the simulated population. An overall population of 10,000 is a good
compromise. A set of models will still take several minutes or more
to run, in parallel.}
\item{e.num}{Initial number of E compartment individuals in
the simulated population.}
\item{i.num}{Initial number of I compartment individuals in
the simulated population.}
\item{q.num}{Initial number of Q compartment individuals in
the simulated population.}
\item{h.num}{Initial number of H compartment individuals in
the simulated population.}
\item{r.num}{Initial number of R compartment individuals in
the simulated population.}
\item{f.num}{Initial number of F compartment individuals in
the simulated population.}
}
\value{
init.icm object
}
\description{
Sets the initial conditions for stochastic individual contact models
simulated with icm.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/epi-functions.R
\name{set.param}
\alias{set.param}
\title{Set epidemic params}
\usage{
set.param(
inf.prob.e = 0.02,
act.rate.e = 10,
inf.prob.i = 0.05,
act.rate.i = 10,
inf.prob.q = 0.02,
act.rate.q = 2.5,
quar.rate = 1/30,
hosp.rate = 1/100,
disch.rate = 1/15,
prog.rate = 1/10,
prog.dist.scale = 5,
prog.dist.shape = 1.5,
rec.rate = 1/20,
rec.dist.scale = 35,
rec.dist.shape = 1.5,
fat.rate.base = 1/50,
hosp.cap = 40,
fat.rate.overcap = 1/25,
fat.tcoeff = 0.5,
vital = TRUE,
a.rate = (10.5/365)/1000,
a.prop.e = 0.01,
a.prop.i = 0.001,
a.prop.q = 0.01,
ds.rate = (7/365)/1000,
de.rate = (7/365)/1000,
di.rate = (7/365)/1000,
dq.rate = (7/365)/1000,
dh.rate = (20/365)/1000,
dr.rate = (7/365)/1000,
out = "mean"
)
}
\arguments{
\item{inf.prob.e}{Probability of passing on infection at each
exposure event for interactions between infectious people in the E
compartment and susceptibles in S. Note the default is lower than for
inf.prob.i reflecting the reduced infectivity of infected but
asymptomatic people (the E compartment). Otherwise as for inf.exp.i.}
\item{act.rate.e}{The number of exposure events (acts) between
infectious individuals in the E compartment and susceptible individuals
in the S compartment, per day. Otherwise as for act.rate.i.}
\item{inf.prob.i}{Probability of passing on infection at each
exposure event for interactions between infectious people in the I
compartment and susceptibles in S. Reducing inf.prob.i is equivalent to
increasing hygiene measures, such as not putting hands in eyes, nose or
moth, use of hand sanitisers, wearing masks by the infected, and so on.}
\item{act.rate.i}{The number of exposure events (acts) between
infectious individuals in the I compartment and susceptible individuals
in the S compartment, per day. It's stochastic, so the rate is an
average, some individuals may have more or less. Note that not every
exposure event results in infection - that is governed by the inf.prob.i
parameters (see below). Reducing act.rate.i is equivalent to increasing
social distancing by people in the I compartment.}
\item{inf.prob.q}{Probability of passing on infection at each
exposure event for interactions between infectious people in the Q
compartment and susceptibles in S. Note the default is lower than for
inf.prob.i reflecting the greater care that self-isolated individuals
will, on average, take regarding hygiene measures, such as wearing masks,
to limit spread to others. Otherwise as for inf.exp.i.}
\item{act.rate.q}{The number of exposure events (acts) between
infectious individuals in the Q compartment (isolated, self or otherwise)
and susceptible individuals in the S compartment, per day. Note the much
lower rate than for the I and E compartments, reflecting the much
greater degree of social isolation for someone in (self-)isolation. The
exposure event rate is not zero for this group, just much less.
Otherwise as for act.rate.i.}
\item{quar.rate}{Rate per day at which symptomatic (or tested
positive), infected I compartment people enter self-isolation (Q
compartment). Asymptomatic E compartment people can't enter
self-isolation because they don't yet know they are infected. Default is
a low rate reflecting low community awareness or compliance with
self-isolation requirements or practices, but this can be tweaked when
exploring scenarios.}
\item{hosp.rate}{Rate per day at which symptomatic (or tested
positive), infected I compartment people or self-isolated Q compartment
people enter the state of requiring hospital care -- that is, become
serious cases. A default rate of 1% per day with an average illness
duration of about 10 days means a bit less than 10% of cases will
require hospitalisation, which seems about right (but can be tweaked,
of course).}
\item{disch.rate}{Rate per day at which people needing
hospitalisation recover.}
\item{prog.rate}{Rate per day at which people who are infected
but asymptomatic (E compartment) progress to becoming symptomatic (or
test-positive), the I compartment. See prog.rand above for more details.}
\item{prog.dist.scale}{Scale parameter for Weibull distribution
for progression, see prog.rand for details.}
\item{prog.dist.shape}{Shape parameter for Weibull distribution
for progression, see prog.rand for details. Read up on the Weibull
distribution before changing the default.}
\item{rec.rate}{Rate per day at which people who are infected and
symptomatic (I compartment) recover, thus entering the R compartment.
See rec.rand above for more details.}
\item{rec.dist.scale}{Scale parameter for Weibull distribution for
recovery, see rec.rand for details.}
\item{rec.dist.shape}{Shape parameter for Weibull distribution for
recovery, see rec.rand for details. Read up on the Weibull distribution
before changing the default.}
\item{fat.rate.base}{Baseline mortality rate per day for people
needing hospitalisation (deaths due to the virus). See fat.rand for more
details.}
\item{hosp.cap}{Number of available hospital beds for the modelled
population. See fat.rand for more details.}
\item{fat.rate.overcap}{Mortality rate per day for people needing
hospitalisation but who can't get into hospital due to the hospitals
being full (see hosp.cap and fat.rand). The default rate is twice that
for those who do get into hospital.}
\item{fat.tcoeff}{Time co-efficient for increasing mortality rate
as time in the H compartment increases for each individual in it. See
fat.rand for details.}
\item{vital}{Enables demographics, that is, arrivals and
departures, to and from the simulated population.}
\item{a.rate}{Background demographic arrival rate. Currently all
arrivals go into the S compartment, the default is approximately the
daily birth rate for Australia. Will be extended to cover immigration in
future versions.}
\item{ds.rate}{Background demographic departure (death not due to
virus) rates. Defaults based on Australian crude death rates. Can be
used to model emigration as well as deaths.}
\item{de.rate}{Background demographic departure (death not due to
virus) rates. Defaults based on Australian crude death rates. Can be used
to model emigration as well as deaths.}
\item{dq.rate}{Background demographic departure (death not due to
virus) rates. Defaults based on Australian crude death rates. Can be used
to model emigration as well as deaths.}
\item{dh.rate}{Background demographic departure (death not due to
virus) rates. Defaults based on Australian crude death rates. Can be used
to model emigration as well as deaths.}
\item{dr.rate}{Background demographic departure (death not due to
virus) rates. Defaults based on Australian crude death rates. Can be used
to model emigration as well as deaths.}
\item{out}{Summary function for the simulation runs. median is
also available, or percentiles, see the EpiModel documentation.}
}
\value{
param.icm object
}
\description{
Sets the epidemic parameters for stochastic individual contact models
simulated with icm.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sirPlus-package.R
\docType{package}
\name{sirPlus}
\alias{sirPlus}
\title{sirPlus}
\description{
\pkg{sirPlus} is a package for modeling COVID-19 spread, focusing on rates
of hospitalization, which should be useful for hospitals.
}
---
title: "sirPLUS models"
date: "Last updated: 23 March 2020"
output:
BiocStyle::html_document:
toc: true
toc_float: true
vignette: >
%\VignetteIndexEntry{sirPLUS models}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
## Backgrouund on the SEIQHRF (SIR + extra compartments) model
Based on [Tim Churches"'" blog post](https://timchurches.github.io/blog/posts/2020-03-18-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2/).
![COVID-19 transition diagram]('figure/TChurches-transition-diagram.png')
*Note the lower case letters between compartment nodes represent model input
parameters defined in the blog post*
## Sett up environment and pull parameters
```{r setup environment, include=FALSE}
library(tidyverse)
library(dplyr)
library(magrittr)
library(lubridate)
library(stringr)
library(tibble)
library(broom)
library(ggplot2)
#remotes::install_github("rstudio/gt")
library(gt)
library(knitr)
library(devtools)
library(DiagrammeR)
library(parallel)
library(foreach)
library(tictoc)
suppressMessages(library(EpiModel))
library(incidence)
.libPaths('/mnt/mcfiles/rlyu/Software/R/3.6/Rlib')
#devtools::install_github("reconhub/earlyR")
library(earlyR)
tic("Time to complete")
```
```{r data from Tim Churches}
source_files <- c("_icm.mod.init.seiqhrf.R", "_icm.mod.status.seiqhrf.R",
"_icm.mod.vital.seiqhrf.R", "_icm.control.seiqhrf.R", "_icm.utils.seiqhrf.R",
"_icm.saveout.seiqhrf.R", "_icm.icm.seiqhrf.R")
src_path <- paste0("./_posts/2020-03-18-modelling-the-effects-of-public-health-",
"interventions-on-covid-19-transmission-part-2/")
gist_url <- "https://gist.github.com/timchurches/92073d0ea75cfbd387f91f7c6e624bd7"
local_source <- FALSE
for (source_file in source_files) {
if (local_source) {
source(paste(src_path, source_file, sep = ""))
} else {
Sys.sleep(1)
source_gist(gist_url, filename = source_file)
}
}
```
## Define Functions
```{r simulate baselines}
# function to set-up and run the baseline simulations
devtools::load_all(".")
control <- set.control()
param <- set.param()
init <- set.init(s.num = 10000, e.num = 150, q.num = 10, h.num = 0)
init
sim <- icm.seiqhrf(param, init, control)
sim_df <- as.data.frame(sim, out=out)
simulate <- list(sim=sim, df=sim_df)
```
## Generate and inspect baseline simulations
started at 3:12 pm
```{r baseline sims}
baseline_sim <- simulate(ncores = 4)
times <- get_times(baseline_sim)
times %>% filter(duration <= 30) %>% ggplot(aes(x = duration)) +
geom_bar() + facet_grid(period_type ~ ., scales = "free_y") +
labs(title = "Duration frequency distributions", subtitle = "Baseline simulation")
```
```{r viz prevalence}
baseline_plot_df <- baseline_sim$df %>% # use only the prevalence columns
select(time, s.num, e.num, i.num, q.num, h.num, r.num, f.num) %>%
# examine only the first 100 days since it is all over by
# then using the default parameters
filter(time <= 100) %>% pivot_longer(-c(time), names_to = "compartment",
values_to = "count")
# define a standard set of colours to represent compartments
compcols <- c(s.num = "yellow", e.num = "orange", i.num = "red",
q.num = "cyan", h.num = "magenta", r.num = "lightgreen",
f.num = "black")
complabels <- c(s.num = "Susceptible", e.num = "Infected/asymptomatic",
i.num = "Infected/infectious", q.num = "Self-isolated", h.num = "Requires hospitalisation",
r.num = "Recovered", f.num = "Case fatality")
baseline_plot_df %>% ggplot(aes(x = time, y = count, colour = compartment)) +
geom_line(size = 2, alpha = 0.7) + scale_colour_manual(values = compcols,
labels = complabels) + theme_dark() + labs(title = "Baseline simulation",
x = "Days since beginning of epidemic", y = "Prevalence (persons)")
```
## Experiment 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment