Title: | Functions and Data for "Epidemics: Models and Data in R" |
---|---|
Description: | Functions, data sets and shiny apps for "Epidemics: Models and Data in R" by Ottar N. Bjornstad (ISBN 978-3-319-97487-3) <https://www.springer.com/gp/book/9783319974866>. The package contains functions to study the S(E)IR model, spatial and age-structured SIR models; time-series SIR and chain-binomial stochastic models; catalytic disease models; coupled map lattice models of spatial transmission and network models for social spread of infection. The package is also an advanced quantitative companion to the coursera Epidemics Massive Online Open Course <https://www.coursera.org/learn/epidemics>. |
Authors: | Ottar N. Bjornstad [aut, cre] |
Maintainer: | Ottar N. Bjornstad <[email protected]> |
License: | GPL-3 |
Version: | 0.6-5 |
Built: | 2025-02-15 05:12:16 UTC |
Source: | https://github.com/cran/epimdr |
Function to generate a Barabasi-Albert network
BarabasiAlbert(N, K)
BarabasiAlbert(N, K)
N |
the number of nodes |
K |
the number of neighbors to which each node is connected so degree = 2*K |
An object of class CM (contact matrix)
cm3=BarabasiAlbert(200, 4)
cm3=BarabasiAlbert(200, 4)
Seroprevalence-by-age-bracket for measles in prevaccination New Haven as studied by Black (1959).
black
black
A data frame with 42 rows and 3 variables:
age-bracket (in years)
mid-point of age-bracket (in years)
number of tests
number seropositive
number seronegative
seroprevalence
Black (1959) Measles antibodies in the population of New Haven, Connecticut. Journal of Immunology 83:74-83
Data is of 22 generations of greenhouse white flies (Trialeurodes vaporariorum) and its parasitoid, Encarsia formosa. Column names are self explanatory.
burnett
burnett
A data frame with 22 rows and 7 variables:
Burnett, T. A. (1958) Model of host-parasite interaction Proceedings of the 10th International Congress, Entomology, 1958, 2, 679-686
The fraction of weeks measles was absent from each of the 954 cities and towns of England and Wales between 1944 and 1965.
ccs
ccs
A data frame with 954 rows and 14 variables:
Average duration of fadeout (of at least 3 weeks of length)
Fraction of time when measles was absent
Median population size
Average duration of fadeouts (of a week or longer)
Standard error fade3
Standard error of fade
The number of fadeouts (of at least 3 weeks of length)
The number of fadeout of a week or longer
City/town name
Bjornstad and Grenfell (2008) Hazards, spatial transmission and timing of outbreaks in epidemic metapopulations. Environmental and Ecological Statistics 15: 265-277. doi:10.1007/s10651-007-0059-3.
Gradient-function for the chain-SIR model
chainSIR(t, logx, params)
chainSIR(t, logx, params)
t |
Implicit argument for time |
logx |
A vector with values for the log-states |
params |
A vector with parameter values for the chain-SIR system |
A list of gradients
require(deSolve) times = seq(0, 10, by=1/52) paras2 = c(mu = 1/75, N = 1, beta = 625, gamma = 365/14, u=5) xstart2 = log(c(S=.06, I=c(0.001, rep(0.0001, paras2["u"]-1)), R = 0.0001)) out = as.data.frame(ode(xstart2, times, chainSIR, paras2))
require(deSolve) times = seq(0, 10, by=1/52) paras2 = c(mu = 1/75, N = 1, beta = 625, gamma = 365/14, u=5) xstart2 = log(c(S=.06, I=c(0.001, rep(0.0001, paras2["u"]-1)), R = 0.0001)) out = as.data.frame(ode(xstart2, times, chainSIR, paras2))
Monthly deaths from cholera in Dacca, East Bengal between 1891 and 1940.
cholera
cholera
A data frame with 600 rows and 4 variables:
Year
Month of the year
Monthly cholera deaths
Population size of district
King, A.A., Ionides, E.L., Pascual, M. and Bouma, M. J. (2008) Inapparent infections and cholera dynamics. Nature, 454:877-880. doi.org/10.1038/nature07084.
Gradient-function for Coyne et al's rabies model
coyne(t, logx, parms)
coyne(t, logx, parms)
t |
Implicit argument for time |
logx |
A vector with values for the log-states |
parms |
A vector with parameter values for the dynamical system |
A list of gradients for the log system
require(deSolve) times = seq(0, 50, by=1/520) paras = c(gamma = 0.0397, b = 0.836, a = 1.34, sigma = 7.5, alpha = 66.36, beta = 33.25, c = 0, rho = 0.8) start = log(c(X=12.69/2, H1=0.1, H2=0.1, Y = 0.1, I = 0.1)) out = as.data.frame(ode(start, times, coyne, paras))
require(deSolve) times = seq(0, 50, by=1/520) paras = c(gamma = 0.0397, b = 0.836, a = 1.34, sigma = 7.5, alpha = 66.36, beta = 33.25, c = 0, rho = 0.8) start = log(c(X=12.69/2, H1=0.1, H2=0.1, Y = 0.1, I = 0.1)) out = as.data.frame(ode(start, times, coyne, paras))
A dataset of Measles incidence across 40 US cities with relevant demographic data
dalziel
dalziel
A data frame with 44,720 rows and 10 variables:
biweek of the year
incidence
year
city name
population size
susceptible recruits
country
city longitude
city latitude
time counter
Dalziel et al. 2016. Persistent chaos of measles epidemics in the prevaccination United States caused by a small change in seasonal transmission patterns. PLoS Computational Biology 2016: e1004655. doi.org/10.1371/journal.pcbi.1004655.
The daily number of cases of ebola in Sierra Leone during the 2015 epidemic.
ebola
ebola
A data frame with 103 rows and 4 variables:
date
day
cumulative incidence
incidence calculated by differencing the cumcases and setting negatives to zero.
http://www.cdc.gov/vhf/ebola/outbreaks/2014-west-africa/cumulative-cases-graphs.html
The incidence aggregated by serial interval of a number of outbreaks studied by Ferrari et al. 2005.
ferrari
ferrari
A data frame with 15 rows and 7 variables:
Number of deaths from ebola during the 2000 Uganda outbreak
Number of cases of ebola during the 2000 Uganda outbreak
Number of cases of ebola during the 1995 DRC outbreak
Number of farms infected with FMD during the 2000-01 UK outbreak
Number of cases of swine fever in pigs in the 1997-98 outbreak in the Netherlands
Number of cases of SARS in Hong Kong during the 2003 outbreak
Number of cases of SARS in Singapore during the 2003 outbreak
Ferrari et al. (2005) Estimation and inference of R-0 of an infectious pathogen by a removal method. Mathematical Biosciences 198: 14-26. doi.org/10.1016/j.mbs.2005.08.002.
Rust infection status of 162 populations of Filipendula ulmaria in a Swedish Island archipelago
filipendula
filipendula
A data frame with 162 rows and 4 variables:
infection status in 1994
infection status in 1995
X coordinate
Y coordinate
Smith et al. 2003. Epidemiological patterns at multiple spatial scales: an 11-year study of a Triphragmium ulmariae – Filipendula ulmaria metapopulation. Journal of Ecology, 91(5), pp.890-903. doi.org/10.1046/j.1365-2745.2003.00811.x.
Immunological measures on cats infected with different strains of FIV
fiv
fiv
A data frame with 238 rows and 18 variables:
Individual identifier
CD4 cell count
CD8B cell count
CD25 cell count
FAS ligand
FAS
Interferon gamma
Interleukin 10
Interleukin 12
Interleukin 4
lymphocyte count
neutrophil count
Tumor necrosis factor
provirus count
viremia
day
unique identifier
Experimental treatment
Roy et al. 2009. Multivariate statistical analyses demonstrate unique host immune responses to single and dual lentiviral infection. PloS one 4, e7359. doi.org/10.1371/journal.pone.0007359.
Plots the flow or velocity field for a one- or two-dimensional autonomous ODE system.
flowField(deriv, xlim, ylim, parameters = NULL, system = "two.dim", points = 21, col = "gray", arrow.type = "equal", arrow.head = 0.05, frac = 1, add = TRUE, xlab = if (system == "two.dim") state.names[1] else "t", ylab = if (system == "two.dim") state.names[2] else state.names[1], ...)
flowField(deriv, xlim, ylim, parameters = NULL, system = "two.dim", points = 21, col = "gray", arrow.type = "equal", arrow.head = 0.05, frac = 1, add = TRUE, xlab = if (system == "two.dim") state.names[1] else "t", ylab = if (system == "two.dim") state.names[2] else state.names[1], ...)
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required format of these functions
can be found in the package vignette, or in the help file for the
function |
xlim |
In the case of a two-dimensional system, this sets the limits of
the first dependent variable in which gradient reflecting line segments
should be plotted. In the case of a one-dimensional system, this sets the
limits of the independent variable in which these line segments should be
plotted. Should be a |
ylim |
In the case of a two-dimensional system this sets the limits of
the second dependent variable in which gradient reflecting line segments
should be plotted. In the case of a one-dimensional system, this sets the
limits of the dependent variable in which these line segments should be
plotted. Should be a |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
points |
Sets the density of the line segments to be plotted;
|
col |
Sets the colour of the plotted line segments. Should be a
|
arrow.type |
Sets the type of line segments plotted. If set to
|
arrow.head |
Sets the length of the arrow heads. Passed to
|
frac |
Sets the fraction of the theoretical maximum length line
segments can take without overlapping, that they can actually attain. In
practice, |
add |
Logical. If |
xlab |
Label for the x-axis of the resulting plot. |
ylab |
Label for the y-axis of the resulting plot. |
... |
Returns a list
with the following components (the
exact make up is dependent on the value of system
):
add |
As per input. |
arrow.head |
As per input. |
arrow.type |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
dx |
A |
dy |
A |
frac |
As per input. |
parameters |
As per input. |
points |
As per input. |
system |
As per input. |
x |
A |
xlab |
As per input. |
xlim |
As per input. |
y |
A |
ylab |
As per input. |
ylim |
As per input. |
Michael J Grayling
#See archived phaseR package for examples
#See archived phaseR package for examples
The daily number of children confined to bed in a boarding school in North England during an outbreak in 1978 of the reemerging A/H1N1 strain. The school had 763 boys of which 512 boys were confined to bed sometime during the outbreak.
flu
flu
A data frame with 14 rows and 2 variables:
day since beginning of outbreak
number of sick children
Anonymous (1978) EPIDEMIOLOGY: Influenza in a boarding school. British Medical Journal, 4 March 1978 p.587.
Function simulating a dynamical system using the Gillespie exact algorithm
gillespie(rateqs, eventmatrix, parameters, initialvals, numevents)
gillespie(rateqs, eventmatrix, parameters, initialvals, numevents)
rateqs |
a list with rate equations |
eventmatrix |
a matrix of changes in state variables associated with each event |
parameters |
a vector of parameter values |
initialvals |
a vector of initial values for the states |
numevents |
number of events to be simulated |
A data frame with simulated time series
rlist=c(quote(mu * (S+I+R)), quote(mu * S), quote(beta * S * I /(S+I+R)), quote(mu * I), quote(gamma * I), quote(mu*R)) emat=matrix(c(1,0,0,-1,0,0,-1,1,0,0,-1,0,0,-1,1,0,0,-1),ncol=3, byrow=TRUE) paras = c(mu = 1, beta = 1000, gamma = 365/20) inits = c(S=100, I=2, R=0) sim=gillespie(rlist, emat, paras, inits, 100)
rlist=c(quote(mu * (S+I+R)), quote(mu * S), quote(beta * S * I /(S+I+R)), quote(mu * I), quote(gamma * I), quote(mu*R)) emat=matrix(c(1,0,0,-1,0,0,-1,1,0,0,-1,0,0,-1,1,0,0,-1),ncol=3, byrow=TRUE) paras = c(mu = 1, beta = 1000, gamma = 365/20) inits = c(S=100, I=2, R=0) sim=gillespie(rlist, emat, paras, inits, 100)
A dataset containing the fraction of forest defoliated by the gypsy moth in 20km x 20km pixels across northeast US in each year between 1975 and 2002.
gm
gm
A data frame with 1086 rows and 30 variables:
UTM x-coordinates
UTM y-coordinates
Defolitation in 1975
Defolitation in 1976
Defolitation in 1977
Defolitation in 1978
Defolitation in 1979
Defolitation in 1980
Defolitation in 1981
Defolitation in 1982
Defolitation in 1983
Defolitation in 1984
Defolitation in 1985
Defolitation in 1986
Defolitation in 1987
Defolitation in 1988
Defolitation in 1989
Defolitation in 1990
Defolitation in 1991
Defolitation in 1992
Defolitation in 1993
Defolitation in 1994
Defolitation in 1995
Defolitation in 1996
Defolitation in 1997
Defolitation in 1998
Defolitation in 1999
Defolitation in 2000
Defolitation in 2001
Defolitation in 2002
Bjornstad, O. N., Robinet, C., & Liebhold, A. M. (2010). Geographic variation in North American gypsy moth cycles: subharmonics, generalist predators, and spatial coupling. Ecology, 91(1), 106-118. doi.org/10.1890/08-1246.1.
The directed contact network from De et al. (2004) contact-tracing of the spread of gonorrhea across asexual network in Alberta canada
gonnet
gonnet
A matrix with 89 rows and 89 columns:
a matrix of directional contacts of disease spread
De et al (2004). Sexual network analysis of a gonorrhea outbreak. Sexually transmitted infections 80: 280-285. doi.org/10.1136/sti.2003.007187.
Data on a fungal pathogen of the aster Euthamia graminifolia collected by Jennifer Keslow.
gra
gra
A data frame with 360 rows and 8 variables:
the block
row
plot within block
x coordinates
y coordinate
plot composition
treatment: dry or wet
the rust score
A dataset containing the monthly ILI incidence in Iceland between 1980 and 2009.
Icelandflu
Icelandflu
A data frame with 360 rows and 3 variables:
the month
the year
ILI incidence
Bjornstad ON, Viboud C. Timing and periodicity of influenza epidemics. Proceedings of the National Academy of Sciences. 2016 Nov 15;113(46):12899-901. doi.org/10.1073/pnas.1616052113.
Auxillary function used by llik.pc
integrandpc(a, up, foi)
integrandpc(a, up, foi)
a |
a vector with the ages |
up |
a vector with upper age-bracket cut-offs |
foi |
a vector with FoI |
A vector with FoIs matched to data
llik.pc
Data on Bordetella bronchiseptica in rabbit kittens in a breeding facility.
litter
litter
A data frame with 494 rows and 8 variables:
breeding facility
infection status
date sampled
animal identifier
dams infection status
litter identifier
bacterial count
unique litter identifier
Long et al (2010) Identifying the Age Cohort Responsible for Transmission in a Natural Outbreak of Bordetella bronchiseptica. PLoS Pathogens 6(12): e1001224. doi:10.1371/journal.ppat.1001224.
Negative log-likelihood function for the chain-binomial model
llik.cb(S0, beta, I)
llik.cb(S0, beta, I)
S0 |
a scalar with value for S0 |
beta |
a scalar with value for beta |
I |
a vector incidence aggregated at serial interval |
the negative log-likelhood for the model
twoweek=rep(1:15, each=2) niamey_cases1=sapply(split(niamey$cases_1[1:30], twoweek), sum) llik.cb(S0=6500, beta=23, I=niamey_cases1)
twoweek=rep(1:15, each=2) niamey_cases1=sapply(split(niamey$cases_1[1:30], twoweek), sum) llik.cb(S0=6500, beta=23, I=niamey_cases1)
This function uses binomial likelihoods to estimate the picewise-constant FoI model from age-incidence data
llik.pc(par, age, num, denom, up)
llik.pc(par, age, num, denom, up)
par |
a vector with initial guesses |
age |
a vector with the ages |
num |
a vector with number infected by age |
denom |
a vector with number tested by age |
up |
a vector with upper age-bracket cut-offs |
The negative log-likelihood for a candidate piecewise constant catalytic model
x=c(1,4,8,12,18,24) para=rep(.1,length(x)) ## Not run: optim(par=log(para),fn=loglikpc, age=rabbit$a, num=rabbit$inf, denom=rabbit$n, up=x)
x=c(1,4,8,12,18,24) para=rep(.1,length(x)) ## Not run: optim(par=log(para),fn=loglikpc, age=rabbit$a, num=rabbit$inf, denom=rabbit$n, up=x)
Weekly cases of gonorrhea in Massachusetts between 2006 and 2015.
magono
magono
A data frame with 422 rows and 4 variables:
Weekly case reports
Year
Week of the year
Time in fractions of year
Launch a shiny-app simulating May's Parasitoid-host Model model
May.app
May.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: May.app
## Not run: May.app
A dataset containing the biweekly incidence of measles in London from 1944 to 1965
meas
meas
A data frame with 546 rows and 5 variables:
year
week of the year
time
incidence
Biweekly births
Birth numbers are annual, so in the data set, this number is evenly distributed across the 26 bi-weeks of each year.
Bjornstad et al. (2002) Endemic and epidemic dynamics of measles: Estimating transmission rates and their scaling using a time series SIR model. Ecological Monographs 72: 169-184. doi.org/10.2307/3100023.
Age-specific contact rates from the diary study by Mossong et al. 2008.
mossong
mossong
A data frame with 900 rows and 3 variables:
end of age-bracket (in years) of contactor group
end of age-bracket (in years) of contactee group
average contact rate
Mossong et al. 2008 Social contacts and mixing patterns relevant to the spread of infectious diseases PLoS Med, Public Library of Science 5:e74. doi.org/10.1371/journal.pmed.0050074.
Function to simulate the Nicholson-Bailey Parasitoid-host model
NB(R, a, T = 100, H0 = 10, P0 = 1)
NB(R, a, T = 100, H0 = 10, P0 = 1)
R |
the host reproductive rate |
a |
the parasitoid search efficiency |
T |
the length of simulation (number of time-steps) |
H0 |
initial host numbers |
P0 |
initial parasitoid numbers |
A list of simulated Host and Parasitoid numbers
sim= NB(R=1.1,a=0.1)
sim= NB(R=1.1,a=0.1)
Function to simulate a stochastic (discrete time) Reed-Frost SIR model on a social network
NetworkSIR(CM, tau, gamma)
NetworkSIR(CM, tau, gamma)
CM |
a contact matrix |
tau |
the transmission probability |
gamma |
the recovery probability |
An object of class netSIR with infectious status for each node through time
cm1=BarabasiAlbert(N=200,K=2) sim1=NetworkSIR(cm1,.3,0.1) summary(sim1) ## Not run: plot(sim1)
cm1=BarabasiAlbert(N=200,K=2) sim1=NetworkSIR(cm1,.3,0.1) summary(sim1) ## Not run: plot(sim1)
A dataset containing the weekly incidence of measles in Niamey, Niger during the 2003-04 outbreak
niamey
niamey
A data frame with 31 rows and 13 variables:
week since beginning of outbreak
week of the year
weekly incidence for the whole city
weekly deaths for the whole city
weekly case fatality rate
weekly attack rates for the whole city
weekly incidence for district 1
weekly attack rates for district 1
weekly incidence for district 2
weekly attack rates for district 2
weekly incidence for district 3
weekly attack rates for district 3
weekly cumulative incidence for the whole city
Grais et al (2008) Time is of the essence: exploring a measles outbreak response vaccination in Niamey, Niger. Journal of the Royal Society Interface 5: 67-74. https://doi.org/10.1098/rsif.2007.1038.
A dataset containing the day of appearance of each measles case in Niamey, Niger during the 2003-04 outbreak.
niamey_daily
niamey_daily
A data frame with 10,937 rows and 1 variables:
the day of appearance of each case since day of outbreak
Grais et al. (2008) Time is of the essence: exploring a measles outbreak response vaccination in Niamey, Niger. Journal of the Royal Society Interface 5: 67-74. doi.org/10.1098/rsif.2007.1038.
Launch a shiny-app to study outbreak-response vaccination campaigns
orv.app
orv.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: orv.app
## Not run: orv.app
A dataset containing the weekly incidence of giardia in Pennsylvania between 2006 and 2014.
pagiard
pagiard
A data frame with 448 rows and 3 variables:
weekly incidence
the year
the week
A dataset containing the weekly ILI related deaths in Pennsylvania between 1972 and 1998.
paili
paili
A data frame with 1404 rows and 3 variables:
weekly deaths
the year
the week
A dataset containing the weekly incidence of Lymes disease in Pennsylvania between 2006 and 2014.
palymes
palymes
A data frame with 448 rows and 3 variables:
weekly incidence
the year
the week
A dataset containing the weekly incidence of measles in Pennsylvania between 2006 and 2014.
pameasle
pameasle
A data frame with 448 rows and 3 variables:
weekly incidence
the year
the week
A dataset containing the weekly incidence of whooping cough from Copenhagen, Denmark between January 1900 and December 1937
pertcop
pertcop
A data frame with 1982 rows and 9 variables:
date
births
day of month
month of year
year
weekly incidence
weekly deaths
weekly population size interpolated from census data
Lavine et al. 2013. Immune boosting explains regime- shifts in prevaccine-era pertussis dynamics. PLoS One, 8(8):e72086. doi:10.1371/journal.pone.0072086.
Rubella incidence by age as studied by Metcalf et al (2011).
peru
peru
A data frame with 95 rows and 2 variables:
end of age-bracket (in years)
cumulative number of rubella cases
number of rubella cases
total cases
Metcalf et al (2011) Rubella metapopulation dynamics and importance of spatial coupling to the risk of congenital rubella syndrome in Peru. Journal of the Royal Society Interface 8: 369-376. doi:10.1371/journal.pone.0072086.
Function to plot an object of class CM
## S3 method for class 'cm' plot(x, ...)
## S3 method for class 'cm' plot(x, ...)
x |
an object of class cm |
... |
other arguments |
A plot of the contract matrix
cm=ringlattice(N=20,K=4) ## Not run: plot(cm)
cm=ringlattice(N=20,K=4) ## Not run: plot(cm)
Function to plot a netSIR object
## S3 method for class 'netSIR' plot(x, ...)
## S3 method for class 'netSIR' plot(x, ...)
x |
an object of class netSIR |
... |
other arguments |
Function to calculate R0 from a contact matrix
r0fun(CM, tau, gamma)
r0fun(CM, tau, gamma)
CM |
an object of class CM |
tau |
= probability of infection across an edge |
gamma |
= probability of removal per time step |
the R0
cm1=BarabasiAlbert(N=200,K=2) r0fun(cm1, 0.3, 0.1)
cm1=BarabasiAlbert(N=200,K=2) r0fun(cm1, 0.3, 0.1)
Rabbits infected by B. brochiseptica by age as studied by Long et al (2010).
rabbit
rabbit
A data frame with 42 rows and 3 variables:
end of age-bracket (in months)
number of rabbits tested
number of rabbits infected with the bacterium
Long et al (2010) Identifying the Age Cohort Responsible for Transmission in a Natural Outbreak of Bordetella bronchiseptica. PLoS Pathogens 6(12): e1001224. doi:10.1371/journal.ppat.1001224.
Data is the average monthly number of reported cases of rabid raccoons across all counties within each of 11 east coast US states the time line is from the first reported case in each state (starting in late 1970s for West Virginia).
rabies
rabies
A data frame with 208 rows and 12 variables:
Month since rabies appearance in the state
Connecticut
Delaware
Maryland
Massachusetts
New Jersey
New York
North Carolina
Pennsylvania
Rhode Island
Virginia
West Virginia
Childs et al. 2000. Predicting the local dynamics of epizootic rabies among raccoons in the United States Proceedings of the National Academy of Sciences 97:13666-13671. doi.org/10.1073/pnas.240326697.
Function to predict efficacy of outbreak-response vaccination campaign
retrospec(R, day, vaccine_efficacy, target_vaccination, intervention_length, mtime, LP = 7, IP = 7, N = 10000)
retrospec(R, day, vaccine_efficacy, target_vaccination, intervention_length, mtime, LP = 7, IP = 7, N = 10000)
R |
reproductive ratio |
day |
first day of ORV campaign |
vaccine_efficacy |
Vaccine efficacy |
target_vaccination |
fraction of population vaccinated during ORV campaign |
intervention_length |
duration of ORV campaign |
mtime |
length of simulation |
LP |
length of latent period |
IP |
length of infectious period |
N |
initial susceptible population size |
A list of gradients
red1=retrospec(R=1.8, 161, vaccine_efficacy=0.85, target_vaccination=0.5, intervention_length=10, mtime=250, LP=8, IP=5, N=16000) 1-red1$redn
red1=retrospec(R=1.8, 161, vaccine_efficacy=0.85, target_vaccination=0.5, intervention_length=10, mtime=250, LP=8, IP=5, N=16000) 1-red1$redn
Function to generate a ring lattice
ringlattice(N, K)
ringlattice(N, K)
N |
the number of nodes |
K |
the number of neighbors to which each node is connected so degree = 2xK |
An object of class CM (contact matrix)
cm=ringlattice(N=20,K=4)
cm=ringlattice(N=20,K=4)
Launch a shiny-app simulating the seasonal SEIR model
SEIR.app
SEIR.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: SEIR.app
## Not run: SEIR.app
Gradient-function for the SEIR model
seirmod(t, y, parms)
seirmod(t, y, parms)
t |
Implicit argument for time |
y |
A vector with values for the states |
parms |
A vector with parameter values for the SEIR system |
A list of gradients
require(deSolve) times = seq(0, 10, by=1/120) paras = c(mu = 1/50, N = 1, beta = 1000, sigma = 365/8, gamma = 365/5) start = c(S=0.06, E=0, I=0.001, R = 0.939) out=ode(y=start, times=times, func=seirmod, parms=paras)
require(deSolve) times = seq(0, 10, by=1/120) paras = c(mu = 1/50, N = 1, beta = 1000, sigma = 365/8, gamma = 365/5) start = c(S=0.06, E=0, I=0.001, R = 0.939) out=ode(y=start, times=times, func=seirmod, parms=paras)
Gradient-function for the forced SEIR model
seirmod2(t, y, parms)
seirmod2(t, y, parms)
t |
Implicit argument for time |
y |
A vector with values for the states |
parms |
A vector with parameter values for the SIR system |
A list of gradients
require(deSolve) times = seq(0, 10, by=1/120) paras = c(mu = 1/50, N = 1, beta0 = 1000, beta1 = 0.2, sigma = 365/8, gamma = 365/5) start = c(S=0.06, E=0, I=0.001, R = 0.939) out=ode(y=start, times=times, func=seirmod2, parms=paras)
require(deSolve) times = seq(0, 10, by=1/120) paras = c(mu = 1/50, N = 1, beta0 = 1000, beta1 = 0.2, sigma = 365/8, gamma = 365/5) start = c(S=0.06, E=0, I=0.001, R = 0.939) out=ode(y=start, times=times, func=seirmod2, parms=paras)
Launch a shiny-app simulating the SEIRS model
SEIRS.app
SEIRS.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: SEIRS.app
## Not run: SEIRS.app
Daily data on laboratory mice infected with various strains of Plasmodium chaudaudi
SH9
SH9
A data frame with 1300 rows and 11 variables:
line number
day of infection
Cage number
Mouse identifier
Plasmodium strain
Unique mouse identifier
Mouse weight
Blood glucose level
Red blood cell count
Sample number
Parasite count
Sylvie Huijben
Data on a fungal pathogen of the wild campion collected by Janis Antonovics
silene2
silene2
A data frame with 876 rows and 5 variables:
road segment number
latitude
longitude
number of healthy plants
number of diseased plants
Antonovics, J. 2004. Long-term study of a plant-pathogen metapopulation. In: Hanski, Ilkka, and Oscar E. Gaggiotti. Ecology, genetics, and evolution of metapopulations. Academic Press. doi.org/10.1371/journal.pone.0007359.
Function to simulate the chain-binomial model
sim.cb(S0, beta)
sim.cb(S0, beta)
S0 |
a scalar with value for S0 |
beta |
a scalar with value for beta |
A data-frame with time series of susceptibles and infecteds
sim=sim.cb(S0=6500, beta=23)
sim=sim.cb(S0=6500, beta=23)
Function to simulate the stochastic TSIR assuming stochasticity in transmission and a Poisson birth-death process
SimTsir(alpha = 0.97, B = 2300, beta = 25, sdbeta = 0, S0 = 0.06, I0 = 180, IT = 520, N = 3300000)
SimTsir(alpha = 0.97, B = 2300, beta = 25, sdbeta = 0, S0 = 0.06, I0 = 180, IT = 520, N = 3300000)
alpha |
the exponent on I |
B |
the birth rate |
beta |
the transmission rate |
sdbeta |
the standard deviation on beta |
S0 |
the initial susceptible fraction |
I0 |
the initial number of infecteds |
IT |
the length of simulation |
N |
the population size |
A list with time series of simulated infected and susceptible hosts
out = SimTsir()
out = SimTsir()
Function to simulate the stochastic TSIR assuming stochasticity in transmission and a Poisson birth-death process
SimTsir2(beta, alpha, B, N, inits = list(Snull = 0, Inull = 0), type = "det")
SimTsir2(beta, alpha, B, N, inits = list(Snull = 0, Inull = 0), type = "det")
beta |
the seasonal transmission coefficients |
alpha |
the exponent on I |
B |
a vector of Births (the length of which determines the length of the simulation) |
N |
the population size |
inits |
a list containing initial S and I |
type |
an argument "det" or "stoc" that determines whether a deterministic or stochastic simulation is done |
A list with time series of simulated infected and susceptible hosts
## Not run: see chapter 8 in book
## Not run: see chapter 8 in book
Launch a shiny-app simulating the SIR model
SIR.app
SIR.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: SIR.app
## Not run: SIR.app
Gradient-function for the age-structured SIR model with possibly heterogeneous mixing
siragemod(t, logx, parms)
siragemod(t, logx, parms)
t |
Implicit argument for time |
logx |
A vector with log-values for the log-states |
parms |
A vector with parameter values for the age-structured SIR system |
A list of gradients
a=rep(1,4) n=length(a) betaM=matrix(1, ncol=4, nrow=4) pars =list(N=1, gamma=365/14, mu=0.02, sigma=0.2, beta=500, betaM=betaM,p=rep(0,4), a=a) xstart<-log(c(S=rep(0.099/n,n), I=rep(0.001/n,n), R=rep(0.9/n,n))) times=seq(0,10,by=14/365) out=as.data.frame(ode(xstart, times=times, func=siragemod, parms=pars))
a=rep(1,4) n=length(a) betaM=matrix(1, ncol=4, nrow=4) pars =list(N=1, gamma=365/14, mu=0.02, sigma=0.2, beta=500, betaM=betaM,p=rep(0,4), a=a) xstart<-log(c(S=rep(0.099/n,n), I=rep(0.001/n,n), R=rep(0.9/n,n))) times=seq(0,10,by=14/365) out=as.data.frame(ode(xstart, times=times, func=siragemod, parms=pars))
Gradient-function for the SIR model
sirmod(t, y, parms)
sirmod(t, y, parms)
t |
Implicit argument for time |
y |
A vector with values for the states |
parms |
A vector with parameter values for the SIR system |
A list of gradients
require(deSolve) times = seq(0, 26, by=1/10) paras = c(mu = 0, N = 1, beta = 2, gamma = 1/2) start = c(S=0.999, I=0.001, R = 0) out=ode(y=start, times=times, func=sirmod, parms=paras)
require(deSolve) times = seq(0, 26, by=1/10) paras = c(mu = 0, N = 1, beta = 2, gamma = 1/2) start = c(S=0.999, I=0.001, R = 0) out=ode(y=start, times=times, func=sirmod, parms=paras)
Gradient-function for the SIRWS model
sirwmod(t, logy, parms)
sirwmod(t, logy, parms)
t |
Implicit argument for time |
logy |
A vector with values for the log(states) |
parms |
A vector with parameter values for the SIRWS system |
A list of gradients (in log-coordinates)
require(deSolve) times = seq(0, 26, by=1/10) paras = c(mu = 1/70, p=0.2, N = 1, beta = 200, omega = 1/10, gamma = 17, kappa=30) start = log(c(S=0.06, I=0.01, R=0.92, W = 0.01)) out = as.data.frame(ode(start, times, sirwmod, paras))
require(deSolve) times = seq(0, 26, by=1/10) paras = c(mu = 1/70, p=0.2, N = 1, beta = 200, omega = 1/10, gamma = 17, kappa=30) start = log(c(S=0.06, I=0.01, R=0.92, W = 0.01)) out = as.data.frame(ode(start, times, sirwmod, paras))
Gradient-function for the SIR model with outbreak-response vaccination
sivmod(t, x, parms)
sivmod(t, x, parms)
t |
Implicit argument for time |
x |
A vector with values for the states |
parms |
A vector with parameter values for the SIR system |
A list of gradients
Function to calculate the degree distribution for an object of class CM
## S3 method for class 'cm' summary(object, plot = FALSE, ...)
## S3 method for class 'cm' summary(object, plot = FALSE, ...)
object |
an object of class cm |
plot |
if TRUE a bar plot of the degree distribution is produced |
... |
other arguments |
A plot of the contract matrix
cm=WattsStrogatz(N=20, K=4, Prw=.3) summary(cm)
cm=WattsStrogatz(N=20, K=4, Prw=.3) summary(cm)
Function to summarize a netSIR object
## S3 method for class 'netSIR' summary(object, ...)
## S3 method for class 'netSIR' summary(object, ...)
object |
an object of class netSIR |
... |
other arguments |
A data-frame with the time series of susceptible, infected and recovered individuals
Function simulating a dynamical system using the Gillespie tau-leap approximation
tau(rateqs, eventmatrix, parameters, initialvals, deltaT, endT)
tau(rateqs, eventmatrix, parameters, initialvals, deltaT, endT)
rateqs |
a list with rate equations |
eventmatrix |
a matrix of changes in state variables associated with each event |
parameters |
a vector of parameter values |
initialvals |
a vector of initial values for the states |
deltaT |
the tau-leap time interval |
endT |
the time length of simulation |
A data frame with simulated time series
rlist2=c(quote(mu * (S+E+I+R)), quote(mu * S), quote(beta * S * I/(S+E+I+R)), quote(mu*E), quote(sigma * E), quote(mu * I), quote(gamma * I), quote(mu*R)) emat2=matrix(c(1,0,0,0,-1,0,0,0,-1,1,0,0,0,-1,0,0,0,-1,1,0,0,0,-1,0,0,0,-1,1,0,0,0,-1), ncol=4, byrow=TRUE) paras = c(mu = 1, beta = 1000, sigma = 365/8, gamma = 365/5) inits = c(S=999, E=0, I=1, R = 0) sim2=tau(rlist2, emat2, paras, inits, 1/365, 1)
rlist2=c(quote(mu * (S+E+I+R)), quote(mu * S), quote(beta * S * I/(S+E+I+R)), quote(mu*E), quote(sigma * E), quote(mu * I), quote(gamma * I), quote(mu*R)) emat2=matrix(c(1,0,0,0,-1,0,0,0,-1,1,0,0,0,-1,0,0,0,-1,1,0,0,0,-1,0,0,0,-1,1,0,0,0,-1), ncol=4, byrow=TRUE) paras = c(mu = 1, beta = 1000, sigma = 365/8, gamma = 365/5) inits = c(S=999, E=0, I=1, R = 0) sim2=tau(rlist2, emat2, paras, inits, 1/365, 1)
Launch a shiny-app simulating TSIR model
TSIR.app
TSIR.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: TSIR.app
## Not run: TSIR.app
Function to calculate the local Lyapunov exponents from an object of class lyap
.
TSIRllyap(x, m = 1)
TSIRllyap(x, m = 1)
x |
an object of class |
m |
number of forward iterations on the attractor |
An object of class llyap with the local Lyapunov exponent and S-I data
## Not run: see chapter 10 in book
## Not run: see chapter 10 in book
Function to do Lyapunov exponent calculations from a TSIR simulation
TSIRlyap(I, S, alpha, bt, N)
TSIRlyap(I, S, alpha, bt, N)
I |
a vector containing the time series of Is |
S |
vector containing the time series of Ss |
alpha |
the exponent on I |
bt |
the seasonal transmission coefficients |
N |
the population size |
An object of class lyap with the lyapunov exponent, values for the Jacobians, parameters and data
## Not run: see chapter 10 in book
## Not run: see chapter 10 in book
A dataset containing the weekly incidence incidence of diphtheria in Philadelphia between 1914 and 1947.
tydiphtheria
tydiphtheria
A data frame with 1774 rows and 4 variables:
the year
the week
weekly diphtheria incidence
the time counter
A dataset containing the weekly incidence incidence of measles in Philadelphia between 1914 and 1947.
tymeasles
tymeasles
A data frame with 1774 rows and 4 variables:
the year
the week
weekly measles incidence
the time counter
A dataset containing the weekly incidence incidence of scarlet fever in Philadelphia between 1914 and 1947.
tyscarlet
tyscarlet
A data frame with 1774 rows and 4 variables:
the year
the week
weekly scarlet fever incidence
the time counter
A dataset containing the weekly incidence incidence of whooping cough in Philadelphia between 1925 and 1947.
tywhooping
tywhooping
A data frame with 1200 rows and 5 variables:
the year
the week
weekly whooping cough incidence
the time counter
observation counter
Influenza-like illness data for the lower 48 states and the District of Columbia during the 1975/76 season dominated by A/H3N2/Victoria strain
usflu
usflu
A data frame with 49 rows and 7 variables:
State number
State code
Population size
Latitude
Longitude
Week of start of epidemic
Week of peak of epidemic
Viboud C, Bjornstad ON, Smith DL, Simonsen L, Miller MA, Grenfell BT (2006) Synchrony, waves, and spatial hierarchies in the spread of influenza. Science 312: 447-451. doi.org/10.1126/science.1125237.
Function to generate a Watts-Strogats network
WattsStrogatz(N, K, Prw)
WattsStrogatz(N, K, Prw)
N |
the number of nodes |
K |
the number of neighbors to which each node is connected so degree = 2*K |
Prw |
the rewiring probability |
An object of class CM (contact matrix)
cm2=WattsStrogatz(N=20, K=4, Prw=.3)
cm2=WattsStrogatz(N=20, K=4, Prw=.3)