Skip to content

Commit

Permalink
change parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Feb 12, 2024
1 parent fe93472 commit 3fd533c
Show file tree
Hide file tree
Showing 44 changed files with 160 additions and 160 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: phylopomp
Type: Package
Title: Phylodynamic Inference for POMP Models
Version: 0.10.1.5
Date: 2024-01-27
Version: 0.10.2.0
Date: 2024-02-12
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="[email protected]",comment=c(ORCID="0000-0001-6159-3207")),
person(given=c("Qianying"),family="Lin",role=c("aut"),comment=c(ORCID="0000-0001-8620-9910"))
)
Expand Down
16 changes: 8 additions & 8 deletions R/seir.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
##' @param sigma progression rate
##' @param gamma recovery rate
##' @param psi per capita sampling rate
##' @param delta rate of waning of immunity
##' @param omega rate of waning of immunity
##' @param S0 initial size of susceptible population
##' @param E0 initial size of exposed population
##' @param I0 initial size of infected population
Expand All @@ -26,9 +26,9 @@ NULL
##' @export
runSEIR <- function (
time, t0 = 0,
Beta = 4, sigma = 1, gamma = 1, psi = 1, delta = 0, S0 = 100, E0 = 5, I0 = 5, R0 = 0
Beta = 4, sigma = 1, gamma = 1, psi = 1, omega = 0, S0 = 100, E0 = 5, I0 = 5, R0 = 0
) {
params <- c(Beta=Beta,sigma=sigma,gamma=gamma,psi=psi,delta=delta)
params <- c(Beta=Beta,sigma=sigma,gamma=gamma,psi=psi,omega=omega)
ivps <- c(S0=S0,E0=E0,I0=I0,R0=R0)
if (any(ivps < 0))
pStop(paste(sQuote(names(ivps)),collapse=","),
Expand All @@ -43,10 +43,10 @@ runSEIR <- function (
##' @export
continueSEIR <- function (
object, time,
Beta = NA, sigma = NA, gamma = NA, psi = NA, delta = NA
Beta = NA, sigma = NA, gamma = NA, psi = NA, omega = NA
) {
params <- c(
Beta=Beta,sigma=sigma,gamma=gamma,psi=psi,delta=delta
Beta=Beta,sigma=sigma,gamma=gamma,psi=psi,omega=omega
)
x <- .Call(P_reviveSEIR,object,params)
.Call(P_runSEIR,x,time) |>
Expand All @@ -63,7 +63,7 @@ continueSEIR <- function (
##' @export
seirs_pomp <- function (
x,
Beta, sigma, gamma, psi, delta = 0,
Beta, sigma, gamma, psi, omega = 0,
S0, E0, I0, R0
)
{
Expand All @@ -84,7 +84,7 @@ seirs_pomp <- function (
t0=dat$time[1L],
times=dat$time[-1L],
params=c(
Beta=Beta,sigma=sigma,gamma=gamma,psi=psi,delta=delta,
Beta=Beta,sigma=sigma,gamma=gamma,psi=psi,omega=omega,
ic,N=sum(ic)
),
nstatevars=nsample+8L,
Expand All @@ -95,7 +95,7 @@ seirs_pomp <- function (
dmeasure="seirs_dmeas",
statenames=c("S","E","I","R","ll","node","linE","linI","lineage"),
paramnames=c(
"Beta","sigma","gamma","psi","delta",
"Beta","sigma","gamma","psi","omega",
"S0","E0","I0","R0","N"
),
PACKAGE="phylopomp"
Expand Down
10 changes: 5 additions & 5 deletions R/si2r.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##' @param Beta transmission rate
##' @param mu mean superspreading-event cluster size
##' @param gamma recovery rate
##' @param delta rate of waning of immunity
##' @param omega rate of waning of immunity
##' @param psi1,psi2 sampling rates for demes 1 and 2, respectively
##' @param sigma12,sigma21 movement rates from deme 1 to 2 and 2 to 1, respectively
##' @param S0 initial size of susceptible population
Expand All @@ -37,13 +37,13 @@ NULL
##' @export
runSI2R <- function (
time, t0 = 0,
Beta = 5, mu = 5, gamma = 1, delta = 0,
Beta = 5, mu = 5, gamma = 1, omega = 0,
psi1 = 1, psi2 = 0,
sigma12 = 1, sigma21 = 3,
S0 = 500, I0 = 10, R0 = 0
) {
params <- c(
Beta=Beta,mu=mu,gamma=gamma,delta=delta,
Beta=Beta,mu=mu,gamma=gamma,omega=omega,
psi1=psi1,psi2=psi2,
sigma12=sigma12,sigma21=sigma21
)
Expand All @@ -58,12 +58,12 @@ runSI2R <- function (
##' @export
continueSI2R <- function (
object, time,
Beta = NA, mu = NA, gamma = NA, delta = NA,
Beta = NA, mu = NA, gamma = NA, omega = NA,
psi1 = NA, psi2 = NA,
sigma12 = NA, sigma21 = NA
) {
params <- c(
Beta=Beta,mu=mu,gamma=gamma,delta=delta,
Beta=Beta,mu=mu,gamma=gamma,omega=omega,
psi1=psi1,psi2=psi2,
sigma12=sigma12,sigma21=sigma21
)
Expand Down
10 changes: 5 additions & 5 deletions R/siir.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
##' @param gamma recovery rate.
##' @param psi1,psi2 sampling rates.
##' @param sigma12,sigma21 movement rates from deme 1 to 2 and 2 to 1, respectively
##' @param delta rate of loss of immunity
##' @param omega rate of loss of immunity
##' @param S0 initial size of susceptible population.
##' @param I1_0 initial size of I2 population.
##' @param I2_0 initial size of I2 population.
Expand All @@ -31,10 +31,10 @@ runSIIR <- function (
Beta1 = 5, Beta2 = 5, gamma = 1,
psi1 = 1, psi2 = 0,
sigma12 = 0, sigma21 = 0,
delta = 0,
omega = 0,
S0 = 500, I1_0 = 10, I2_0 = 10, R0 = 0
) {
params <- c(Beta1=Beta1,Beta2=Beta2,gamma=gamma,psi1=psi1,psi2=psi2,sigma12=sigma12,sigma21=sigma21,delta=delta)
params <- c(Beta1=Beta1,Beta2=Beta2,gamma=gamma,psi1=psi1,psi2=psi2,sigma12=sigma12,sigma21=sigma21,omega=omega)
ivps <- c(S0=S0,I1_0=I1_0,I2_0=I2_0,R0=R0)
x <- .Call(P_makeSIIR,params,ivps,t0)
.Call(P_runSIIR,x,time) |>
Expand All @@ -48,10 +48,10 @@ continueSIIR <- function (
Beta1 = NA, Beta2 = NA, gamma = NA,
psi1 = NA, psi2 = NA,
sigma12 = NA, sigma21 = NA,
delta = NA
omega = NA
) {
params <- c(
Beta1=Beta1,Beta2=Beta2,gamma=gamma,psi1=psi1,psi2=psi2,sigma12=sigma12,sigma21=sigma21,delta=delta
Beta1=Beta1,Beta2=Beta2,gamma=gamma,psi1=psi1,psi2=psi2,sigma12=sigma12,sigma21=sigma21,omega=omega
)
x <- .Call(P_reviveSIIR,object,params)
.Call(P_runSIIR,x,time) |>
Expand Down
16 changes: 8 additions & 8 deletions R/sir.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @param Beta transmission rate.
##' @param gamma recovery rate.
##' @param psi sampling rate.
##' @param delta immunity waning rate
##' @param omega immunity waning rate
##' @param S0 initial size of susceptible population.
##' @param I0 initial size of infected population.
##' @param R0 initial size of recovered population.
Expand All @@ -24,10 +24,10 @@ NULL
##' @export
runSIR <- function (
time, t0 = 0,
Beta = 2, gamma = 1, psi = 1, delta = 0,
Beta = 2, gamma = 1, psi = 1, omega = 0,
S0 = 100, I0 = 2, R0 = 0
) {
params <- c(Beta=Beta,gamma=gamma,psi=psi,delta=delta)
params <- c(Beta=Beta,gamma=gamma,psi=psi,omega=omega)
ivps <- c(S0=S0,I0=I0,R0=R0)
if (any(ivps < 0))
pStop(paste(sQuote(names(ivps)),collapse=","),
Expand All @@ -45,9 +45,9 @@ runSIRS <- runSIR
##' @inheritParams simulate
##' @export
continueSIR <- function (
object, time, Beta = NA, gamma = NA, psi = NA, delta = NA
object, time, Beta = NA, gamma = NA, psi = NA, omega = NA
) {
params <- c(Beta=Beta,gamma=gamma,psi=psi,delta=delta)
params <- c(Beta=Beta,gamma=gamma,psi=psi,omega=omega)
x <- .Call(P_reviveSIR,object,params)
.Call(P_runSIR,x,time) |>
structure(model="SIR",class=c("gpsim","gpgen"))
Expand All @@ -61,7 +61,7 @@ continueSIR <- function (
##' \code{sir_pomp} constructs a \pkg{pomp} object containing a given set of data and a SIR model.
##' @importFrom pomp pomp onestep covariate_table
##' @export
sir_pomp <- function (x, Beta, gamma, psi, delta = 0, S0, I0, R0, t0=0)
sir_pomp <- function (x, Beta, gamma, psi, omega = 0, S0, I0, R0, t0=0)
{
ic <- as.integer(c(S0,I0,R0))
names(ic) <- c("S0","I0","R0")
Expand All @@ -74,7 +74,7 @@ sir_pomp <- function (x, Beta, gamma, psi, delta = 0, S0, I0, R0, t0=0)
pomp(
data=NULL,
times=dat$time[-1L],t0=t0,
params=c(Beta=Beta,gamma=gamma,psi=psi,delta=delta,ic,N=sum(ic)),
params=c(Beta=Beta,gamma=gamma,psi=psi,omega=omega,ic,N=sum(ic)),
covar=covariate_table(
dat,
times="time",
Expand All @@ -84,7 +84,7 @@ sir_pomp <- function (x, Beta, gamma, psi, delta = 0, S0, I0, R0, t0=0)
rprocess=onestep("sirs_gill"),
dmeasure="sirs_dmeas",
statenames=c("S","I","R","ll"),
paramnames=c("Beta","gamma","psi","delta","S0","I0","R0","N"),
paramnames=c("Beta","gamma","psi","omega","S0","I0","R0","N"),
covarnames=c("lineages","code"),
PACKAGE="phylopomp"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/movie.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)

pb <- utils::txtProgressBar(0,length(times),0,style=3)
x <- simulate("SIIR",time=0,Beta1=5,Beta2=10,gamma=1,delta=0.5,
x <- simulate("SIIR",time=0,Beta1=5,Beta2=10,gamma=1,omega=0.5,
psi1=0.2,psi2=0.1,sigma12=1,sigma21=1,S0=200,I1_0=3,I2_0=2)
for (k in seq_len(length(times))) {
x <- simulate(x,time=times[k])
Expand Down
4 changes: 2 additions & 2 deletions examples/seir.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ runSEIR(Beta=3,gamma=0.1,psi=0.2,S0=100,I0=5,R0=0,time=2,t0=0) -> x
plot_grid(plotlist=list(plot(x,points=TRUE),diagram(x)),
ncol=1,rel_heights=c(4,1))

simulate("SEIR",sigma=1,delta=1,time=20,I0=4) |> plot(obscure=FALSE)
simulate("SEIR",sigma=1,omega=1,time=20,I0=4) |> plot(obscure=FALSE)

simulate("SEIR",sigma=1,delta=1,time=20,I0=4) |>
simulate("SEIR",sigma=1,omega=1,time=20,I0=4) |>
lineages(obscure=FALSE) |>
plot()
2 changes: 1 addition & 1 deletion examples/si2r.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ simulate("SI2R",time=5) |>
simulate("SI2R",time=2) |>
diagram(m=30)

simulate("SI2R",time=20,delta=0.2,mu=20) -> x
simulate("SI2R",time=20,omega=0.2,mu=20) -> x
plot_grid(
x |> plot(obscure=FALSE),
x |> lineages(obscure=FALSE) |> plot(),
Expand Down
4 changes: 2 additions & 2 deletions examples/sir.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ runSIR(Beta=3,gamma=0.1,psi=0.2,S0=100,I0=5,R0=0,time=2,t0=0) -> x
plot_grid(plotlist=list(plot(x,points=TRUE),diagram(x)),
ncol=1,rel_heights=c(4,1))

simulate("SIRS",delta=1,time=20,I0=4) |> plot()
simulate("SIRS",delta=1,time=20,I0=4) |> lineages() |> plot()
simulate("SIRS",omega=1,time=20,I0=4) |> plot()
simulate("SIRS",omega=1,time=20,I0=4) |> lineages() |> plot()
12 changes: 6 additions & 6 deletions man/seir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/si2r.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/siir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3fd533c

Please sign in to comment.