22# #' @rdname strains
33# #' @include strains.R
44# #' @param x genealogy in \pkg{phylopomp} format (i.e., an object that inherits from \sQuote{gpgen}).
5+ # #' @param S0,I1_0,I2_0,I3_0,R0 initial conditions; non-negative numbers that specify the relative occupancies of the compartments at the inital time.
6+ # #' @param pop host population size
57# #' @details
68# #' \code{strains_pomp} constructs a \sQuote{pomp} object containing a given set of data and the Strains model.
79# #' @return
810# #' \code{strains_pomp} returns a \sQuote{pomp} object.
9- # #' @importFrom pomp pomp onestep
11+ # #' @importFrom pomp pomp onestep parameter_trans
1012# #' @export
1113strains_pomp <- function (
1214 x ,
1315 Beta1 , Beta2 , Beta3 , gamma ,
14- psi1 , psi2 , psi3 ,
16+ psi1 , psi2 , psi3 , pop ,
1517 S0 , I1_0 , I2_0 , I3_0 , R0
1618) {
1719 x | > gendat(obscure = FALSE ) - > gi
18- ic <- as.integer(c(S0 ,I1_0 ,I2_0 ,I3_0 ,R0 ))
19- names(ic ) <- c(" S0" ," I1_0" ," I2_0" ," I3_0" ," R0" )
20- if (any(ic < 0 ))
21- pStop(paste(sQuote(names(ic )),collapse = " ," ),
22- " must be nonnegative integers." )
20+ ivps <- structure(
21+ c(S0 ,I1_0 ,I2_0 ,I3_0 ,R0 ),
22+ names = c(" S0" ," I1_0" ," I2_0" ," I3_0" ," R0" )
23+ )
24+ if (any(ivps < 0 ))
25+ pStop(paste(sQuote(names(ivps )),collapse = " ," ),
26+ " must be nonnegative." )
2327 pomp(
2428 data = NULL ,
2529 t0 = gi $ nodetime [1L ],
@@ -28,20 +32,27 @@ strains_pomp <- function (
2832 Beta1 = Beta1 ,Beta2 = Beta2 ,Beta3 = Beta3 ,
2933 gamma = gamma ,
3034 psi1 = psi1 ,psi2 = psi2 ,psi3 = psi3 ,
31- ic , N = sum( ic )
35+ ivps , pop = pop
3236 ),
3337 userdata = gi ,
3438 rinit = " strains_rinit" ,
3539 rprocess = onestep(" strains_gill" ),
3640 dmeasure = " strains_dmeas" ,
41+ partrans = parameter_trans(
42+ log = c(
43+ " Beta1" ," Beta2" ," Beta3" ," gamma" ,
44+ " psi1" ," psi2" ," psi3"
45+ ),
46+ barycentric = c(names(ivps ))
47+ ),
3748 statenames = c(
3849 " S" ," I1" ," I2" ," I3" ," R" ,
3950 " ll" ," ell1" ," ell2" ," ell3" ," node"
4051 ),
4152 paramnames = c(
4253 " Beta1" ," Beta2" ," Beta3" ," gamma" ,
4354 " psi1" ," psi2" ," psi3" ,
44- names(ic )," N "
55+ names(ivps )," pop "
4556 ),
4657 PACKAGE = " phylopomp"
4758 )
0 commit comments