|
| 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 | +} |
0 commit comments