Skip to content

Commit 400c519

Browse files
committed
add 'TwoUndead' model
1 parent 43c91d2 commit 400c519

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1197
-116
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ Collate:
4848
'treeplot.R'
4949
'twospecies.R'
5050
'twospecies_pomp.R'
51+
'twoundead.R'
5152
'yaml.R'

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export(continueSIR)
3131
export(continueSIRS)
3232
export(continueStrains)
3333
export(continueTwoSpecies)
34+
export(continueTwoUndead)
3435
export(curtail)
3536
export(diagram)
3637
export(foreach)
@@ -62,6 +63,7 @@ export(runSIR)
6263
export(runSIRS)
6364
export(runStrains)
6465
export(runTwoSpecies)
66+
export(runTwoUndead)
6567
export(seirs_pomp)
6668
export(simulate)
6769
export(sir_pomp)

R/geneal.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ geneal <- function (object) {
2020
modelSIR = .Call(P_genealSIR,object),
2121
modelStrains = .Call(P_genealStrains,object),
2222
modelTwoSpecies = .Call(P_genealTwoSpecies,object),
23+
modelTwoUndead = .Call(P_genealTwoUndead,object),
2324
model = structure(object,class=c("gpgen")),
2425
pStop("unrecognized model ",sQuote(attr(object,"model")))
2526
)

R/simulate.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ simulate.default <- function (object, ...) {
3737
"- SIR: Classical susceptible-infected-recovered model\n",
3838
"- Strains: Three strains compete for a single susceptible pool.\n",
3939
"- TwoSpecies: Two-host infection model with waning, immigration, demography, and spillover. Hosts are culled upon sampling with a given probability.\n",
40+
"- TwoUndead: Two-host infection model with waning, immigration, demography, and spillover. Hosts are culled upon sampling with a given probability. This is identical to the TwoSpecies model with the exception that dead lineages are not pruned. Instead, they become *ghosts*.\n",
4041
"- SIRS: synonymous with SIR\n",
4142
"- SEIRS: synonymous with SEIR\n",
4243
"\n"
@@ -65,6 +66,7 @@ simulate.character <- function (object, time, ...) {
6566
modelSIR = runSIR(time=time,...),
6667
modelStrains = runStrains(time=time,...),
6768
modelTwoSpecies = runTwoSpecies(time=time,...),
69+
modelTwoUndead = runTwoUndead(time=time,...),
6870
modelSIRS = runSIR(time=time,...),
6971
modelSEIRS = runSEIR(time=time,...),
7072
pStop_("unrecognized model: ",sQuote(object),".\n",
@@ -93,6 +95,7 @@ simulate.gpsim <- function (object, time, ...) {
9395
modelSIR = continueSIR(object,time=time,...),
9496
modelStrains = continueStrains(object,time=time,...),
9597
modelTwoSpecies = continueTwoSpecies(object,time=time,...),
98+
modelTwoUndead = continueTwoUndead(object,time=time,...),
9699
model = pStop_("no model attribute detected."),
97100
pStop_("unrecognized model ",sQuote(model),".")
98101
)

R/twoundead.R

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
##' Two-host infection model with waning, immigration, demography, and spillover. Hosts are culled upon sampling with a given probability. This is identical to the TwoSpecies model with the exception that dead lineages are not pruned. Instead, they become *ghosts*.
2+
##'
3+
##' The population is structured by infection progression and host species.
4+
##'
5+
##' @name twoundead
6+
##' @family Genealogy processes
7+
##' @include seir.R
8+
##' @aliases TwoUndead
9+
##' @include getinfo.R
10+
##' @param Beta11 transmission rate within species 1
11+
##' @param Beta12 transmission from species 2 to species 1
12+
##' @param Beta21 transmission from species 1 to species 2
13+
##' @param Beta22 transmission rate within species 2
14+
##' @param gamma1 species 1 recovery rate
15+
##' @param gamma2 species 2 recovery rate
16+
##' @param psi1 per capita sampling rate for species 1
17+
##' @param psi2 per capita sampling rate for species 2
18+
##' @param c1 probability that a sampled (positive) host of species 1 is culled
19+
##' @param c2 probability that a sampled (positive) host of species 2 is culled
20+
##' @param omega1 rate of waning of immunity for species 1
21+
##' @param omega2 rate of waning of immunity for species 2
22+
##' @param b1 per capita birth rate for species 1
23+
##' @param b2 per capita birth rate for species 2
24+
##' @param d1 per capita death rate for species 1
25+
##' @param d2 per capita death rate for species 2
26+
##' @param iota1 imported infections for species 1
27+
##' @param iota2 imported infections for species 2
28+
##' @param S1_0 initial size of species 1 susceptible population
29+
##' @param S2_0 initial size of species 2 susceptible population
30+
##' @param I1_0 initial size of species 1 infected population
31+
##' @param I2_0 initial size of species 2 infected population
32+
##' @param R1_0 initial size of species 1 immune population
33+
##' @param R2_0 initial size of species 2 immune population
34+
##' @inheritParams sir
35+
##' @return \code{runTwoUndead} and \code{continueTwoUndead} return objects of class \sQuote{gpsim} with \sQuote{model} attribute \dQuote{TwoUndead}.
36+
##'
37+
NULL
38+
39+
##' @rdname twoundead
40+
##' @export
41+
runTwoUndead <- function (
42+
time, t0 = 0,
43+
Beta11 = 4, Beta12 = 0, Beta21 = 0, Beta22 = 4, gamma1 = 1, gamma2 = 1, psi1 = 1, psi2 = 0, c1 = 1, c2 = 1, omega1 = 0, omega2 = 0, b1 = 0, b2 = 0, d1 = 0, d2 = 0, iota1 = 0, iota2 = 0, S1_0 = 100, S2_0 = 100, I1_0 = 0, I2_0 = 10, R1_0 = 0, R2_0 = 0
44+
) {
45+
params <- c(Beta11=Beta11,Beta12=Beta12,Beta21=Beta21,Beta22=Beta22,gamma1=gamma1,gamma2=gamma2,psi1=psi1,psi2=psi2,c1=c1,c2=c2,omega1=omega1,omega2=omega2,b1=b1,b2=b2,d1=d1,d2=d2,iota1=iota1,iota2=iota2)
46+
ivps <- c(S1_0=S1_0,S2_0=S2_0,I1_0=I1_0,I2_0=I2_0,R1_0=R1_0,R2_0=R2_0)
47+
x <- .Call(P_makeTwoUndead,params,ivps,t0)
48+
.Call(P_runTwoUndead,x,time) |>
49+
structure(model="TwoUndead",class=c("gpsim","gpgen"))
50+
}
51+
52+
##' @rdname twoundead
53+
##' @export
54+
continueTwoUndead <- function (
55+
object, time,
56+
Beta11 = NA, Beta12 = NA, Beta21 = NA, Beta22 = NA, gamma1 = NA, gamma2 = NA, psi1 = NA, psi2 = NA, c1 = NA, c2 = NA, omega1 = NA, omega2 = NA, b1 = NA, b2 = NA, d1 = NA, d2 = NA, iota1 = NA, iota2 = NA
57+
) {
58+
params <- c(
59+
Beta11=Beta11,Beta12=Beta12,Beta21=Beta21,Beta22=Beta22,gamma1=gamma1,gamma2=gamma2,psi1=psi1,psi2=psi2,c1=c1,c2=c2,omega1=omega1,omega2=omega2,b1=b1,b2=b2,d1=d1,d2=d2,iota1=iota1,iota2=iota2
60+
)
61+
x <- .Call(P_reviveTwoUndead,object,params)
62+
.Call(P_runTwoUndead,x,time) |>
63+
structure(model="TwoUndead",class=c("gpsim","gpgen"))
64+
}

R/yaml.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ yaml <- function (object) {
2525
modelSIR = .Call(P_yamlSIR,object),
2626
modelStrains = .Call(P_yamlStrains,object),
2727
modelTwoSpecies = .Call(P_yamlTwoSpecies,object),
28+
modelTwoUndead = .Call(P_yamlTwoUndead,object),
2829
model = .Call(P_yaml,object),
2930
pStop("unrecognized model ",sQuote(attr(object,"model")))
3031
) |>

man/lbdp.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/moran.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/s2i2r2.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/seir.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)