From 4e63744a9a1a1f90015191fcc87d71000224b562 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 15 Jan 2024 11:33:57 -0800 Subject: [PATCH] Major Update: blood feeding, egg laying, and resource dynamics This update includes a few bug fixes introduced through the transition to multi-species models. Now, pars$nStrata is no longer relevant. Instead, we use pars$Hpar[[i]]$nStrata. The major changes here update resource dynamics, egg laying, and blood feeding. + By policy all variables not in the vector y are stored in pars$vars + Other than the transmission terms (EIR, FoI, kappa, beta), the objects related to blood feeding and transmission are now stored in pars$BFpar, including time spent and time at risk matrices. + The terms relating to the availability of humans / hosts for blood feeding are now computed in Resources, but they are set up in BFpar. + Other than the terms computed by egg laying (Lambda, calU, and eggs_laid), all objects related to egg laying are stored in pars$EGGpar + The .setup case was introduced to initialize terms after setup for static models. + The utilities to compute TaR were renamed to indicate that they are actually computing Time Spent, and an explicit function was created that makes TaR matrices from a time at risk matrix. + setup_Hpar now handles only demography. --- NAMESPACE | 91 +++-- R/adult-RM.R | 10 +- R/aquatic-basic.R | 2 +- R/aquatic-interface.R | 14 +- R/available_blood.R | 77 ++++ R/available_habitat.R | 53 +++ R/available_sugar.R | 28 ++ R/bionomics.R | 73 +++- R/blood_feeding.R | 90 +++++ R/compute.R | 2 +- R/demography-interface.R | 47 +-- R/diffeqn.R | 20 +- R/egg_laying.R | 161 ++++++-- R/exposure.R | 1 + R/habitat_dynamics.R | 25 +- R/human-SIP.R | 22 +- R/human-SIS.R | 18 +- R/human-hMoI.R | 10 +- R/local_fraction.R | 56 +++ R/other_blood_hosts.R | 12 +- R/resources-forced.R | 87 ----- R/resources-interface.R | 40 -- R/resources-null.R | 48 --- R/resources.R | 105 ++++++ R/setup.R | 70 ++-- R/solving.R | 5 +- R/{sugar.R => sugar_dynamics.R} | 19 +- R/time_at_risk.R | 83 ---- R/time_spent.R | 95 +++++ R/transmission.R | 196 +++++++--- R/travel_malaria-null.R | 24 -- R/travel_malaria-static.R | 24 ++ R/utils.R | 37 +- R/visitors.R | 28 +- _pkgdown.yml | 355 ++++++++++-------- ...HumanAvailability.Rd => AvailableBlood.Rd} | 10 +- ...ility.null.Rd => AvailableBlood.forced.Rd} | 8 +- ...lity.forced.Rd => AvailableBlood.setup.Rd} | 8 +- man/AvailableBlood.static.Rd | 21 ++ man/AvailableHabitat.Rd | 17 + ...y.forced.Rd => AvailableHabitat.forced.Rd} | 8 +- man/AvailableHabitat.simple.Rd | 17 + man/AvailableHabitat.static.Rd | 17 + man/AvailableSugar.Rd | 17 + ...ity.forced.Rd => AvailableSugar.forced.Rd} | 8 +- man/AvailableSugar.static.Rd | 17 + man/Bionomics.Ldynamic.Rd | 21 ++ man/Bionomics.Mdynamic.Rd | 21 ++ man/Bionomics.Rd | 5 +- man/Bionomics.dynamic.Rd | 21 ++ man/Bionomics.setup.Rd | 21 ++ man/Bionomics.static.Rd | 21 ++ ...tSearch.static.Rd => EggLaying.dynamic.Rd} | 8 +- ...atSearch.dynamic.Rd => EggLaying.setup.Rd} | 8 +- man/EggLaying.simple.Rd | 21 ++ man/EggLaying.static.Rd | 21 ++ man/F_EIR.Rd | 4 +- man/F_beta.Rd | 18 +- man/F_kappa.Rd | 6 +- man/HabitatAvailability.Rd | 17 - man/HabitatAvailability.null.Rd | 17 - man/HabitatDynamics.Rd | 4 +- man/HabitatDynamics.null.Rd | 19 - man/HabitatDynamics.static.Rd | 19 + man/LocalFrac.Rd | 17 + man/LocalFrac.dynamic.Rd | 17 + man/LocalFrac.static.Rd | 17 + ...osts.null.Rd => OtherBloodHosts.static.Rd} | 8 +- man/Resources.Rd | 2 +- man/Resources.forced.Rd | 2 +- man/{Resources.null.Rd => Resources.setup.Rd} | 8 +- man/Resources.static.Rd | 21 ++ man/SugarAvailability.Rd | 17 - man/SugarAvailability.null.Rd | 17 - man/{Sugar.Rd => SugarDynamics.Rd} | 8 +- ...{Sugar.null.Rd => SugarDynamics.static.Rd} | 10 +- man/Transmission.Rd | 4 +- man/Transmission.dynamic.Rd | 21 ++ man/Transmission.setup.Rd | 21 ++ man/Transmission.static.Rd | 21 ++ man/{Visitors.null.Rd => Visitors.static.Rd} | 10 +- man/compute_AvailableHabitat.Rd | 19 + man/compute_AvailableHosts.Rd | 23 ++ man/compute_EIR.Rd | 21 ++ man/compute_EIR_full.Rd | 21 ++ man/{HabitatSearch.Rd => compute_EggsLaid.Rd} | 8 +- man/compute_beta.Rd | 14 +- man/compute_calU.Rd | 21 ++ man/compute_kappa.Rd | 21 ++ man/compute_local_frac.Rd | 2 +- man/make_TaR.Rd | 18 +- man/make_TaR.as_matrix.Rd | 23 -- man/make_TaR.athome.Rd | 23 -- man/make_TaR.xy.Rd | 23 -- man/make_TimeSpent.Rd | 23 ++ man/make_TimeSpent.as_matrix.Rd | 23 ++ man/make_TimeSpent.athome.Rd | 23 ++ man/make_TimeSpent.xy.Rd | 23 ++ ...TaR_athome.Rd => make_TimeSpent_athome.Rd} | 18 +- man/{make_TaR_xy.Rd => make_TimeSpent_xy.Rd} | 12 +- man/make_calU.Rd | 6 +- man/make_calU_s.Rd | 19 + man/make_parameters_demography_null.Rd | 8 +- man/setup_BFpar_static.Rd | 25 ++ man/setup_BloodFeeding.Rd | 37 ++ man/setup_EGGpar_static.Rd | 22 ++ ...EggLaying.Rd => setup_EggLaying_simple.Rd} | 6 +- man/setup_EggLaying_static.Rd | 23 ++ man/{setup_Hpar.Rd => setup_Hpar_static.Rd} | 14 +- man/setup_bionomics_static.Rd | 17 + man/setup_habitat_dynamics_null.Rd | 17 - man/setup_habitat_dynamics_static.Rd | 17 + man/setup_local_fraction_simple.Rd | 19 + man/setup_other_blood_hosts_null.Rd | 17 - man/setup_other_blood_hosts_static.Rd | 19 + man/setup_resources_forced.Rd | 2 +- man/setup_resources_null.Rd | 2 +- man/setup_resources_static.Rd | 17 + man/setup_sugar_null.Rd | 17 - man/setup_sugar_static.Rd | 19 + man/setup_travel_null.Rd | 17 - man/setup_travel_static.Rd | 19 + man/setup_visitors_null.Rd | 17 - man/setup_visitors_static.Rd | 23 ++ man/travel_malaria.null.Rd | 19 - man/travel_malaria.static.Rd | 19 + man/xde_setup.Rd | 15 +- man/xde_setup_cohort.Rd | 8 +- man/xde_setup_human.Rd | 15 +- tests/testthat/test-aqua-basic.R | 10 +- tests/testthat/test-equilibrium-RM-SIP.R | 10 +- tests/testthat/test-equilibrium-RM-SIS.R | 10 +- tests/testthat/test-equilibrium-RM-hMoI.R | 10 +- tests/testthat/test-human-hMoI.R | 5 +- tests/testthat/test-human-sip.R | 5 +- tests/testthat/test-human-sis.R | 5 +- tests/testthat/test-vc-lemenach.R | 5 +- vignettes/adult_GeRM.Rmd | 4 + vignettes/adult_RM.Rmd | 5 +- vignettes/aqua_basic.Rmd | 11 +- vignettes/aqua_trace.Rmd | 5 +- vignettes/ex_534.Rmd | 58 ++- vignettes/human_hmoi.Rmd | 8 +- vignettes/human_sip.Rmd | 10 +- vignettes/human_sis.Rmd | 11 +- vignettes/vc_lemenach.Rmd | 11 +- 146 files changed, 2490 insertions(+), 1196 deletions(-) create mode 100644 R/available_blood.R create mode 100644 R/available_habitat.R create mode 100644 R/available_sugar.R create mode 100644 R/local_fraction.R delete mode 100644 R/resources-forced.R delete mode 100644 R/resources-interface.R delete mode 100644 R/resources-null.R create mode 100644 R/resources.R rename R/{sugar.R => sugar_dynamics.R} (53%) delete mode 100644 R/time_at_risk.R create mode 100644 R/time_spent.R delete mode 100644 R/travel_malaria-null.R create mode 100644 R/travel_malaria-static.R rename man/{HumanAvailability.Rd => AvailableBlood.Rd} (56%) rename man/{HumanAvailability.null.Rd => AvailableBlood.forced.Rd} (69%) rename man/{HumanAvailability.forced.Rd => AvailableBlood.setup.Rd} (68%) create mode 100644 man/AvailableBlood.static.Rd create mode 100644 man/AvailableHabitat.Rd rename man/{HabitatAvailability.forced.Rd => AvailableHabitat.forced.Rd} (62%) create mode 100644 man/AvailableHabitat.simple.Rd create mode 100644 man/AvailableHabitat.static.Rd create mode 100644 man/AvailableSugar.Rd rename man/{SugarAvailability.forced.Rd => AvailableSugar.forced.Rd} (61%) create mode 100644 man/AvailableSugar.static.Rd create mode 100644 man/Bionomics.Ldynamic.Rd create mode 100644 man/Bionomics.Mdynamic.Rd create mode 100644 man/Bionomics.dynamic.Rd create mode 100644 man/Bionomics.setup.Rd create mode 100644 man/Bionomics.static.Rd rename man/{HabitatSearch.static.Rd => EggLaying.dynamic.Rd} (67%) rename man/{HabitatSearch.dynamic.Rd => EggLaying.setup.Rd} (67%) create mode 100644 man/EggLaying.simple.Rd create mode 100644 man/EggLaying.static.Rd delete mode 100644 man/HabitatAvailability.Rd delete mode 100644 man/HabitatAvailability.null.Rd delete mode 100644 man/HabitatDynamics.null.Rd create mode 100644 man/HabitatDynamics.static.Rd create mode 100644 man/LocalFrac.Rd create mode 100644 man/LocalFrac.dynamic.Rd create mode 100644 man/LocalFrac.static.Rd rename man/{OtherBloodHosts.null.Rd => OtherBloodHosts.static.Rd} (60%) rename man/{Resources.null.Rd => Resources.setup.Rd} (70%) create mode 100644 man/Resources.static.Rd delete mode 100644 man/SugarAvailability.Rd delete mode 100644 man/SugarAvailability.null.Rd rename man/{Sugar.Rd => SugarDynamics.Rd} (71%) rename man/{Sugar.null.Rd => SugarDynamics.static.Rd} (51%) create mode 100644 man/Transmission.dynamic.Rd create mode 100644 man/Transmission.setup.Rd create mode 100644 man/Transmission.static.Rd rename man/{Visitors.null.Rd => Visitors.static.Rd} (54%) create mode 100644 man/compute_AvailableHabitat.Rd create mode 100644 man/compute_AvailableHosts.Rd create mode 100644 man/compute_EIR.Rd create mode 100644 man/compute_EIR_full.Rd rename man/{HabitatSearch.Rd => compute_EggsLaid.Rd} (72%) create mode 100644 man/compute_calU.Rd create mode 100644 man/compute_kappa.Rd delete mode 100644 man/make_TaR.as_matrix.Rd delete mode 100644 man/make_TaR.athome.Rd delete mode 100644 man/make_TaR.xy.Rd create mode 100644 man/make_TimeSpent.Rd create mode 100644 man/make_TimeSpent.as_matrix.Rd create mode 100644 man/make_TimeSpent.athome.Rd create mode 100644 man/make_TimeSpent.xy.Rd rename man/{make_TaR_athome.Rd => make_TimeSpent_athome.Rd} (55%) rename man/{make_TaR_xy.Rd => make_TimeSpent_xy.Rd} (59%) create mode 100644 man/make_calU_s.Rd create mode 100644 man/setup_BFpar_static.Rd create mode 100644 man/setup_BloodFeeding.Rd create mode 100644 man/setup_EGGpar_static.Rd rename man/{setup_EggLaying.Rd => setup_EggLaying_simple.Rd} (77%) create mode 100644 man/setup_EggLaying_static.Rd rename man/{setup_Hpar.Rd => setup_Hpar_static.Rd} (51%) create mode 100644 man/setup_bionomics_static.Rd delete mode 100644 man/setup_habitat_dynamics_null.Rd create mode 100644 man/setup_habitat_dynamics_static.Rd create mode 100644 man/setup_local_fraction_simple.Rd delete mode 100644 man/setup_other_blood_hosts_null.Rd create mode 100644 man/setup_other_blood_hosts_static.Rd create mode 100644 man/setup_resources_static.Rd delete mode 100644 man/setup_sugar_null.Rd create mode 100644 man/setup_sugar_static.Rd delete mode 100644 man/setup_travel_null.Rd create mode 100644 man/setup_travel_static.Rd delete mode 100644 man/setup_visitors_null.Rd create mode 100644 man/setup_visitors_static.Rd delete mode 100644 man/travel_malaria.null.Rd create mode 100644 man/travel_malaria.static.Rd diff --git a/NAMESPACE b/NAMESPACE index 8f136d21..b24110e9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,11 +5,24 @@ S3method(Abiotic,null) S3method(AreaSpray,null) S3method(AreaSprayEffectSizes,null) S3method(AreaSprayEffects,null) +S3method(AvailableBlood,forced) +S3method(AvailableBlood,setup) +S3method(AvailableBlood,static) +S3method(AvailableHabitat,forced) +S3method(AvailableHabitat,simple) +S3method(AvailableHabitat,static) +S3method(AvailableSugar,forced) +S3method(AvailableSugar,static) S3method(BedNetEffectSizes,lemenach) S3method(BedNetEffectSizes,null) S3method(BedNetEffects,null) S3method(Behavior,forced) S3method(Behavior,null) +S3method(Bionomics,Ldynamic) +S3method(Bionomics,Mdynamic) +S3method(Bionomics,dynamic) +S3method(Bionomics,setup) +S3method(Bionomics,static) S3method(Births,zero) S3method(CareSeeking,null) S3method(Civil,forced) @@ -21,6 +34,10 @@ S3method(Control,static) S3method(Development,null) S3method(DistributeBedNets,null) S3method(EIP,static) +S3method(EggLaying,dynamic) +S3method(EggLaying,setup) +S3method(EggLaying,simple) +S3method(EggLaying,static) S3method(F_H,SIP) S3method(F_H,SIS) S3method(F_H,hMoI) @@ -68,13 +85,7 @@ S3method(F_sigma,static) S3method(HTC,SIP) S3method(HTC,SIS) S3method(HTC,hMoI) -S3method(HabitatAvailability,forced) -S3method(HabitatAvailability,null) -S3method(HabitatDynamics,null) -S3method(HabitatSearch,dynamic) -S3method(HabitatSearch,static) -S3method(HumanAvailability,forced) -S3method(HumanAvailability,null) +S3method(HabitatDynamics,static) S3method(Hydrology,null) S3method(IRSeffectSizes,null) S3method(IRSeffects,null) @@ -82,6 +93,8 @@ S3method(LBionomics,basic) S3method(LBionomics,trace) S3method(LSMeffectSizes,null) S3method(LSMeffects,null) +S3method(LocalFrac,dynamic) +S3method(LocalFrac,static) S3method(MBionomics,GeRM) S3method(MBionomics,Gtrace) S3method(MBionomics,RM) @@ -89,22 +102,24 @@ S3method(MBionomics,Ztrace) S3method(MBionomics,basicM) S3method(MassMedical,forced) S3method(MassMedical,null) -S3method(OtherBloodHosts,null) +S3method(OtherBloodHosts,static) S3method(OviTraps,null) S3method(OwnBedNet,null) S3method(Rainfall,null) S3method(Relative_Humidity,null) S3method(Resources,forced) -S3method(Resources,null) +S3method(Resources,setup) +S3method(Resources,static) S3method(Shock,null) S3method(SprayHouses,null) -S3method(Sugar,null) -S3method(SugarAvailability,forced) -S3method(SugarAvailability,null) S3method(SugarBaitEffectSizes,null) S3method(SugarBaitEffects,null) S3method(SugarBaits,null) +S3method(SugarDynamics,static) S3method(Temperature,null) +S3method(Transmission,dynamic) +S3method(Transmission,setup) +S3method(Transmission,static) S3method(TreatHabitats,null) S3method(UseBedNet,null) S3method(VectorControl,control) @@ -114,7 +129,7 @@ S3method(VectorControlEffectSizes,null) S3method(VectorControlEffects,control) S3method(VectorControlEffects,null) S3method(Visitors,basic) -S3method(Visitors,null) +S3method(Visitors,static) S3method(Weather,forced) S3method(Weather,null) S3method(check_abiotic,forced) @@ -155,9 +170,9 @@ S3method(get_inits_X,SIP) S3method(get_inits_X,SIS) S3method(get_inits_X,hMoI) S3method(get_inits_X,trace) -S3method(make_TaR,as_matrix) -S3method(make_TaR,athome) -S3method(make_TaR,xy) +S3method(make_TimeSpent,as_matrix) +S3method(make_TimeSpent,athome) +S3method(make_TimeSpent,xy) S3method(make_calK,as_matrix) S3method(make_calK,herethere) S3method(make_calK,xy) @@ -214,7 +229,7 @@ S3method(setup_control,forced) S3method(setup_control,null) S3method(travel_malaria,eir) S3method(travel_malaria,foi) -S3method(travel_malaria,null) +S3method(travel_malaria,static) S3method(update_inits_L,basic) S3method(update_inits_L,trace) S3method(update_inits_MYZ,GeRM_dde) @@ -242,6 +257,9 @@ export(Abiotic) export(AreaSpray) export(AreaSprayEffectSizes) export(AreaSprayEffects) +export(AvailableBlood) +export(AvailableHabitat) +export(AvailableSugar) export(BedNetEffectSizes) export(BedNetEffects) export(Behavior) @@ -276,16 +294,14 @@ export(F_q) export(F_sigma) export(F_tau) export(HTC) -export(HabitatAvailability) export(HabitatDynamics) -export(HabitatSearch) -export(HumanAvailability) export(Hydrology) export(IRSeffectSizes) export(IRSeffects) export(LBionomics) export(LSMeffectSizes) export(LSMeffects) +export(LocalFrac) export(MBionomics) export(MassMedical) export(OtherBloodHosts) @@ -296,11 +312,10 @@ export(Relative_Humidity) export(Resources) export(Shock) export(SprayHouses) -export(Sugar) -export(SugarAvailability) export(SugarBaitEffectSizes) export(SugarBaitEffects) export(SugarBaits) +export(SugarDynamics) export(Temperature) export(Transmission) export(TreatHabitats) @@ -314,6 +329,10 @@ export(approx_equal) export(checkIt) export(check_abiotic) export(check_civil) +export(compute_AvailableHabitat) +export(compute_AvailableHosts) +export(compute_EIR) +export(compute_EIR_full) export(compute_NI) export(compute_NI_ix) export(compute_beta) @@ -321,6 +340,7 @@ export(compute_fqM) export(compute_fqM_ix) export(compute_fqZ) export(compute_fqZ_ix) +export(compute_kappa) export(compute_local_frac) export(compute_terms) export(compute_terms_steady) @@ -352,8 +372,9 @@ export(make_MYZpar_Ztrace) export(make_MYZpar_basicM) export(make_Omega) export(make_TaR) -export(make_TaR_athome) -export(make_TaR_xy) +export(make_TimeSpent) +export(make_TimeSpent_athome) +export(make_TimeSpent_xy) export(make_Xinits_SIP) export(make_Xinits_SIS) export(make_Xinits_hMoI) @@ -365,6 +386,7 @@ export(make_calK) export(make_calK_xy) export(make_calN) export(make_calU) +export(make_calU_s) export(make_indices) export(make_indices_L) export(make_indices_MYZ) @@ -404,9 +426,13 @@ export(parse_deout_L) export(parse_deout_MYZ) export(parse_deout_X) export(parse_deout_vec) +export(setup_BFpar_static) +export(setup_BloodFeeding) +export(setup_EGGpar_static) export(setup_EIP) -export(setup_EggLaying) -export(setup_Hpar) +export(setup_EggLaying_simple) +export(setup_EggLaying_static) +export(setup_Hpar_static) export(setup_Linits) export(setup_Lpar) export(setup_MYZinits) @@ -419,6 +445,7 @@ export(setup_area_spray_null) export(setup_behavior) export(setup_behavior_forced) export(setup_behavior_null) +export(setup_bionomics_static) export(setup_care_seeking_null) export(setup_civil_forced) export(setup_civil_null) @@ -431,31 +458,33 @@ export(setup_development_null) export(setup_eip_static) export(setup_exposure_nb) export(setup_exposure_pois) -export(setup_habitat_dynamics_null) +export(setup_habitat_dynamics_static) export(setup_hydrology_null) export(setup_irs_null) export(setup_itn_lemenach) export(setup_itn_null) +export(setup_local_fraction_simple) export(setup_lsm_null) export(setup_mass_medical_forced) export(setup_mass_medical_null) -export(setup_other_blood_hosts_null) +export(setup_other_blood_hosts_static) export(setup_ovitraps_null) export(setup_rainfall_null) export(setup_relative_humidity_null) export(setup_resources_forced) export(setup_resources_null) +export(setup_resources_static) export(setup_shock_null) export(setup_sugar_baits_null) -export(setup_sugar_null) +export(setup_sugar_static) export(setup_temperature_null) export(setup_travel_eir) export(setup_travel_foi) -export(setup_travel_null) +export(setup_travel_static) export(setup_vc_control) export(setup_vc_null) export(setup_visitors_basic) -export(setup_visitors_null) +export(setup_visitors_static) export(setup_weather_forced) export(setup_weather_null) export(shapeIt) diff --git a/R/adult-RM.R b/R/adult-RM.R index 8a19ece7..5d6adea3 100644 --- a/R/adult-RM.R +++ b/R/adult-RM.R @@ -63,12 +63,12 @@ dMYZdt.RM_ode <- function(t, y, pars, s) { Z <- y[Z_ix] with(pars$MYZpar[[s]],{ - dMdt <- Lambda - (Omega %*% M) - dPdt <- f*(M - P) - (Omega %*% P) - dYdt <- f*q*kappa*(M - Y) - (Omega %*% Y) - dZdt <- Upsilon %*% diag(f*q*kappa, nPatches) %*% (M - Y) - (Omega %*% Z) + dM <- Lambda - (Omega %*% M) + dP <- f*(M - P) - (Omega %*% P) + dY <- f*q*kappa*(M - Y) - (Omega %*% Y) + dZ <- Upsilon %*% diag(f*q*kappa, nPatches) %*% (M - Y) - (Omega %*% Z) - return(c(dMdt, dPdt, dYdt, dZdt)) + return(c(dM, dP, dY, dZ)) }) }) } diff --git a/R/aquatic-basic.R b/R/aquatic-basic.R index f9389927..6cccbfe9 100644 --- a/R/aquatic-basic.R +++ b/R/aquatic-basic.R @@ -32,7 +32,7 @@ F_alpha.basic <- function(t, y, pars, s) { #' @return a [numeric] vector #' @export dLdt.basic <- function(t, y, pars, s) { - eta <- pars$eta[[s]] + eta <- pars$eggs_laid[[s]] with(pars$ix$L[[s]],{ L <- y[L_ix] with(pars$Lpar[[s]], { diff --git a/R/aquatic-interface.R b/R/aquatic-interface.R index 673003c4..7b47e3da 100644 --- a/R/aquatic-interface.R +++ b/R/aquatic-interface.R @@ -119,16 +119,4 @@ make_calN = function(nPatches, membership){ return(calN) } -#' @title Make the egg distribution matrix, calU -#' @param calN the habitat membership matrix -#' @param searchQ the habitat search weights -#' @return a [matrix] of dimensions `nHabitats` by `nPatches` -#' @export -make_calU = function(calN, searchQ=1){ - calU = searchQ*t(calN) - colNorms = colSums(calU) - ix = which(colNorms == 0) - if(length(ix)>0) colNorms[ix]=1 - calU = calU %*% diag(1/colNorms) - return(calU) -} + diff --git a/R/available_blood.R b/R/available_blood.R new file mode 100644 index 00000000..cab6d649 --- /dev/null +++ b/R/available_blood.R @@ -0,0 +1,77 @@ + +#' @title Update the availability of blood hosts +#' @description This method dispatches on the type of `pars$BFpar`. +#' @param t current simulation time +#' @param y vector of state variables +#' @param pars an [list] +#' @return a [list] +#' @export +AvailableBlood <- function(t, y, pars) { + UseMethod("AvailableBlood", pars$BFpar) +} + +#' @title Compute availability of local humans for blood feeding +#' @description Compute the availability for the pathogen's hosts for blood feeding +#' @param t current simulation time +#' @param y state vector +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableBlood.static <- function(t, y, pars){ + return(pars) +} + +#' @title Compute availability of local humans for blood feeding +#' @description Compute the availability for the pathogen's hosts for blood feeding +#' @param t current simulation time +#' @param y state vector +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableBlood.setup <- function(t, y, pars){ + for(s in 1:pars$nVectors) + pars = compute_AvailableHosts(t, y, pars, s) + + return(pars) +} + +#' @title Compute availability of local humans for blood feeding +#' @description Compute the availability for the pathogen's hosts for blood feeding +#' @param t current simulation time +#' @param y state vector +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableBlood.forced <- function(t, y, pars){ + for(s in 1:pars$nVectors) + pars = compute_AvailableHosts(t, y, pars, s) + + return(pars) +} + +#' @title Compute availability blood hosts of the i^th species +#' @description Compute the availability for the pathogen's hosts for blood feeding +#' @param t current simulation time +#' @param y state vector +#' @param pars a [list] +#' @param s the vector species index +#' @return a [numeric] vector of length `nPatches` +#' @export +compute_AvailableHosts <- function(t, y, pars, s){ + + H = F_H(t, y, pars, 1) + + pars$vars$Wi[[1]][[s]] = as.vector(with(pars$BFpar, TaR[[1]][[s]] %*% (searchWts[[1]][[s]]*H))) + pars$vars$W[[s]] = pars$vars$Wi[[1]][[s]] + if(pars$nHosts > 1){ + for(i in 2:pars$nHosts){ + H = F_H(t, y, pars, i) + pars$vars$Wi[[i]][[s]] = as.vector(with(pars$BFpar, TaR[[i]][[s]] %*% (searchWts[[i]][[s]]*H))) + pars$vars$W[[s]] = pars$vars$W[[s]] + pars$vars$Wi[[i]][[s]] + } + } + pars$vars$W[[s]] = as.vector(pars$vars$W[[s]]) + pars$vars$B[[s]] = as.vector(with(pars$vars, W[[s]] + Visitors[[s]] + Other[[s]])) + + return(pars) +} diff --git a/R/available_habitat.R b/R/available_habitat.R new file mode 100644 index 00000000..7905da72 --- /dev/null +++ b/R/available_habitat.R @@ -0,0 +1,53 @@ + +#' @title Update the availability of aquatic habitats +#' @description This method dispatches on the type of `pars$EGGpar`. +#' @param pars an [list] +#' @return a [list] +#' @export +AvailableHabitat <- function(pars) { + UseMethod("AvailableHabitat", pars$EGGpar) +} + +#' @title Compute total availability of aquatic habitats +#' @description Computes the availability of aquatic habitats for the static model (do nothing) +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableHabitat.static <- function(pars){ + return(pars) +} + +#' @title Compute total availability of aquatic habitats +#' @description Computes the availability of aquatic habitats for the static model (do nothing) +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableHabitat.simple <- function(pars){ + return(pars) +} + +#' @title Compute total availability of aquatic habitats +#' @description Computes the availability of aquatic habitats +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableHabitat.forced <- function(pars){ + for(s in 1:pars$nVectors) pars = compute_AvailableHabitat(pars, s) + return(pars) +} + +#' @title Compute total availability of aquatic habitats +#' @description Computes the availability of aquatic habitats +#' @param pars a [list] +#' @param s the vector species index +#' @return a [numeric] vector of length `nPatches` +#' @export +compute_AvailableHabitat <- function(pars, s){ + habitats = with(pars, calN %*% EGGpar$searchWts[[s]]) + Q = habitats + pars$vars$ovitraps + pars$vars$non_habitats + Qfrac = as.vector(habitats/Q) + Qfrac[which(Q==0)]=0 + pars$vars$Q[[s]] = as.vector(Q) + pars$vars$Qfrac[[s]] = as.vector(Qfrac) + return(pars) +} diff --git a/R/available_sugar.R b/R/available_sugar.R new file mode 100644 index 00000000..5cd5870a --- /dev/null +++ b/R/available_sugar.R @@ -0,0 +1,28 @@ + +#' @title Update the availability of sugar +#' @description This method dispatches on the type of `pars$SUGAR`. +#' @param pars an [list] +#' @return a [list] +#' @export +AvailableSugar <- function(pars) { + UseMethod("AvailableSugar", pars$SUGAR) +} + +#' @title Compute total availability of sugar +#' @description Computes the availability of sugar for the static model (do nothing) +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableSugar.static <- function(pars){ + return(pars) +} + +#' @title Compute total availability of sugar +#' @description Computes the availability of sugar +#' @param pars a [list] +#' @return a [numeric] vector of length `nPatches` +#' @export +AvailableSugar.forced <- function(pars){ + pars$S = pars$nectar + pars$sugar_baits + return(pars) +} diff --git a/R/bionomics.R b/R/bionomics.R index df457216..a10564cc 100644 --- a/R/bionomics.R +++ b/R/bionomics.R @@ -1,16 +1,83 @@ #' @title Set bionomic parameter rates relative to baseline -#' @description This calls Mbionomics and Lbionmics for each species +#' @description This calls Mbionomics and Lbionmics for each species. This function +#' resets bionomic parameters to their pre-control baseline value, which can later be +#' modified by vector control. In some models, the pre-control baseline is computed in +#' here as a function of resource availability. #' @param t current simulation time #' @param y state vector #' @param pars a [list] #' @return a [list] #' @export Bionomics <- function(t, y, pars){ - pars <- HabitatSearch(t, y, pars) - for(s in 1:pars$nVectors){ + UseMethod("Bionomics", pars$BIONOMICS) +} + +#' @title Set bionomic parameter rates relative to baseline +#' @description This calls Mbionomics and Lbionmics for each species +#' @inheritParams Bionomics +#' @return a [list] +#' @export +Bionomics.static <- function(t, y, pars){ + return(pars) +} + +#' @title Set bionomic parameter rates relative to baseline +#' @description This calls Mbionomics and Lbionmics for each species +#' @inheritParams Bionomics +#' @return a [list] +#' @export +Bionomics.setup <- function(t, y, pars){ + for(s in 1:pars$nVectors){ + pars <- MBionomics(t, y, pars, s) + pars <- LBionomics(t, y, pars, s) + } + class(pars$BIONOMICS) <- "static" + return(pars) +} + +#' @title Set bionomic parameter rates relative to baseline +#' @description This calls Mbionomics and Lbionmics for each species +#' @inheritParams Bionomics +#' @return a [list] +#' @export +Bionomics.dynamic <- function(t, y, pars){ + for(s in 1:pars$nVectors){ pars <- MBionomics(t, y, pars, s) pars <- LBionomics(t, y, pars, s) } return(pars) } + +#' @title Set bionomic parameter rates relative to baseline +#' @description This calls Mbionomics and Lbionmics for each species +#' @inheritParams Bionomics +#' @return a [list] +#' @export +Bionomics.Mdynamic <- function(t, y, pars){ + for(s in 1:pars$nVectors) pars <- MBionomics(t, y, pars, s) + return(pars) +} + +#' @title Set bionomic parameter rates relative to baseline +#' @description This calls Lbionomics for each species each time step +#' @inheritParams Bionomics +#' @return a [list] +#' @export +Bionomics.Ldynamic <- function(t, y, pars){ + for(s in 1:pars$nVectors) pars <- LBionomics(t, y, pars, s) + return(pars) +} + +#' @title Make parameters for the static model bionomics +#' @param pars a [list] +#' @return [list] +#' @export +setup_bionomics_static <- function(pars) { + + BIONOMICS <- list() + class(BIONOMICS) <- "setup" + pars$BIONOMICS <- BIONOMICS + + return(pars) +} diff --git a/R/blood_feeding.R b/R/blood_feeding.R index e69de29b..60f613f4 100644 --- a/R/blood_feeding.R +++ b/R/blood_feeding.R @@ -0,0 +1,90 @@ + +#' @title Set up the blood feeding model +#' @description This sets up a list that stores all the information required by the +#' blood feeding model, including information about humans (the residence vector, search +#' weights for blood feeding mosquitoes); the mosquitoes circadian pattern (F_circadian); +#' and derived structures, including the time spent (TimeSpent) and the time at risk (TaR) +#' matrices. This also sets up the objects required for blood feeding, including host availability +#' for each species (Wi) and for all hosts (W), other blood hosts (Other), and total blood +#' availability (B). Finally, it sets up the lists that will hold the mixing matrix (beta), and +#' the transmission terms describing the entomological inoculation rate (EIR and eir), and the force +#' of infection (FoI), and the net infectiousness (kappa and ni). +#' @param pars a [list] +#' @return none +#' @export +setup_BFpar_static <- function(pars){ + up = list() + class(up) <- "setup" + + # Human + up$residence = list() + up$searchWts = list() + up$searchWts[[1]] = list() + + # Mosquito + up$F_circadian = list() + + # Time Spent / Time at Risk + up$TimeSpent = list() + up$TaR = list() + up$TaR[[1]] = list() + + # Mosquito + pars$BFpar <- up + + # Available Blood Hosts, by vector species + pars$vars$Wi = list() + pars$vars$Wi[[1]] = list() + pars$vars$W = list() + pars$vars$Other = list() + pars$vars$B = list() + + # Transmission Terms + pars$beta = list() + pars$beta[[1]] = list() + + pars$eir = list() + pars$eir[[1]] = list() + pars$EIR = list() + pars$FoI = list() + + pars$ni = list() + pars$ni[[1]] = list() + pars$kappa = list() + + return(pars) +} + +#' @title Set up blood feeding +#' @description This sets up a list that stores all the information +#' @param pars a [list] +#' @param i the host species index +#' @param s the vector species index +#' @param BFopts a [list] +#' @param residence is the patch where each stratum resides +#' @param searchWts is the blood feeding search weight for each stratum +#' @param F_circadian is a function that computes relative mosquito blood feeding activity rates by time of day +#' @return none +#' @export +setup_BloodFeeding <- function(pars, i, s=1, BFopts = list(), residence=1, searchWts=1, F_circadian=NULL){ + pars$BFpar$searchWts[[i]][[s]] = checkIt(searchWts, pars$Hpar[[i]]$nStrata) + pars$BFpar$relativeBitingRate[[i]][[s]] = checkIt(searchWts, pars$Hpar[[i]]$nStrata) + pars$BFpar$residence[[i]] = checkIt(residence, pars$Hpar[[i]]$nStrata) + if(is.null(F_circadian)) pars$BFpar$F_circadian[[s]] = function(d){return(1)} + return(pars) +} + +#' @title Make TaR +#' @description Make a time at risk matrix (TaR) from a time spent matrix and a circadian function +#' @param t the time +#' @param pars a [list] +#' @param i the host species index +#' @param s the vector species index +#' @return none +#' @export +make_TaR <- function(t, pars, i, s){ + pars$BFpar$TaR[[i]][[s]] = with(pars$BFpar, TimeSpent[[i]]*F_circadian[[s]](t)) + return(pars) +} + + diff --git a/R/compute.R b/R/compute.R index 05bf3bd3..6ce033a8 100644 --- a/R/compute.R +++ b/R/compute.R @@ -43,7 +43,7 @@ compute_terms.cohort <- function(varslist, deout, pars, s, i) { time = deout[,1] d1 = length(time) - eir = matrix(pars$F_eir(time, pars), d1, pars$nStrata) + eir = matrix(pars$F_eir(time, pars), d1, pars$Hpar[[i]]$nStrata) ni = compute_NI(deout, pars, i) pr = F_pr(varslist, pars, i) return(list(time=time,eir=eir,pr=pr,ni=ni)) diff --git a/R/demography-interface.R b/R/demography-interface.R index 511c0e77..2859bc2e 100644 --- a/R/demography-interface.R +++ b/R/demography-interface.R @@ -2,34 +2,29 @@ #' @title A utility to set up Hpar #' @param pars a [list] +#' @param i the host species index #' @param HPop a [numeric] vector of population densities -#' @param residence is the patch where each stratum resides -#' @param searchWts is the blood feeding search weight for each stratum -#' @param Hopts a [list] to overwrite default values #' @return a [list] #' @export -setup_Hpar = function(pars, HPop=1000, residence=1, searchWts=1, Hopts=NULL){ - with(Hopts,{ - with(pars, if(!exists("nStrata")) pars$nStrata = length(HPop)) +setup_Hpar_static = function(pars, i, HPop=1000){ - Hpar = list() - Hpar$H = HPop + Hpar = list() + class(Hpar) <- "static" + Hpar$H = HPop + Hpar$nStrata = length(HPop) - Hpar$residence <- checkIt(residence, pars$nStrata) - Hpar$wts_f <- checkIt(searchWts, pars$nStrata) - Hpar$rbr <- searchWts*sum(HPop)/sum(searchWts*HPop) + Bf <- "zero" + class(Bf) <- "zero" + Hpar$Bf <- Bf - Bf <- "zero" - class(Bf) <- "zero" - Hpar$Bf <- Bf + dH <- "zero" + class(dH) <- "zero" + Hpar$dH <- dH - dH <- "zero" - class(dH) <- "zero" - Hpar$dH <- dH + pars$Hpar[[i]] <- Hpar - pars$Hpar[[1]] <- Hpar - return(pars) -})} + return(pars) +} #' @title Derivatives of demographic changes in human populations @@ -59,20 +54,13 @@ Births <- function(t, y, pars, i){ #' @title Make parameters for null human demography model #' @param pars a [list] #' @param H size of human population in each strata -#' @param residence is a vector describing patch residency -#' @param searchWts is a vector describing blood feeding search weights -#' @param TaR is a matrix describing time spent among patches #' @return none #' @export -make_parameters_demography_null <- function(pars, H, residence, searchWts, TaR) { +make_parameters_demography_null <- function(pars, H) { stopifnot(length(H) == pars$nStrata) Hpar <- list() Hpar$H <- H - - Hpar$residence <- checkIt(residence, pars$nStrata, F) - Hpar$wts_f <- checkIt(searchWts, pars$nStrata, F) - Hpar$rbr <- searchWts*sum(H)/sum(searchWts*H) - Hpar$TaR <- TaR + Hpar$nStrata <- length(H) Bf <- "zero" class(Bf) <- "zero" @@ -83,7 +71,6 @@ make_parameters_demography_null <- function(pars, H, residence, searchWts, TaR) Hpar$dH <- dH pars$Hpar[[1]] <- Hpar - pars$nStrata <- length(H) return(pars) } diff --git a/R/diffeqn.R b/R/diffeqn.R index dc285a32..881a91ad 100644 --- a/R/diffeqn.R +++ b/R/diffeqn.R @@ -36,20 +36,21 @@ xDE_diffeqn <- function(t, y, pars) { # compute the FoI pars <- Exposure(t, y, pars) - # state derivatives + # compute derivatives dL <- dLdt(t, y, pars, 1) dMYZ <- dMYZdt(t, y, pars, 1) if(pars$nVectors > 1) - for(s in 1:pars$nVectors){ + for(s in 2:pars$nVectors){ dL <- c(dL, dLdt(t, y, pars, s)) dMYZ <- c(dMYZ, dMYZdt(t, y, pars, s)) } dX <- dXdt(t, y, pars, 1) if(pars$nHosts > 1) - for(i in 1:pars$nHosts) + for(i in 2:pars$nHosts) dX <- c(dX, dXdt(t, y, pars, i)) + return(list(c(dL, dMYZ, dX))) } @@ -83,7 +84,7 @@ xDE_diffeqn_human <- function(t, y, pars) { # state derivatives dX <- dXdt(t, y, pars, 1) if(pars$nHosts > 1) - for(i in 1:pars$nHosts) + for(i in 2:pars$nHosts) dX <- c(dX, dXdt(t, y, pars, i)) return(list(c(dX))) @@ -107,7 +108,7 @@ xDE_diffeqn_mosy <- function(t, y, pars) { pars <- Shock(t, pars) pars <- Control(t, y, pars) pars <- Behavior(t, y, pars) - pars <- Resources(t, y, pars) + #pars <- Resources(t, y, pars) # set baseline mosquito bionomic parameters pars <- Bionomics(t, y, pars) @@ -143,7 +144,7 @@ xDE_diffeqn_mosy <- function(t, y, pars) { xDE_diffeqn_cohort <- function(a, y, pars, F_eir) { # EIR: entomological inoculation rate trace - pars$EIR[[1]] <- F_eir(a, pars)*pars$Hpar[[1]]$wts_f + pars$EIR[[1]] <- F_eir(a, pars)*pars$BFpar$relativeBitingRate[[1]][[1]] # FoI: force of infection pars <- Exposure(a, y, pars) @@ -151,7 +152,7 @@ xDE_diffeqn_cohort <- function(a, y, pars, F_eir) { # state derivatives dX <- dXdt(t, y, pars, 1) if(pars$nHosts > 1) - for(i in 1:pars$nHosts) + for(i in 2:pars$nHosts) dX <- c(dX, dXdt(t, y, pars, i)) return(list(c(dX))) @@ -171,14 +172,15 @@ xDE_diffeqn_aquatic <- function(t, y, pars) { pars <- Abiotic(t, pars) pars <- Shock(t, pars) pars <- Control(t, y, pars) - pars <- Resources(t, y, pars) + pars <- HabitatDynamics(t, pars) # modify baseline mosquito bionomic parameters pars <- LBionomics(t, y, pars, 1) pars <- VectorControlEffectSizes(t, y, pars) # egg laying: compute eta - pars <- EggLaying(t, y, pars) + + pars$eggs_laid[[1]] = F_eggs(t, y, pars, 1) # state derivatives dL <- dLdt(t, y, pars, 1) diff --git a/R/egg_laying.R b/R/egg_laying.R index 21078ef9..6464f064 100644 --- a/R/egg_laying.R +++ b/R/egg_laying.R @@ -1,16 +1,3 @@ -#' @title Setup egg laying for most models -#' @description Sets up the egg-deposition matrix calU for the s^th species -#' @param pars the model object -#' @param s the vector species index -#' @param searchQ the membership matrix -#' @param Lopts a [list] of options to override defaults -#' @return a [list] vector -#' @export -setup_EggLaying = function(pars, s, searchQ=1, Lopts=list()){with(Lopts,{ - pars$search4habitat[[s]] = checkIt(searchQ, pars$nHabitats, F) - pars$calU[[s]] = make_calU(pars$calN, searchQ) - return(pars) -})} #' @title Compute eggs laid #' @description Computes eggs laid for the s^th species @@ -20,42 +7,162 @@ setup_EggLaying = function(pars, s, searchQ=1, Lopts=list()){with(Lopts,{ #' @return a [list] #' @export EggLaying = function(t, y, pars){ + UseMethod("EggLaying", pars$EGGpar) +} + +#' @title Compute eggs laid +#' @description Computes eggs laid for the s^th species +#' @inheritParams EggLaying +#' @return a [list] +#' @export +EggLaying.static = function(t, y, pars){ + pars = compute_EggsLaid(t, y, pars) + return(pars) +} + +#' @title Compute eggs laid +#' @description Computes eggs laid for the s^th species +#' @inheritParams EggLaying +#' @return a [list] +#' @export +EggLaying.simple = function(t, y, pars){ for(s in 1:pars$nVectors) - pars$eta[[s]] = pars$calU[[s]] %*% F_eggs(t, y, pars, s) + pars$eggs_laid[[s]] = pars$calU[[s]] %*% F_eggs(t, y, pars, s) return(pars) } -#' @title Searching for Habitat +#' @title Compute eggs laid #' @description Computes eggs laid for the s^th species -#' @param t the time -#' @param y the state variables -#' @param pars the model object +#' @inheritParams EggLaying #' @return a [list] #' @export -HabitatSearch = function(t, y, pars){ - UseMethod("HabitatSearch", pars$calU) +EggLaying.setup = function(t, y, pars){ + for(s in 1:pars$nVectors) pars = compute_AvailableHabitat(pars, s) + pars = compute_calU(t, y, pars) + class(pars$EGGpar) <- "static" + return(pars) } -#' @title Searching for Habitat + +#' @title Compute eggs laid #' @description Computes eggs laid for the s^th species +#' @inheritParams EggLaying +#' @return a [list] +#' @export +EggLaying.dynamic = function(t, y, pars){ + pars = compute_calU(t, y, pars) + pars = compute_EggsLaid(t, y, pars) + return(pars) +} + +#' @title Compute calU +#' @description Computes the egg laying matrices #' @param t the time #' @param y the state variables #' @param pars the model object #' @return a [list] -#' @export -HabitatSearch.static = function(t, y, pars){ +compute_calU = function(t, y, pars){ + + for(s in 1:pars$nVectors) + pars = make_calU_s(pars, s) return(pars) } -#' @title Searching for Habitat +#' @title Compute eggs laid #' @description Computes eggs laid for the s^th species #' @param t the time #' @param y the state variables #' @param pars the model object #' @return a [list] -#' @export -HabitatSearch.dynamic = function(t, y, pars){ +compute_EggsLaid = function(t, y, pars){ for(s in 1:pars$nVectors) - pars$calU[[s]] = with(pars, make_calU(calN, egg_laying[[s]]$searchQ)) + pars$eggs_laid[[s]] = pars$calU[[s]] %*% (F_eggs(t, y, pars, s)*pars$vars$Qfrac[[s]]) + + return(pars) +} + +#' @title Make the egg distribution matrix, calU +#' @param calN the habitat membership matrix +#' @param searchWts the habitat search weights +#' @return a [matrix] of dimensions `nHabitats` by `nPatches` +#' @export +make_calU = function(calN, searchWts=1){ + calU = searchWts*t(calN) + colNorms = colSums(calU) + ix = which(colNorms == 0) + if(length(ix)>0) colNorms[ix]=1 + calU = calU %*% diag(1/colNorms) + return(calU) +} + +#' @title Make the egg distribution matrix, calU +#' @param pars the model object +#' @param s vector species index +#' @return [list] +#' @export +make_calU_s = function(pars, s){ + pars$calU[[s]] = make_calU(pars$calN, pars$EGGpar$searchWts[[s]]) return(pars) } + + +#' @title Setup the structures required for egg laying +#' @description This sets up the object EGGpar, which holds information +#' about the egg laying model. Several terms are expected to differ by +#' vector species, including the search weights (searchWts), the fraction +#' of eggs laid in habitat that is sometimes suitable (Qfrac), the +#' egg deposition matrix (calU), and the habitat egg laying rate (eggs_laid). +#' This function sets up lists. +#' @param pars the model object +#' @return a [list] vector +#' @export +setup_EGGpar_static = function(pars){ + up <- list() + class(up) <- "static" + + pars$EGGpar <- up + pars$EGGpar$searchWts = list() + + pars$vars$Qfrac = list() + pars$vars$Qfrac[[1]] <- 1 + + pars$calU = list() + pars$eggs_laid = list() + + return(pars) +} + +#' @title Setup egg laying for most models +#' @description Sets up the egg-deposition matrix calU for the s^th species +#' @param pars the model object +#' @param s the vector species index +#' @param searchQ the membership matrix +#' @param Lopts a [list] of options to override defaults +#' @return a [list] vector +#' @export +setup_EggLaying_static = function(pars, s, searchQ=1, Lopts=list()){with(Lopts,{ + + # Habitat search weights + searchQ = checkIt(searchQ, pars$nHabitats) + pars$EGGpar$searchWts[[s]] = checkIt(searchQ, pars$nHabitats, F) + pars <- make_calU_s(pars, s) + return(pars) +})} + +#' @title Setup egg laying for most models +#' @description Sets up the egg-deposition matrix calU for the s^th species +#' @param pars the model object +#' @param s the vector species index +#' @param searchQ the membership matrix +#' @param Lopts a [list] of options to override defaults +#' @return a [list] vector +#' @export +setup_EggLaying_simple = function(pars, s, searchQ=1, Lopts=list()){with(Lopts,{ + + # Habitat search weights + searchQ = checkIt(searchQ, pars$nHabitats) + pars$EGGpar$searchWts[[s]] = searchQ + pars <- make_calU_s(pars, 1) + class(pars$EGGpar) <- "simple" + return(pars) +})} diff --git a/R/exposure.R b/R/exposure.R index c97628cf..4e3b1497 100644 --- a/R/exposure.R +++ b/R/exposure.R @@ -5,6 +5,7 @@ #' @return [list] #' @export Exposure <- function(t, y, pars){ + for(i in 1:pars$nHosts){ b = F_b(y, pars, i) pars$FoI[[i]] = F_foi(pars$EIR[[i]], b, pars) + travel_malaria(t, pars) diff --git a/R/habitat_dynamics.R b/R/habitat_dynamics.R index b3fa7a73..b30f78fa 100644 --- a/R/habitat_dynamics.R +++ b/R/habitat_dynamics.R @@ -1,7 +1,7 @@ # Methods to set up variables describing exogenous forcing by habitat_dynamics -#' @title Set the values of exogenous variables describing habitat_dynamics -#' @description This method dispatches on the type of `pars$HABITAT_DYNAMICS`. +#' @title Habitat Dynamics and Searching +#' @description Set the values of habitat search weights and other exogenous variables describing habitat_dynamics. This method dispatches on the type of `pars$HABITAT_DYNAMICS`. #' @param t current simulation time #' @param pars a [list] #' @return [list] @@ -10,22 +10,23 @@ HabitatDynamics <- function(t, pars) { UseMethod("HabitatDynamics", pars$HABITAT_DYNAMICS) } -#' @title Set the values of exogenous variables describing habitat dynamics -#' @description Implements [HabitatDynamics] for the null model of habitat_dynamics (do nothing) +#' @title Set the values of habitat search weights and other exogenous variables describing habitat_dynamics +#' @description Implements [HabitatDynamics] for the static model of habitat_dynamics (do nothing) #' @inheritParams HabitatDynamics #' @return [list] #' @export -HabitatDynamics.null <- function(t, pars) { +HabitatDynamics.static <- function(t, pars) { return(pars) } -#' @title Make parameters for the null model for habitat dynamics (do nothing) -#' @param pars a [list] -#' @return [list] +#' @title Setup the egg laying object +#' @description Sets up the egg-deposition matrix calU for the s^th species +#' @param pars the model object +#' @return a [list] vector #' @export -setup_habitat_dynamics_null <- function(pars) { - HABITAT_DYNAMICS <- list() - class(HABITAT_DYNAMICS) <- 'null' - pars$HABITAT_DYNAMICS <- HABITAT_DYNAMICS +setup_habitat_dynamics_static = function(pars){ + up <- list() + class(up) <- "static" + pars$HABITAT_DYNAMICS <- up return(pars) } diff --git a/R/human-SIP.R b/R/human-SIP.R index 2f1b87e2..7a1bba82 100644 --- a/R/human-SIP.R +++ b/R/human-SIP.R @@ -87,7 +87,7 @@ HTC.SIP <- function(pars, i) { #' @return a [list] vector #' @export setup_Xpar.SIP = function(Xname, pars, i, Xopts=list()){ - pars$Xpar[[i]] = make_Xpar_SIP(pars$nStrata, Xopts) + pars$Xpar[[i]] = make_Xpar_SIP(pars$Hpar[[i]]$nStrata, Xopts) return(pars) } @@ -97,7 +97,7 @@ setup_Xpar.SIP = function(Xname, pars, i, Xopts=list()){ #' @return a [list] vector #' @export setup_Xinits.SIP = function(pars, i, Xopts=list()){ - pars$Xinits[[i]] = make_Xinits_SIP(pars$nStrata, Xopts, H0=pars$Hpar[[i]]$H) + pars$Xinits[[i]] = make_Xinits_SIP(pars$Hpar[[i]]$nStrata, Xopts, H0=pars$Hpar[[i]]$H) return(pars) } @@ -171,13 +171,13 @@ parse_deout_X.SIP <- function(deout, pars, i) { #' @export make_indices_X.SIP <- function(pars, i) {with(pars,{ - S_ix <- seq(from = max_ix+1, length.out=nStrata) + S_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(S_ix, 1) - I_ix <- seq(from = max_ix+1, length.out=nStrata) + I_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(I_ix, 1) - P_ix <- seq(from = max_ix+1, length.out=nStrata) + P_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(P_ix, 1) pars$max_ix = max_ix @@ -231,7 +231,7 @@ update_inits_X.SIP <- function(pars, y0, i) { S = y0[S_ix] I = y0[I_ix] P = y0[P_ix] - pars$Xinits[[i]] = make_Xinits_SIP(pars$nStrata, list(), S0=S, I0=I, P0=P) + pars$Xinits[[i]] = make_Xinits_SIP(pars$Hpar[[i]]$nStrata, list(), S0=S, I0=I, P0=P) return(pars) })} @@ -272,15 +272,15 @@ xde_plot_X.SIP = function(pars, i=1, clrs=c("darkblue", "darkred", "darkgreen"), #' @export xde_lines_X_SIP = function(XH, pars, clrs=c("darkblue", "darkred", "darkgreen"), llty=1){ with(XH,{ - if(pars$nStrata==1) { + if(pars$Hpar[[i]]$nStrata==1) { lines(time, S, col=clrs[1], lty = llty[1]) lines(time, I, col=clrs[2], lty = llty[1]) lines(time, P, col=clrs[3], lty = llty[1]) } - if(pars$nStrata>1){ - if (length(clrs)==1) clrs=matrix(clrs, 3, pars$nStrata) - if (length(llty)==1) llty=rep(llty, pars$nStrata) - for(i in 1:pars$nStrata){ + if(pars$Hpar[[i]]$nStrata>1){ + if (length(clrs)==1) clrs=matrix(clrs, 3, pars$Hpar[[i]]$nStrata) + if (length(llty)==1) llty=rep(llty, pars$Hpar[[i]]$nStrata) + for(i in 1:pars$Hpar[[i]]$nStrata){ lines(time, S[,i], col=clrs[1,i], lty = llty[i]) lines(time, I[,i], col=clrs[2,i], lty = llty[i]) lines(time, P[,i], col=clrs[3,i], lty = llty[i]) diff --git a/R/human-SIS.R b/R/human-SIS.R index 9bbd7d15..fa063b40 100644 --- a/R/human-SIS.R +++ b/R/human-SIS.R @@ -69,7 +69,7 @@ dXdt.SIS <- function(t, y, pars, i) { #' @return a [list] vector #' @export setup_Xpar.SIS = function(Xname, pars, i, Xopts=list()){ - pars$Xpar[[i]] = make_Xpar_SIS(pars$nStrata, Xopts) + pars$Xpar[[i]] = make_Xpar_SIS(pars$Hpar[[i]]$nStrata, Xopts) return(pars) } @@ -79,7 +79,7 @@ setup_Xpar.SIS = function(Xname, pars, i, Xopts=list()){ #' @return a [list] vector #' @export setup_Xinits.SIS = function(pars, i, Xopts=list()){ - pars$Xinits[[i]] = with(pars,make_Xinits_SIS(nStrata, Xopts, H0=Hpar[[i]]$H)) + pars$Xinits[[i]] = with(pars,make_Xinits_SIS(pars$Hpar[[i]]$nStrata, Xopts, H0=Hpar[[i]]$H)) return(pars) } @@ -154,10 +154,10 @@ HTC.SIS <- function(pars, i) { #' @export make_indices_X.SIS <- function(pars, i) {with(pars,{ - S_ix <- seq(from = max_ix+1, length.out=nStrata) + S_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(S_ix, 1) - I_ix <- seq(from = max_ix+1, length.out=nStrata) + I_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(I_ix, 1) pars$max_ix = max_ix @@ -244,15 +244,15 @@ xde_plot_X.SIS = function(pars, i=1, clrs=c("darkblue","darkred"), llty=1, stabl #' @export xde_lines_X_SIS = function(XH, pars, clrs=c("darkblue","darkred"), llty=1){ with(XH,{ - if(pars$nStrata==1) { + if(pars$Hpar[[i]]$nStrata==1) { lines(time, S, col=clrs[1], lty = llty[1]) lines(time, I, col=clrs[2], lty = llty[1]) } - if(pars$nStrata>1){ - if (length(clrs)==2) clrs=matrix(clrs, 2, pars$nStrata) - if (length(llty)==1) llty=rep(llty, pars$nStrata) + if(pars$Hpar[[i]]$nStrata>1){ + if (length(clrs)==2) clrs=matrix(clrs, 2, pars$Hpar[[i]]$nStrata) + if (length(llty)==1) llty=rep(llty, pars$Hpar[[i]]$nStrata) - for(i in 1:pars$nStrata){ + for(i in 1:pars$Hpar[[i]]$nStrata){ lines(time, S[,i], col=clrs[1,i], lty = llty[i]) lines(time, I[,i], col=clrs[2,i], lty = llty[i]) } diff --git a/R/human-hMoI.R b/R/human-hMoI.R index a44c3789..021343a8 100644 --- a/R/human-hMoI.R +++ b/R/human-hMoI.R @@ -75,7 +75,7 @@ dXdt.hMoI <- function(t, y, pars, i) { #' @return a [list] vector #' @export setup_Xpar.hMoI = function(Xname, pars, i, Xopts=list()){ - pars$Xpar[[i]] = make_Xpar_hMoI(pars$nStrata, Xopts) + pars$Xpar[[i]] = make_Xpar_hMoI(pars$Hpar[[i]]$nStrata, Xopts) return(pars) } @@ -85,7 +85,7 @@ setup_Xpar.hMoI = function(Xname, pars, i, Xopts=list()){ #' @return a [list] vector #' @export setup_Xinits.hMoI = function(pars, i, Xopts=list()){ - pars$Xinits[[i]] = make_Xinits_hMoI(pars$nStrata, Xopts) + pars$Xinits[[i]] = make_Xinits_hMoI(pars$Hpar[[i]]$nStrata, Xopts) return(pars) } @@ -150,10 +150,10 @@ HTC.hMoI <- function(pars, i) { #' @importFrom utils tail #' @export make_indices_X.hMoI <- function(pars, i) {with(pars,{ - m1_ix <- seq(from = max_ix+1, length.out=nStrata) + m1_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(m1_ix, 1) - m2_ix <- seq(from = max_ix+1, length.out=nStrata) + m2_ix <- seq(from = max_ix+1, length.out=Hpar[[i]]$nStrata) max_ix <- tail(m2_ix, 1) pars$max_ix = max_ix @@ -205,7 +205,7 @@ update_inits_X.hMoI <- function(pars, y0,i) { with(pars$ix$X[[i]],{ m1 = y0[m1_ix] m2 = y0[m2_ix] - pars$Xinits[[i]] = make_Xinits_hMoI(pars$nStrata, m10=m1, m20=m2) + pars$Xinits[[i]] = make_Xinits_hMoI(pars$Hpar[[1]]$nStrata, m10=m1, m20=m2) return(pars) })} diff --git a/R/local_fraction.R b/R/local_fraction.R new file mode 100644 index 00000000..a77ac2ef --- /dev/null +++ b/R/local_fraction.R @@ -0,0 +1,56 @@ + +#' @title Compute the local fraction +#' @description This method dispatches on the type of `pars$BFpar` +#' @param pars, a [list] +#' @return [list] +#' @export +LocalFrac <- function(pars){ + UseMethod("LocalFrac", pars$BFpar) +} + +#' @title Compute transmission terms dynamically, no update required +#' @description This method dispatches on the type of `pars$BFpar` +#' @inheritParams LocalFrac +#' @return [list] +#' @export +LocalFrac.static <- function(pars){ + return(pars) +} + +#' @title Compute transmission terms dynamically, no update required +#' @description This method dispatches on the type of `pars$BFpar` +#' @inheritParams LocalFrac +#' @return [list] +#' @export +LocalFrac.dynamic <- function(pars){ + pars = compute_local_frac(pars) + return(pars) +} + +#' @title Compute the local fraction +#' @description Compute the availability for the pathogen's hosts for blood feeding +#' @param pars a [list] +#' @return pars a [list] +#' @export +compute_local_frac <- function(pars){ + + for(s in 1:pars$nVectors) + pars$vars$local_frac[[s]] = with(pars$vars, W[[s]]/(W[[s]]+Visitors[[s]])) + + return(pars) +} + +#' @title Set up the local_fraction for static models +#' @description The local fraction +#' @param pars a [list] +#' @param local_frac is the fraction of the ambient human / host population that is not a visitor +#' @return [list] +#' @export +setup_local_fraction_simple <- function(pars, local_frac=1) { + + pars$vars$local_frac = list() + pars$vars$local_frac[[1]] = local_frac + + return(pars) +} + diff --git a/R/other_blood_hosts.R b/R/other_blood_hosts.R index 22bd2d90..62140b3c 100644 --- a/R/other_blood_hosts.R +++ b/R/other_blood_hosts.R @@ -11,21 +11,23 @@ OtherBloodHosts <- function(t, pars) { } #' @title Set the values of exogenous variables describing other blood hosts -#' @description Implements [OtherBloodHosts] for the null model of other_blood_hosts (do nothing) +#' @description Implements [OtherBloodHosts] for the static model of other_blood_hosts (do nothing) #' @inheritParams OtherBloodHosts #' @return [list] #' @export -OtherBloodHosts.null <- function(t, pars) { +OtherBloodHosts.static <- function(t, pars) { return(pars) } -#' @title Make parameters for the null model for other blood hosts (do nothing) +#' @title Make parameters for the static model for other blood hosts (do nothing) #' @param pars a [list] +#' @param Other the availability of other blood hosts #' @return [list] #' @export -setup_other_blood_hosts_null <- function(pars) { +setup_other_blood_hosts_static <- function(pars, Other=0) { OTHER_BLOOD <- list() - class(OTHER_BLOOD) <- 'null' + class(OTHER_BLOOD) <- 'static' + pars$vars$Other[[1]] = Other pars$OTHER_BLOOD <- OTHER_BLOOD return(pars) } diff --git a/R/resources-forced.R b/R/resources-forced.R deleted file mode 100644 index b6719b2d..00000000 --- a/R/resources-forced.R +++ /dev/null @@ -1,87 +0,0 @@ -# specialized methods for models with dynamically changing resource availability - -#' @title Methods for resources -#' @description Implements [Resources] -#' @inheritParams Resources -#' @return [list] -#' @export -Resources.forced <- function(t, y, pars) { - - # Availability of Blood Hosts - pars = OtherBloodHosts(t, pars) - pars = HumanAvailability(t, y, pars) - - # Availability of Blood Hosts - pars = HabitatDynamics(t, pars) - pars = HabitatAvailability(pars) - - # Availability of Blood Hosts - pars = Sugar(t, pars) - pars = SugarAvailability(pars) - - pars$local_frac = compute_local_frac(pars) - - return(pars) -} - - -#' @title Compute availability of local humans for blood feeding -#' @description Compute the availability for the pathogen's hosts for blood feeding -#' @param t current simulation time -#' @param y state vector -#' @param pars a [list] -#' @return a [numeric] vector of length `nPatches` -#' @export -HumanAvailability.forced <- function(t, y, pars){ - H = F_H(t, y, pars) - pars$W = with(pars$Hpar, TaR %*% (wts_f*H)) - return(pars) -} - -#' @title Compute total availability of aquatic habitats -#' @description Computes the availability of aquatic habitats -#' @param pars a [list] -#' @return a [numeric] vector of length `nPatches` -#' @export -HabitatAvailability.forced <- function(pars){ - habitats = with(pars, calN %*% searchQ) - pars$Q = habitats + pars$ovitraps + pars$non_habitats - pars$eggs_laid = habitats/pars$Q - pars$calU = make_calU(pars$calN, pars$searchQ) - return(pars) -} - -#' @title Compute total availability of sugar -#' @description Computes the availability of sugar -#' @param pars a [list] -#' @return a [numeric] vector of length `nPatches` -#' @export -SugarAvailability.forced <- function(pars){ - pars$S = pars$nectar + pars$sugar_baits - return(pars) -} - -#' @title Set up a model for mass medical -#' @param pars a [list] -#' @return [list] -#' @export -setup_resources_forced <- function(pars) { - pars = setup_control(pars) - RESOURCES <- list() - class(RESOURCES) <- 'forced' - pars$RESOURCES <- RESOURCES - pars = setup_habitat_dynamics_null(pars) - pars = setup_sugar_null(pars) - pars = setup_other_blood_hosts_null(pars) - return(pars) -} - -#' @title Compute the local fraction -#' @description Compute the availability for the pathogen's hosts for blood feeding -#' @param pars a [list] -#' @return pars a [list] -#' @export -compute_local_frac <- function(pars){ - pars$local_frac = with(pars, W/(W+Visitors)) - return(pars) -} diff --git a/R/resources-interface.R b/R/resources-interface.R deleted file mode 100644 index 0bf49212..00000000 --- a/R/resources-interface.R +++ /dev/null @@ -1,40 +0,0 @@ -#' @title Set the values of exogenous variables describing available mosquito resources -#' @description This method dispatches on the type of `pars$RESOURCES`. -#' @param t current simulation time -#' @param y vector of state variables -#' @param pars a [list] -#' @return none -#' @export -Resources <- function(t, y, pars) { - UseMethod("Resources", pars$RESOURCES) -} - -#' @title Update the availability of blood hosts -#' @description This method dispatches on the type of `pars$RESOURCES`. -#' @param t current simulation time -#' @param y vector of state variables -#' @param pars an [list] -#' @return a [list] -#' @export -HumanAvailability <- function(t, y, pars) { - UseMethod("HumanAvailability", pars$RESOURCES) -} - -#' @title Update the availability of aquatic habitats -#' @description This method dispatches on the type of `pars$RESOURCES`. -#' @param pars an [list] -#' @return a [list] -#' @export -HabitatAvailability <- function(pars) { - UseMethod("HabitatAvailability", pars$RESOURCES) -} - -#' @title Update the availability of sugar -#' @description This method dispatches on the type of `pars$RESOURCES`. -#' @param pars an [list] -#' @return a [list] -#' @export -SugarAvailability <- function(pars) { - UseMethod("SugarAvailability", pars$RESOURCES) -} - diff --git a/R/resources-null.R b/R/resources-null.R deleted file mode 100644 index d9f2d311..00000000 --- a/R/resources-null.R +++ /dev/null @@ -1,48 +0,0 @@ -#' @title Modify resources and resource availability -#' @description Implements [Resources] for the null model of resources -#' @inheritParams Resources -#' @return none -#' @export -Resources.null <- function(t, y, pars) { - return(pars) -} - -#' @title Compute availability of local humans for blood feeding -#' @description Compute the availability for the pathogen's hosts for blood feeding -#' @param t current simulation time -#' @param y state vector -#' @param pars a [list] -#' @return a [numeric] vector of length `nPatches` -#' @export -HumanAvailability.null <- function(t, y, pars){ - return(pars) -} - -#' @title Compute total availability of aquatic habitats -#' @description Computes the availability of aquatic habitats for the null model (do nothing) -#' @param pars a [list] -#' @return a [numeric] vector of length `nPatches` -#' @export -HabitatAvailability.null <- function(pars){ - return(pars) -} - -#' @title Compute total availability of sugar -#' @description Computes the availability of sugar for the null model (do nothing) -#' @param pars a [list] -#' @return a [numeric] vector of length `nPatches` -#' @export -SugarAvailability.null <- function(pars){ - return(pars) -} - -#' @title Set up parameters for the null model for resource availability -#' @param pars a [list] -#' @return none -#' @export -setup_resources_null<- function(pars){ - RESOURCES <- list() - class(RESOURCES) <- 'null' - pars$RESOURCES <- RESOURCES - return(pars) -} diff --git a/R/resources.R b/R/resources.R new file mode 100644 index 00000000..cca5e500 --- /dev/null +++ b/R/resources.R @@ -0,0 +1,105 @@ +# Methods to compute resource dynamics and availability + +#' @title Set the values of exogenous variables describing available mosquito resources +#' @description This method dispatches on the type of `pars$RESOURCES`. +#' @param t current simulation time +#' @param y vector of state variables +#' @param pars a [list] +#' @return none +#' @export +Resources <- function(t, y, pars) { + UseMethod("Resources", pars$RESOURCES) +} + +#' @title Modify resources and resource availability +#' @description Implements [Resources] for the null model of resources +#' @inheritParams Resources +#' @return none +#' @export +Resources.static <- function(t, y, pars) { + return(pars) +} + +#' @title Modify resources and resource availability +#' @description Implements [Resources] for the null model of resources +#' @inheritParams Resources +#' @return none +#' @export +Resources.setup <- function(t, y, pars) { + + pars = OtherBloodHosts(t, pars) + pars = AvailableBlood(t, y, pars) + + pars = HabitatDynamics(t, pars) + pars = AvailableHabitat(pars) + + pars = SugarDynamics(t, pars) + pars = AvailableSugar(pars) + + class(pars$RESOURCES) <- "static" + + return(pars) +} + +#' @title Methods for resources +#' @description Implements [Resources] +#' @inheritParams Resources +#' @return [list] +#' @export +Resources.forced <- function(t, y, pars) { + + pars = OtherBloodHosts(t, pars) + pars = AvailableBlood(t, y, pars) + + pars = HabitatDynamics(t, pars) + pars = AvailableHabitat(pars) + + pars = SugarDynamics(t, pars) + pars = AvailableSugar(pars) + + return(pars) +} + +#' @title Set up parameters for the null model for resource availability +#' @param pars a [list] +#' @return none +#' @export +setup_resources_null <- function(pars){ + RESOURCES <- list() + class(RESOURCES) <- 'static' + pars$RESOURCES <- RESOURCES + pars <- setup_other_blood_hosts_static(pars) + return(pars) +} + +#' @title Set up parameters for the null model for resource availability +#' @param pars a [list] +#' @return none +#' @export +setup_resources_static <- function(pars){ + RESOURCES <- list() + class(RESOURCES) <- 'setup' + pars$RESOURCES <- RESOURCES + + pars$vars$Q = list() + pars$vars$non_habitats = 0 + pars$vars$ovitraps = 0 + + pars = setup_sugar_static(pars) + pars = setup_other_blood_hosts_static(pars) + return(pars) +} + +#' @title Set up a model for mass medical +#' @param pars a [list] +#' @return [list] +#' @export +setup_resources_forced <- function(pars) { + pars = setup_control(pars) + RESOURCES <- list() + class(RESOURCES) <- 'forced' + pars$RESOURCES <- RESOURCES + pars = setup_sugar_static(pars) + pars = setup_other_blood_hosts_static(pars) + return(pars) +} diff --git a/R/setup.R b/R/setup.R index 04160a3b..1829b681 100644 --- a/R/setup.R +++ b/R/setup.R @@ -16,11 +16,12 @@ #' @param EIPname are the options to setup EIPmod #' @param EIPopts are the options to setup EIPmod #' @param Xopts a list to configure the X model -#' @param Hopts a list to configure the H model +#' @param BFopts a list to configure the blood feeding model #' @param residence is a vector that describes the patch where each human stratum lives #' @param searchB is a vector of search weights for blood feeding -#' @param TaR is either a TaR matrix or a string to call a function that sets it up -#' @param TaRopts are the options to setup TaR +#' @param F_circadian is a function describing mosquito daily activity +#' @param TimeSpent is either a TimeSpent matrix or a string to call a function that sets it up +#' @param TimeSpentOpts are the options to setup TimeSpent #' @param searchQ is a vector of search weights for egg laying #' @param Lopts a list to configure the L model #' @return a [list] @@ -48,11 +49,14 @@ xde_setup = function(modelName = "unnamed", # Human Strata / Options Xopts = list(), - Hopts = list(), + + # Blood Feeding + BFopts = list(), residence=1, searchB = 1, - TaR = "athome", - TaRopts=list(), + F_circadian = NULL, + TimeSpent = "athome", + TimeSpentOpts=list(), # Aquatic Mosquito Options searchQ = 1, @@ -70,27 +74,30 @@ xde_setup = function(modelName = "unnamed", # Fixed Structural Elements pars$nPatches = nPatches - pars$nStrata = length(HPop) pars$nVectors = nVectors pars$nHosts = nHosts pars$nHabitats = length(membership) pars$membership = membership pars$calN = make_calN(pars$nPatches, pars$membership) - pars = setup_Hpar(pars, HPop, residence, searchB, Hopts) - pars$Hpar[[1]]$TaR = make_TaR(nPatches, pars$Hpar$residence, TaR, TaRopts) + # Human Demography + pars = setup_Hpar_static(pars, 1, HPop) + + # Blood Feeding + pars = setup_BloodFeeding(pars, 1, 1, BFopts, residence, searchB, F_circadian) + pars = make_TimeSpent(pars, 1, TimeSpent, TimeSpentOpts) # Adult Mosquito Dynamics EIPmod = setup_EIP(EIPname, EIPopts) calK = make_calK(nPatches, calK, calKopts) - pars = setup_MYZpar(MYZname, pars, 1, MYZopts, EIPmod, calK) pars = setup_MYZinits(pars, 1, MYZopts) # Aquatic Mosquito Dynamics pars = setup_Lpar(Lname, pars, 1, Lopts) pars = setup_Linits(pars, 1, Lopts) - pars = setup_EggLaying(pars, 1, searchQ) + + pars = setup_EggLaying_static(pars, 1, searchQ) # Vertebrate Host Dynamics pars = setup_Xpar(Xname, pars, 1, Xopts) @@ -98,6 +105,11 @@ xde_setup = function(modelName = "unnamed", pars = make_indices(pars) + y0 <- get_inits(pars) + pars <- EggLaying(0, y0, pars) + pars <- Resources(0, y0, pars) + pars <- Bionomics(0, y0, pars) + pars <- Transmission(0, y0, pars) return(pars) } @@ -164,14 +176,13 @@ xde_setup_mosy = function(modelName = "unnamed", # Aquatic Mosquito Dynamics pars = setup_Lpar(Lname, pars, 1, Lopts) pars = setup_Linits(pars, 1, Lopts) - pars = setup_EggLaying(pars, 1, searchQ) + pars = setup_EggLaying_simple(pars, 1, searchQ) if(is.null(kappa)) kappa = rep(0, nPatches) pars$kappa[[1]] = checkIt(kappa, nPatches) pars = make_indices(pars) - return(pars) } @@ -212,12 +223,12 @@ xde_setup_aquatic = function(modelName = "unnamed", searchQ = rep(1, nHabitats) pars = setup_Lpar(Lname, pars, 1, Lopts) pars = setup_Linits(pars, 1, Lopts) - pars = setup_EggLaying(pars, 1, searchQ, Lopts) pars <- setup_lsm_null(pars) pars = make_indices(pars) + return(pars) } @@ -228,11 +239,12 @@ xde_setup_aquatic = function(modelName = "unnamed", #' @param HPop is the number of humans in each patch #' @param MYZopts a list to configure the MYZ model #' @param Xopts a list to configure the X model -#' @param Hopts a list to configure the H model +#' @param BFopts a list to configure the blood feeding model #' @param residence is a vector that describes the patch where each human stratum lives #' @param searchB is a vector of search weights for blood feeding -#' @param TaR is either a TaR matrix or a string to call a function that sets it up -#' @param TaRopts are the options to setup TaR +#' @param F_circadian is a function describing mosquito daily activity +#' @param TimeSpent is either a TimeSpent matrix or a string to call a function that sets it up +#' @param TimeSpentOpts are the options to setup TimeSpent #' @return a [list] #' @export xde_setup_human = function(modelName = "unnamed", @@ -248,11 +260,14 @@ xde_setup_human = function(modelName = "unnamed", # Human Strata / Options Xopts = list(), - Hopts = list(), + + # Blood Feeding + BFopts = list(), residence=1, searchB = 1, - TaR = "athome", - TaRopts=list() + F_circadian = NULL, + TimeSpent = "athome", + TimeSpentOpts=list() ){ @@ -269,8 +284,9 @@ xde_setup_human = function(modelName = "unnamed", pars$nPatches = as.integer(nStrata) pars$nStrata = nStrata - pars= setup_Hpar(pars, HPop, 1:nStrata, rep(1, nStrata), Hopts) - pars$Hpar$TaR = make_TaR(pars$nPatches, pars$Hpar$residence, TaR, TaRopts) + pars = setup_Hpar_static(pars, 1, HPop) + pars = setup_BloodFeeding(pars, 1, 1, BFopts, residence, searchB, F_circadian) + pars = make_TimeSpent(pars, 1, TimeSpent, TimeSpentOpts) # Dynamics pars = setup_MYZpar("Ztrace", pars, 1, MYZopts, EIPmod=NULL, calK=NULL) @@ -291,8 +307,8 @@ xde_setup_human = function(modelName = "unnamed", #' @param Xname is a character string defining a X model #' @param HPop is the number of humans in each patch #' @param searchB is a vector of search weights for blood feeding +#' @param residence is a vector that describes the patch where each human stratum lives #' @param Xopts a list to configure the X model -#' @param Hopts a list to configure the H model #' @return a [list] #' @export xde_setup_cohort = function(F_eir, @@ -304,10 +320,10 @@ xde_setup_cohort = function(F_eir, # Model Structure HPop=1000, searchB = 1, + residence = 1, # Human Strata / Options - Xopts = list(), - Hopts = list() + Xopts = list() ){ @@ -323,10 +339,10 @@ xde_setup_cohort = function(F_eir, # Structure nStrata = length(HPop) pars$nPatches = as.integer(nStrata) - pars$nStrata = nStrata pars$nHosts = 1 - pars = setup_Hpar(pars, HPop, 1:nStrata, searchB, Hopts) + pars = setup_Hpar_static(pars, 1, HPop) + pars = setup_BloodFeeding(pars, 1, 1, list(), residence, searchB, NULL) # Dynamics pars = setup_Xpar(Xname, pars, 1, Xopts) diff --git a/R/solving.R b/R/solving.R index ff45335b..b07a6974 100644 --- a/R/solving.R +++ b/R/solving.R @@ -53,7 +53,7 @@ xde_solve.ode = function(pars, Tmax=365, dt=1){ #' @title Solve a system of equations as a dde #' @description Implements [xde_solve] for delay differential equations #' @inheritParams xde_solve -#' @return a [list] +#'@return a [list] #' @export xde_solve.dde = function(pars, Tmax=365, dt=1){ tt = seq(0, Tmax, by=dt) @@ -70,7 +70,6 @@ xde_solve.dde = function(pars, Tmax=365, dt=1){ #' @export xde_solve.aqua = function(pars, Tmax=365, dt=1){ tt = seq(0, Tmax, by=dt) - #y0 = get_inits_L(pars, 1) y0 = get_inits(pars) deSolve::ode(y = y0, times = tt, func = xDE_diffeqn_aquatic, parms = pars, method = "lsoda") -> out pars$outputs$orbits = parse_deout(out, pars) @@ -84,7 +83,7 @@ xde_solve.aqua = function(pars, Tmax=365, dt=1){ #' @export xde_solve.aqua_dde = function(pars, Tmax=365, dt=1){ tt = seq(0, Tmax, by=dt) - y0 = get_inits_L(pars, 1) + y0 = get_inits(pars) deSolve::dede(y = y0, times = tt, func = xDE_diffeqn_aquatic, parms = pars, method = "lsoda") -> out pars$outputs$orbits = parse_deout(out, pars) return(pars) diff --git a/R/sugar.R b/R/sugar_dynamics.R similarity index 53% rename from R/sugar.R rename to R/sugar_dynamics.R index 83c71ee1..cb87123d 100644 --- a/R/sugar.R +++ b/R/sugar_dynamics.R @@ -6,27 +6,30 @@ #' @param pars a [list] #' @return [list] #' @export -Sugar <- function(t, pars) { - UseMethod("Sugar", pars$SUGAR) +SugarDynamics <- function(t, pars) { + UseMethod("SugarDynamics", pars$SUGAR) } #' @title Set the values of exogenous variables describing sugar -#' @description Implements [Sugar] for the null model of sugar (do nothing) -#' @inheritParams Sugar +#' @description Implements [SugarDynamics] for the static model of sugar (do nothing) +#' @inheritParams SugarDynamics #' @return [list] #' @export -Sugar.null <- function(t, pars) { +SugarDynamics.static <- function(t, pars) { return(pars) } -#' @title Make parameters for the null model for sugar (do nothing) +#' @title Make parameters for the static model for sugar (do nothing) #' @param pars a [list] +#' @param Sugar describes sugar availability #' @return [list] #' @export -setup_sugar_null <- function(pars) { +setup_sugar_static <- function(pars, Sugar=0) { SUGAR <- list() - class(SUGAR) <- 'null' + class(SUGAR) <- 'static' pars$SUGAR <- SUGAR + pars$vars$Sugar = Sugar return(pars) } + diff --git a/R/time_at_risk.R b/R/time_at_risk.R deleted file mode 100644 index fec10f93..00000000 --- a/R/time_at_risk.R +++ /dev/null @@ -1,83 +0,0 @@ - -#' @title Make a mosquito dispersal matrix, called TaR -#' @param nPatches is the number of patches -#' @param residence is the residence vector -#' @param TaR a matrix; or a string -#' @param opts a list of options to configure TaR -#' @return a [matrix] -#' @export -make_TaR = function(nPatches, residence, TaR, opts = list()){ - if(is.matrix(TaR)) class(opts) <- "as_matrix" - if(is.character(TaR)) class(opts)<- TaR - UseMethod("make_TaR", opts) -} - -#' @title Make a mosquito dispersal matrix, called TaR with a here / away -#' @description Implements [make_TaR] for as_matrix -#' @inheritParams make_TaR -#' @return a [matrix] -#' @export -make_TaR.athome = function(nPatches, residence, TaR = "athome", opts = list()){ - with(opts,make_TaR_athome(nPatches, residence, opts)) -} - -#' @title Make a mosquito dispersal matrix, called TaR -#' @param nPatches is the number of patches -#' @param residence is the home patch for each stratum -#' @param atHome is the fraction of time spent at home -#' @param opts is a set of options that overwrites the defaults -#' @param travel is the fraction of time spent traveling -#' @return a [matrix] -#' @export -make_TaR_athome = function(nPatches, residence, opts=list(), atHome=1, travel=0) {with(opts,{ - nStrata = length(residence) - away = ifelse(nPatches == 1, 0, (1-atHome-travel)/(nPatches-1)) - atHome = ifelse(nPatches == 1, 1-travel, atHome) - TiSp <- matrix(away, nPatches, length(residence)) - TiSp[cbind(residence, c(1:nStrata))] <- atHome - return(TiSp) -})} - -#' @title Pass a pre-configured TaR -#' @description Implements [make_TaR] for as_matrix -#' @inheritParams make_TaR -#' @return a [matrix] -#' @export -make_TaR.as_matrix = function(nPatches, residence, TaR, opts=list()){ - return(TaR) -} - -#' @title Develop a mosquito dispersal matrix from a kernel and xy-coordinates -#' @description Implements [make_TaR] for kernels -#' @inheritParams make_TaR -#' @return a [matrix] -#' @export -make_TaR.xy = function(nPatches, residence, TaR = "xy", opts=list()) { - with(opts,make_TaR_xy(xy, residence, kern, stay, travel)) -} - -#' @title Make a mosquito dispersal matrix, called TaR -#' @param xy is the xy-locations of the patches -#' @param residence is the home patch for each stratum -#' @param kern is a function that gives weight by distance -#' @param stay is the fraction of time spent at home -#' @param travel is the fraction of time spent traveling -#' @return a [matrix] -#' @export -make_TaR_xy = function(xy, residence, kern, stay, travel) { - nPatches = dim(xy)[1] - nStrata = length(residence) - stopifnot(length(stay)==nStrata) - stopifnot(length(travel)==nStrata) - TaR = matrix(0, nPatches, nStrata) - for(i in 1:nStrata){ - j = residence[i] - dd = sqrt((xy[j,1] - xy[,1])^2 + (xy[j,2] - xy[,2])^2) - wts = kern(dd) - wts[j] = 0 - wts = (1-stay[i]-travel[i])*wts/sum(wts[-j]) - wts[j] = stay[i] - TaR[,i] = wts - } - return(TaR) -} diff --git a/R/time_spent.R b/R/time_spent.R new file mode 100644 index 00000000..184147f5 --- /dev/null +++ b/R/time_spent.R @@ -0,0 +1,95 @@ + +#' @title Make a time spent matrix, called TimeSpent +#' @param pars an [list] +#' @param i the host species index +#' @param TimeSpent a matrix; or a string +#' @param opts a list of options to configure TimeSpent +#' @return a [list] +#' @export +make_TimeSpent = function(pars, i, TimeSpent, opts = list()){ + if(is.matrix(TimeSpent)) class(opts) <- "as_matrix" + if(is.character(TimeSpent)) class(opts) <- TimeSpent + UseMethod("make_TimeSpent", opts) +} + +#' @title Make a mosquito dispersal matrix, called TimeSpent with a here / away +#' @description Implements [make_TimeSpent] for as_matrix +#' @inheritParams make_TimeSpent +#' @return a [list] +#' @export +make_TimeSpent.athome = function(pars, i, TimeSpent = "athome", opts = list()){ + + residence = pars$BFpar$residence[[i]] + TiSp = make_TimeSpent_athome(pars$nPatches, residence, opts) + pars$BFpar$TimeSpent[[i]] = TiSp + for(s in 1:pars$nVectors) pars = make_TaR(t, pars, i, s) + + return(pars) +} + +#' @title Make a mosquito dispersal matrix, called TimeSpent +#' @param nPatches is the number of patches +#' @param residence is the home patch for each stratum +#' @param atHome is the fraction of time spent at home +#' @param opts is a set of options that overwrites the defaults +#' @param travel is the fraction of time spent traveling +#' @return a [matrix] +#' @export +make_TimeSpent_athome = function(nPatches, residence, opts=list(), atHome=1, travel=0) {with(opts,{ + nStrata = length(residence) + away = ifelse(nPatches == 1, 0, (1-atHome-travel)/(nPatches-1)) + atHome = ifelse(nPatches == 1, 1-travel, atHome) + TiSp <- matrix(away, nPatches, length(residence)) + TiSp[cbind(residence, c(1:nStrata))] <- atHome + return(TiSp) +})} + +#' @title Pass a pre-configured TimeSpent +#' @description Implements [make_TimeSpent] for as_matrix +#' @inheritParams make_TimeSpent +#' @return a [list] +#' @export +make_TimeSpent.as_matrix = function(pars, i, TimeSpent, opts=list()){ + pars$BFpar$TimeSpent[[i]] = TimeSpent + for(s in 1:pars$nVectors) pars = make_TaR(t, pars, i, s) + return(pars) +} + +#' @title Develop a mosquito dispersal matrix from a kernel and xy-coordinates +#' @description Implements [make_TimeSpent] for kernels +#' @inheritParams make_TimeSpent +#' @return a [list] +#' @export +make_TimeSpent.xy = function(pars, i, TimeSpent = "xy", opts=list()) { + residence = pars$BFpar[[i]]$residence + TiSp = with(opts, make_TimeSpent_xy(xy, residence, kern, stay, travel)) + pars$BFpar$TimeSpent[[i]] = TiSp + for(s in 1:pars$nVectors) pars = make_TaR(t, pars, i, s) + return(pars) +} + +#' @title Make a mosquito dispersal matrix, called TimeSpent +#' @param xy is the xy-locations of the patches +#' @param residence is the home patch for each stratum +#' @param kern is a function that gives weight by distance +#' @param stay is the fraction of time spent at home +#' @param travel is the fraction of time spent traveling +#' @return a [matrix] +#' @export +make_TimeSpent_xy = function(xy, residence, kern, stay, travel) { + nPatches = dim(xy)[1] + nStrata = length(residence) + stopifnot(length(stay)==nStrata) + stopifnot(length(travel)==nStrata) + TimeSpent = matrix(0, nPatches, nStrata) + for(i in 1:nStrata){ + j = residence[i] + dd = sqrt((xy[j,1] - xy[,1])^2 + (xy[j,2] - xy[,2])^2) + wts = kern(dd) + wts[j] = 0 + wts = (1-stay[i]-travel[i])*wts/sum(wts[-j]) + wts[j] = stay[i] + TimeSpent[,i] = wts + } + return(TimeSpent) +} diff --git a/R/transmission.R b/R/transmission.R index b87de930..27d563c1 100644 --- a/R/transmission.R +++ b/R/transmission.R @@ -1,55 +1,136 @@ # Compute the Transmission Terms -#' @title Compute the biting distribution matrix, beta -#' @description This method dispatches on the type of `pars$xde` +#' @title Compute transmission terms dynamically +#' @description This method dispatches on the type of `pars$BFpar` #' @param t current simulation time #' @param y state vector #' @param pars, a [list] #' @return [list] #' @export Transmission <- function(t, y, pars){ + UseMethod("Transmission", pars$BFpar) +} + +#' @title Compute transmission terms dynamically, no update required +#' @description This method dispatches on the type of `pars$BFpar` +#' @inheritParams Transmission +#' @return [list] +#' @export +Transmission.static <- function(t, y, pars){ + + pars = compute_EIR(t, y, pars) + pars = compute_kappa(t, y, pars) + + return(pars) +} + +#' @title Compute transmission terms, the dynamic case +#' @description This method dispatches on the type of `pars$BFpar` +#' @inheritParams Transmission +#' @return [list] +#' @export +Transmission.dynamic <- function(t, y, pars){ + + pars = LocalFrac(pars) + pars = compute_beta(t, y, pars) + pars = compute_EIR(t, y, pars) + pars = compute_kappa(t, y, pars) + + return(pars) +} + +#' @title Compute transmission terms, the dynamic case +#' @description This method dispatches on the type of `pars$BFpar` +#' @inheritParams Transmission +#' @return [list] +#' @export +Transmission.setup <- function(t, y, pars){ + + pars = setup_local_fraction_simple(pars) + for(s in 1:pars$nVectors) + pars = compute_AvailableHosts(t, y, pars, s) + pars = compute_beta(t, y, pars) + pars = compute_EIR(t, y, pars) + pars = compute_kappa(t, y, pars) + + class(pars$BFpar) <- "static" + return(pars) +} - # beta: mixing - for(i in 1:pars$nHosts) - for(s in 1:pars$nVectors) - pars$beta[[i]][[s]] <- F_beta(t, y, pars, s, i) +#' @title Compute beta +#' @description This function computes the mixing matrix, beta +#' @param t current simulation time +#' @param y state vector +#' @param pars, a [list] +#' @return [list] +#' @export +compute_beta <- function(t, y, pars){ - # EIR: entomological inoculation rate for(i in 1:pars$nHosts){ - pars$EIR[[i]] <- 0*F_EIR(t, y, pars, pars$beta[[i]][[1]], 1) + H = F_H(t, y, pars, i) for(s in 1:pars$nVectors){ -# pars$eir[[i]][[s]] <- F_EIR(t, y, pars, pars$beta[[i]][[s]], s) -# pars$EIR[[i]] <- pars$EIR[[i]] + pars$eir[[i]][[s]] - pars$EIR[[i]] <- pars$EIR[[i]] + F_EIR(t, y, pars, pars$beta[[i]][[s]], s) + W = pars$vars$W[[s]] + wts = pars$BFpar$searchWts[[i]][[s]] + TaR = pars$BFpar$TaR[[i]][[s]] + pars$beta[[i]][[s]] <- F_beta(H, W, wts, TaR) } - pars$EIR[[i]] = pars$EIR[[i]]*pars$local_frac } - for(s in 1:pars$nVectors){ - pars$kappa[[s]] <- 0* F_kappa(t, y, pars, pars$beta[[1]][[s]], 1) - for(i in 1:pars$nHosts){ -# pars$ni[[i]][[s]] <- F_kappa(t, y, pars, pars$beta[[i]][[s]], i) -# pars$kappa[[s]] <- pars$kappa[[s]] + W[[i]]/Wtot*pars$ni[[i]][[s]] - pars$kappa[[s]] <- pars$kappa[[s]] + F_kappa(t, y, pars, pars$beta[[i]][[s]], i) + return(pars) +} + +#' @title Compute beta, the biting distribution matrix +#' @param H human / host population density +#' @param W human / host availability in the patches +#' @param wts_f the blood feeding search weights +#' @param TaR (time at risk), a [matrix] dimensions `nPatches` by `nStrata` +#' @return a [matrix] of dimensions `nStrata` by `nPatches` +#' @export +F_beta = function(H, W, wts_f, TaR){ + beta = diag(wts_f, length(H)) %*% t(TaR) %*% diag(1/W, length(W)) + return(beta) +} + +#' @title Compute EIR +#' @description This function computes the EIR for each stratum of each host species +#' @param t current simulation time +#' @param y state vector +#' @param pars, a [list] +#' @return [list] +#' @export +compute_EIR <- function(t, y, pars){ + + for(i in 1:pars$nHosts){ + pars$EIR[[i]] <- F_EIR(t, y, pars, i, 1) + if(pars$nVectors > 1) + for(s in 2:pars$nVectors){ + pars$EIR[[i]] <- pars$EIR[[i]] + F_EIR(t, y, pars, i, s) } - pars$kappa[[s]] = with(pars, local_frac*kappa[[s]] + (1-local_frac)*x_visitors) } + return(pars) } -#' @title Compute the biting distribution matrix, beta -#' @description This method dispatches on the type of `pars$xde` +#' @title Compute EIR for each vector-host pair +#' @description This function computes the EIR from each vector species for each stratum of each host species #' @param t current simulation time #' @param y state vector -#' @param pars, a [list] -#' @param s the vector species index -#' @param i the host species index +#' @param pars a [list] #' @return [list] #' @export -F_beta <- function(t, y, pars, s, i){ - H <- F_H(t, y, pars, i) - beta = compute_beta(H, pars$Hpar[[i]]$wts_f, pars$Hpar[[i]]$TaR) - return(beta) +compute_EIR_full <- function(t, y, pars){ + + for(i in 1:pars$nHosts){ + pars$eir[[i]][[1]] <- F_EIR(t, y, pars, i, 1) + pars$EIR[[i]] <- pars$EIR[[i]] + pars$eir[[i]][[1]] + if(s>1) + for(s in 2:pars$nVectors){ + pars$eir[[i]][[s]] <- F_EIR(t, y, pars, i, s) + pars$EIR[[i]] <- pars$EIR[[i]] + pars$eir[[i]][[s]] + } + } + + return(pars) } #' @title Entomological inoculation rate on human strata @@ -57,13 +138,41 @@ F_beta <- function(t, y, pars, s, i){ #' @param t current simulation time #' @param y state vector #' @param pars a [list] -#' @param beta, a [matrix] +#' @param i the host species index #' @param s the vector species index #' @return [numeric] vector of length `nStrata` #' @export -F_EIR <- function(t, y, pars, beta, s) { +F_EIR <- function(t, y, pars, i, s) { + fqZ <- F_fqZ(t, y, pars, s) - return(as.vector(beta %*% fqZ)) + beta <- pars$beta[[i]][[s]] + lf <- pars$vars$local_frac[[s]] + eir = beta %*% (fqZ*lf) + + return(as.vector(eir)) +} + +#' @title Compute kappa +#' @description This function computes kappa for each vector species in each patch +#' @param t current simulation time +#' @param y state vector +#' @param pars a [list] +#' @return [list] +#' @export +compute_kappa <- function(t, y, pars){ + + for(s in 1:pars$nVectors){ + kappa <- F_kappa(t, y, pars, 1, s) + + if(pars$nHosts>1) + for(i in 2:pars$nHosts) + kappa <- kappa + F_kappa(t, y, pars, i, s) + + kappa = with(pars$vars, local_frac[[s]]*kappa + (1-local_frac[[s]])*x_visitors[[s]]) + pars$kappa[[s]] = kappa + } + + return(pars) } #' @title Net infectiousness of human population to mosquitoes @@ -71,25 +180,16 @@ F_EIR <- function(t, y, pars, beta, s) { #' @param t current simulation time #' @param y state vector #' @param pars a [list] -#' @param beta, a [matrix] #' @param i the host species index +#' @param s the vector species index #' @return a [numeric] vector of length `nPatches` #' @export -F_kappa <- function(t, y, pars, beta, i) { - if(i>1) browser() - kappa = as.vector(t(beta) %*% F_X(t, y, pars, i)) -# kappa = pars$HostAvailability[[i]]/pars$Wtot*as.vector(t(beta) %*% F_X(t, y, pars, i)) - return(kappa) -} +F_kappa <- function(t, y, pars, i, s) { -#' @title Compute beta, the biting distribution matrix -#' @param H the human population size -#' @param wts_f the blood feeding search weights -#' @param TaR (time at risk), a [matrix] dimensions `nPatches` by `nStrata` -#' @return a [matrix] of dimensions `nStrata` by `nPatches` -#' @export -compute_beta = function(H, wts_f, TaR){ - W <- as.vector(TaR %*% (wts_f*H)) - beta <- diag(wts_f, length(H)) %*% t(TaR) %*% diag(1/W, length(W)) - return(beta) + beta = pars$beta[[i]][[s]] + Wi = pars$vars$Wi[[i]][[s]] + W = pars$vars$W[[s]] + kappa = Wi/W*(as.vector(t(beta) %*% F_X(t, y, pars, i))) + + return(as.vector(kappa)) } diff --git a/R/travel_malaria-null.R b/R/travel_malaria-null.R deleted file mode 100644 index a22785d9..00000000 --- a/R/travel_malaria-null.R +++ /dev/null @@ -1,24 +0,0 @@ -# specialized methods for a null model of travel malaria - -#' @title travel, a null model -#' @description Implements [travel_malaria] for the null model (do nothing) -#' @inheritParams travel_malaria -#' @return a [numeric] -#' @export -travel_malaria.null <- function(t, pars) { - return(0) -} - -#' @title A function to set up malaria importation -#' @description Setup a null model for travel malaria -#' @param pars a [list] -#' @return a [list] -#' @export -setup_travel_null = function(pars){ - - TRAVEL <- list() - class(TRAVEL) <- 'null' - pars$TRAVEL <- TRAVEL - - return(pars) -} diff --git a/R/travel_malaria-static.R b/R/travel_malaria-static.R new file mode 100644 index 00000000..255a7a9f --- /dev/null +++ b/R/travel_malaria-static.R @@ -0,0 +1,24 @@ +# specialized methods for a static model of travel malaria + +#' @title travel, a static model +#' @description Implements [travel_malaria] for the static model (do nothing) +#' @inheritParams travel_malaria +#' @return a [numeric] +#' @export +travel_malaria.static <- function(t, pars) { + return(pars$vars$delta) +} + +#' @title A function to set up malaria importation +#' @description Setup a static model for travel malaria +#' @param pars a [list] +#' @param delta the travel FoI +#' @return a [list] +#' @export +setup_travel_static = function(pars, delta=0){ + TRAVEL <- list() + class(TRAVEL) <- 'static' + pars$TRAVEL <- TRAVEL + pars$vars$delta = delta + return(pars) +} diff --git a/R/utils.R b/R/utils.R index fec25c25..eae5785e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -10,50 +10,41 @@ make_parameters_xde = function(solve_as='dde'){ class(xde) <- xde pars$xde = xde - static_l = list() - class(static_l) <- "static" - pars$MYZpar = list() - pars$MYZinits = list() - pars$Lpar = list() - pars$Linits = list() - pars$Xpar = list() - pars$Xinits = list() pars$Hpar = list() + pars$vars = list() - pars$search4habitat = list() - pars$calU = static_l - pars$eta = list() pars$Lambda = list() - pars$HostAvailability = list() - pars$beta = list() - pars$beta[[1]] = list() -# pars$eir = list() -# pars$eir[[1]] = list() - pars$EIR = list() - pars$FoI = list() -# pars$ni = list() -# pars$ni[[1]] = list() - pars$kappa = list() + pars <- setup_EGGpar_static(pars) + pars <- setup_BFpar_static(pars) + + pars$Linits = list() + pars$MYZinits = list() + pars$Xinits = list() pars$ix = list() pars$ix$X = list() pars$ix$MYZ = list() pars$ix$L = list() + pars$outputs = list() pars$compute = list() + pars$HostAvailability = list() + pars <- setup_abiotic_null(pars) pars <- setup_shock_null(pars) pars <- setup_control_null(pars) pars <- setup_vc_null(pars) pars <- setup_behavior_null(pars) - pars <- setup_visitors_null(pars) + pars <- setup_habitat_dynamics_static(pars) + pars <- setup_bionomics_static(pars) + pars <- setup_visitors_static(pars) pars <- setup_resources_null(pars) - pars <- setup_travel_null(pars) + pars <- setup_travel_static(pars) pars <- setup_exposure_pois(pars) return(pars) diff --git a/R/visitors.R b/R/visitors.R index 6fe26295..7dc7dede 100644 --- a/R/visitors.R +++ b/R/visitors.R @@ -10,28 +10,34 @@ Visitors <- function(t, pars) { UseMethod("Visitors", pars$VISITORS) } -#' @title Visitors, a null model -#' @description Implements [Visitors] for the null model (do nothing) +#' @title Visitors, a static model +#' @description Implements [Visitors] for the static model (do nothing) #' @inheritParams Visitors #' @return a [list] #' @export -Visitors.null <- function(t, pars) { +Visitors.static <- function(t, pars) { return(pars) } -#' @title Make parameters for the null model visitors (no visitors) +#' @title Make parameters for the static model visitors (no visitors) #' @param pars a [list] +#' @param local_frac is the fraction of humans / hosts that are not visitors +#' @param Visitors is the availability of visitors +#' @param x_visitors is the net infectiousness of the visitors #' @return [list] #' @export -setup_visitors_null <- function(pars) { +setup_visitors_static <- function(pars, local_frac=1, Visitors=0, x_visitors=0) { VISITORS <- list() - class(VISITORS) <- 'null' + class(VISITORS) <- "static" pars$VISITORS <- VISITORS - pars$local_frac = 1 - pars$Visitors = 0 - pars$x_visitors = 0 + pars$vars$local_frac = list() + pars$vars$local_frac[[1]] = local_frac + pars$vars$Visitors = list() + pars$vars$Visitors[[1]] = Visitors + pars$vars$x_visitors = list() + pars$vars$x_visitors[[1]] = x_visitors return(pars) } @@ -43,8 +49,8 @@ setup_visitors_null <- function(pars) { #' @return a [list] #' @export Visitors.basic <- function(t, pars) { - pars$x_visitors = with(pars$VISITORS, x_scale*xt(t, pars)) - pars$Visitors = with(pars$VISITORS, V_scale*Vt(t, pars)) + pars$vars$x_visitors = with(pars$VISITORS, x_scale*xt(t, pars)) + pars$vars$Visitors = with(pars$VISITORS, V_scale*Vt(t, pars)) return(pars) } diff --git a/_pkgdown.yml b/_pkgdown.yml index ffb6bf78..dfddd219 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -57,23 +57,96 @@ home: title: Changelog text: News reference: -- title: Derivatives functions +- title: Blood Feeding and Transmission + desc: | + Methods to compute the transmission terms contents: - - xDE_diffeqn - - xDE_diffeqn_aquatic - - xDE_diffeqn_mosy - - xDE_diffeqn_human - - xDE_diffeqn_cohort -- title: Transmission + - Transmission + - Exposure + - LocalFrac + - AvailableBlood +- subtitle: Transmision desc: | - Generic methods for transmission. + Specialized methods to compute the transmission terms contents: + - Transmission.static + - Transmission.dynamic + - Transmission.setup - F_beta + - compute_beta - F_EIR + - compute_EIR + - compute_EIR_full - F_kappa - - compute_beta - - Transmission - - Exposure + - compute_kappa +- subtitle: Blood Feeding + desc: | + Method to set up the blood feeding model + contents: + - setup_BFpar_static + - setup_BloodFeeding + - make_TaR +- subtitle: Time Spent and Time at Risk + desc: | + Method to set up time spent and time at risk (TaR) matrices + contents: + - make_TimeSpent + - make_TimeSpent.athome + - make_TimeSpent_athome + - make_TimeSpent.as_matrix + - make_TimeSpent.xy + - make_TimeSpent_xy +- subtitle: Availability of humans / hosts + desc: | + Specialized methods to compute available humans / hosts + contents: + - AvailableBlood.static + - AvailableBlood.setup + - AvailableBlood.forced + - compute_AvailableHosts +- subtitle: Exposure + desc: | + Methods to model the force of infection + contents: + - F_foi +- subtitle: Poisson Exposure + desc: | + Specialized methods the Poisson exposure model + contents: + - F_foi.pois + - setup_exposure_pois +- subtitle: Negative Binomial Exposure + desc: | + Specialized methods the Negative Binomial exposure model + contents: + - F_foi.nb + - setup_exposure_nb +- subtitle: Local Fraction + desc: | + Specialized methods for NULL dynamics: a funtion generates values of Z to force human infection dynamics + contents: + - LocalFrac.static + - LocalFrac.dynamic + - compute_local_frac + - setup_local_fraction_simple +- title: Egg Laying & Emergence + desc: | + Generic methods for the aquatic (immature) mosquito component. + contents: + - Emergence + - make_calN + - EggLaying + - EggLaying.static + - EggLaying.dynamic + - EggLaying.simple + - EggLaying.setup + - compute_calU + - compute_EggsLaid + - make_calU + - make_calU_s + - setup_EggLaying_static + - setup_EggLaying_simple + - setup_EGGpar_static - title: Adult Mosquito Dynamics desc: | Generic methods for the adult mosquito dynamics component. @@ -218,44 +291,6 @@ reference: - update_inits_MYZ.GeRM_ode - update_inits_MYZ.GeRM_dde - make_parameters_MYZ_GeRM -- title: Mosquito Bionomic Functional Responses - desc: | - Compute bionomic parameters as functional responses to resource availability - contents: - - F_sigma - - F_sigma.static - - F_sigma.BQS - - F_nu - - F_nu.static - - F_nu.type2 - - F_f - - F_f.static - - F_f.type2 - - F_q - - F_q.static - - F_q.dynamic - - F_g - - F_g.static -- title: Mosquito Dispersal - desc: | - Specialized methods to set up mosquito dispersal matrices - contents: - - make_calK - - make_calK.herethere - - make_calK.as_matrix - - make_calK.xy - - make_calK_xy -- title: Mosquito Ecology - desc: | - Generic methods for the aquatic (immature) mosquito component. - contents: - - Bionomics - - HabitatSearch - - HabitatSearch.static - - HabitatSearch.dynamic - - EggLaying - - setup_EggLaying - - Emergence - title: Aquatic Mosquito Dynamics desc: | Generic methods for the aquatic (immature) mosquito component. @@ -269,8 +304,6 @@ reference: - parse_deout_L - get_inits_L - update_inits_L - - make_calN - - make_calU - subtitle: trace desc: | Specialized methods for the exogeneously forced trace model of aquatic mosquito dynamics. @@ -304,6 +337,44 @@ reference: - get_inits_L.basic - update_inits_L.basic - make_parameters_L_basic +- title: Mosquito Bionomics + desc: | + Methods to compute or update mosquito bionomic parameters + contents: + - Bionomics + - Bionomics.static + - Bionomics.dynamic + - Bionomics.Ldynamic + - Bionomics.Mdynamic + - Bionomics.setup + - setup_bionomics_static +- subtitle: Functional Responses + desc: | + Compute bionomic parameters as functional responses to resource availability + contents: + - F_sigma + - F_sigma.static + - F_sigma.BQS + - F_nu + - F_nu.static + - F_nu.type2 + - F_f + - F_f.static + - F_f.type2 + - F_q + - F_q.static + - F_q.dynamic + - F_g + - F_g.static +- subtitle: Mosquito Dispersal + desc: | + Specialized methods to set up mosquito dispersal matrices + contents: + - make_calK + - make_calK.herethere + - make_calK.as_matrix + - make_calK.xy + - make_calK_xy - title: Human Infection Dynamics desc: | Generic methods for the dynamical component that handles human infection dynamics, immunity, disease and transmission @@ -408,7 +479,7 @@ reference: Generic methods for the human demography and aging contents: - dHdt - - setup_Hpar + - setup_Hpar_static - Births - make_parameters_demography_null - make_Hpar_trace @@ -418,17 +489,7 @@ reference: contents: - Births.zero - dHdt.zero -- title: Time at Risk - desc: | - Method to set up time at risk (TaR) matrices - contents: - - make_TaR - - make_TaR.athome - - make_TaR_athome - - make_TaR.as_matrix - - make_TaR.xy - - make_TaR_xy -- title: Human and Mosqutio Behaviors +- title: Human and Mosquito Behaviors desc: | Methods to implement human and Mosquito Behaviorsbehaviors contents: @@ -447,58 +508,28 @@ reference: - CareSeeking - CareSeeking.null - setup_care_seeking_null -- title: Exposure - desc: | - Methods to implement exposure models (i.e., EIR to FoI) - contents: F_foi -- subtitle: Poisson - desc: | - Specialized methods the default model (Poisson) - contents: - - F_foi.pois - - setup_exposure_pois -- subtitle: nb - desc: | - Specialized methods the negative binomial model - contents: - - F_foi.nb - - setup_exposure_nb -- title: Travel Malaria +- title: Imported Malaria desc: | - Methods to implement exposure to malaria while traveling - contents: travel_malaria -- subtitle: null model - desc: | - Specialized methods the null travel malaria model + Methods to implement imported malaria contents: - - travel_malaria.null - - setup_travel_null -- subtitle: FoI + - travel_malaria + - Visitors +- subtitle: Travel Malaria desc: | - Specialized methods the foi-based travel malaria model + Specialized methods for travel malaria contents: + - travel_malaria.static + - setup_travel_static - travel_malaria.foi - setup_travel_foi -- subtitle: EIR - desc: | - Specialized methods the eir-based travel malaria model - contents: - travel_malaria.eir - setup_travel_eir -- title: Visitors - desc: | - Methods to implement malaria importation through visitors - contents: Visitors -- subtitle: null model - desc: | - Specialized methods for a null model for visitors (do nothing) - contents: - - Visitors.null - - setup_visitors_null -- subtitle: basic +- subtitle: Visitors desc: | - Specialized methods for a basic model of malaria visitorsation + Methods for the availability and infectiousness of a visitor population contents: + - Visitors.static + - setup_visitors_static - Visitors.basic - setup_visitors_basic - title: Exogeneous Forcing @@ -512,7 +543,7 @@ reference: - Clinic - Development - MassMedical -- subtitle: null model +- subtitle: Models desc: | Specialized methods the null model (no exogenous forcing) contents: @@ -524,8 +555,8 @@ reference: - setup_shock_null - Control.null - Control.static - - setup_control_null - setup_control + - setup_control_null - setup_control.null - setup_control.forced - Clinic.null @@ -578,46 +609,46 @@ reference: - Hydrology - Hydrology.null - setup_hydrology_null -- title: Resources and Availability +- title: Resource Dynamics desc: | Methods to implement resource availability contents: - Resources - - HumanAvailability - - HabitatAvailability - - SugarAvailability - - Resources.null - - HumanAvailability.null - - HabitatAvailability.null - - SugarAvailability.null + - Resources.static + - Resources.setup - Resources.forced - - HumanAvailability.forced - - HabitatAvailability.forced - - SugarAvailability.forced - setup_resources_null + - setup_resources_static - setup_resources_forced - - compute_local_frac - subtitle: Other Blood Hosts desc: | Methods to simulate availability of other blood hosts contents: - OtherBloodHosts - - OtherBloodHosts.null - - setup_other_blood_hosts_null -- subtitle: Habitat Dynamics + - OtherBloodHosts.static + - setup_other_blood_hosts_static +- subtitle: Habitat Dynamics and Availability desc: | - Methods to implement habitat dynamics + Specialized methods for weather contents: + - AvailableHabitat + - AvailableHabitat.static + - AvailableHabitat.simple + - AvailableHabitat.forced + - compute_AvailableHabitat - HabitatDynamics - - HabitatDynamics.null - - setup_habitat_dynamics_null + - HabitatDynamics.static + - setup_habitat_dynamics_static - subtitle: Sugar desc: | Methods to simulate availability of sugar contents: - - Sugar - - Sugar.null - - setup_sugar_null + - SugarDynamics + - SugarDynamics.static + - setup_sugar_static + - AvailableSugar + - AvailableSugar.static + - AvailableSugar.forced - title: Vector Control desc: | Methods to implement vector control. @@ -709,20 +740,42 @@ reference: - OviTraps - OviTraps.null - setup_ovitraps_null -- title: Spatial metrics - contents: - - metric_calV - - metric_calD - - metric_calR - - metric_calZ + - title: Setup + desc: | + Basic setup for models + contents: + - make_parameters_xde + - make_indices +- subtitle: Setting Up + desc: | + Methods to set up basic models contents: - xde_setup - xde_setup_aquatic - xde_setup_mosy - xde_setup_human - xde_setup_cohort +- subtitle: Initial Values + desc: | + Methods to set up basic models + contents: + - get_inits + - update_inits + - last_to_inits - title: Solving + desc: | + Methods to compute the derivatives and solve the equat +- subtitle: Derivatives + contents: + - xDE_diffeqn + - xDE_diffeqn_aquatic + - xDE_diffeqn_mosy + - xDE_diffeqn_human + - xDE_diffeqn_cohort +- subtitle: Solving + desc: | + Wrappers around the derivatives functions that handle time and parse outputs contents: - xde_solve - xde_solve.dde @@ -735,21 +788,21 @@ reference: - xde_solve.cohort - xde_stable_orbit - xde_steady -- title: Utilities +- title: Analysis and Visualization + desc: | + Methods to compute and output terms +- subtitle: Spatial metrics + contents: + - metric_calV + - metric_calD + - metric_calR + - metric_calZ +- subtitle: Compute terms + desc: | + Methods to compute and transmission terms contents: - - make_parameters_xde - - make_indices - parse_deout - parse_deout_vec - - get_inits - - update_inits - - last_to_inits - - diag_inverse - - approx_equal - - checkIt - - shapeIt -- title: Compute terms - contents: - compute_terms - compute_terms.xde - compute_terms.cohort @@ -762,7 +815,9 @@ reference: - compute_fqM_ix - compute_NI - compute_NI_ix -- title: Plot terms +- subtitle: Plot terms + desc: | + Basic visualization of the transmission terms contents: - xde_plot_EIR - xde_lines_EIR @@ -770,3 +825,9 @@ reference: - xde_lines_aEIR - xde_plot_PR - xde_lines_PR +- title: Utilities + contents: + - diag_inverse + - approx_equal + - checkIt + - shapeIt diff --git a/man/HumanAvailability.Rd b/man/AvailableBlood.Rd similarity index 56% rename from man/HumanAvailability.Rd rename to man/AvailableBlood.Rd index 8e3aaaad..7e1507e5 100644 --- a/man/HumanAvailability.Rd +++ b/man/AvailableBlood.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-interface.R -\name{HumanAvailability} -\alias{HumanAvailability} +% Please edit documentation in R/available_blood.R +\name{AvailableBlood} +\alias{AvailableBlood} \title{Update the availability of blood hosts} \usage{ -HumanAvailability(t, y, pars) +AvailableBlood(t, y, pars) } \arguments{ \item{t}{current simulation time} @@ -17,5 +17,5 @@ HumanAvailability(t, y, pars) a \link{list} } \description{ -This method dispatches on the type of \code{pars$RESOURCES}. +This method dispatches on the type of \code{pars$BFpar}. } diff --git a/man/HumanAvailability.null.Rd b/man/AvailableBlood.forced.Rd similarity index 69% rename from man/HumanAvailability.null.Rd rename to man/AvailableBlood.forced.Rd index b80ac704..0a068947 100644 --- a/man/HumanAvailability.null.Rd +++ b/man/AvailableBlood.forced.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-null.R -\name{HumanAvailability.null} -\alias{HumanAvailability.null} +% Please edit documentation in R/available_blood.R +\name{AvailableBlood.forced} +\alias{AvailableBlood.forced} \title{Compute availability of local humans for blood feeding} \usage{ -\method{HumanAvailability}{null}(t, y, pars) +\method{AvailableBlood}{forced}(t, y, pars) } \arguments{ \item{t}{current simulation time} diff --git a/man/HumanAvailability.forced.Rd b/man/AvailableBlood.setup.Rd similarity index 68% rename from man/HumanAvailability.forced.Rd rename to man/AvailableBlood.setup.Rd index 09036131..431202c8 100644 --- a/man/HumanAvailability.forced.Rd +++ b/man/AvailableBlood.setup.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-forced.R -\name{HumanAvailability.forced} -\alias{HumanAvailability.forced} +% Please edit documentation in R/available_blood.R +\name{AvailableBlood.setup} +\alias{AvailableBlood.setup} \title{Compute availability of local humans for blood feeding} \usage{ -\method{HumanAvailability}{forced}(t, y, pars) +\method{AvailableBlood}{setup}(t, y, pars) } \arguments{ \item{t}{current simulation time} diff --git a/man/AvailableBlood.static.Rd b/man/AvailableBlood.static.Rd new file mode 100644 index 00000000..a41def88 --- /dev/null +++ b/man/AvailableBlood.static.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_blood.R +\name{AvailableBlood.static} +\alias{AvailableBlood.static} +\title{Compute availability of local humans for blood feeding} +\usage{ +\method{AvailableBlood}{static}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +a \link{numeric} vector of length \code{nPatches} +} +\description{ +Compute the availability for the pathogen's hosts for blood feeding +} diff --git a/man/AvailableHabitat.Rd b/man/AvailableHabitat.Rd new file mode 100644 index 00000000..e36e1f65 --- /dev/null +++ b/man/AvailableHabitat.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_habitat.R +\name{AvailableHabitat} +\alias{AvailableHabitat} +\title{Update the availability of aquatic habitats} +\usage{ +AvailableHabitat(pars) +} +\arguments{ +\item{pars}{an \link{list}} +} +\value{ +a \link{list} +} +\description{ +This method dispatches on the type of \code{pars$EGGpar}. +} diff --git a/man/HabitatAvailability.forced.Rd b/man/AvailableHabitat.forced.Rd similarity index 62% rename from man/HabitatAvailability.forced.Rd rename to man/AvailableHabitat.forced.Rd index 7d037878..53ca2588 100644 --- a/man/HabitatAvailability.forced.Rd +++ b/man/AvailableHabitat.forced.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-forced.R -\name{HabitatAvailability.forced} -\alias{HabitatAvailability.forced} +% Please edit documentation in R/available_habitat.R +\name{AvailableHabitat.forced} +\alias{AvailableHabitat.forced} \title{Compute total availability of aquatic habitats} \usage{ -\method{HabitatAvailability}{forced}(pars) +\method{AvailableHabitat}{forced}(pars) } \arguments{ \item{pars}{a \link{list}} diff --git a/man/AvailableHabitat.simple.Rd b/man/AvailableHabitat.simple.Rd new file mode 100644 index 00000000..260ecb6b --- /dev/null +++ b/man/AvailableHabitat.simple.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_habitat.R +\name{AvailableHabitat.simple} +\alias{AvailableHabitat.simple} +\title{Compute total availability of aquatic habitats} +\usage{ +\method{AvailableHabitat}{simple}(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +a \link{numeric} vector of length \code{nPatches} +} +\description{ +Computes the availability of aquatic habitats for the static model (do nothing) +} diff --git a/man/AvailableHabitat.static.Rd b/man/AvailableHabitat.static.Rd new file mode 100644 index 00000000..fddee0d4 --- /dev/null +++ b/man/AvailableHabitat.static.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_habitat.R +\name{AvailableHabitat.static} +\alias{AvailableHabitat.static} +\title{Compute total availability of aquatic habitats} +\usage{ +\method{AvailableHabitat}{static}(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +a \link{numeric} vector of length \code{nPatches} +} +\description{ +Computes the availability of aquatic habitats for the static model (do nothing) +} diff --git a/man/AvailableSugar.Rd b/man/AvailableSugar.Rd new file mode 100644 index 00000000..d0914b93 --- /dev/null +++ b/man/AvailableSugar.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_sugar.R +\name{AvailableSugar} +\alias{AvailableSugar} +\title{Update the availability of sugar} +\usage{ +AvailableSugar(pars) +} +\arguments{ +\item{pars}{an \link{list}} +} +\value{ +a \link{list} +} +\description{ +This method dispatches on the type of \code{pars$SUGAR}. +} diff --git a/man/SugarAvailability.forced.Rd b/man/AvailableSugar.forced.Rd similarity index 61% rename from man/SugarAvailability.forced.Rd rename to man/AvailableSugar.forced.Rd index a1b94e35..25640417 100644 --- a/man/SugarAvailability.forced.Rd +++ b/man/AvailableSugar.forced.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-forced.R -\name{SugarAvailability.forced} -\alias{SugarAvailability.forced} +% Please edit documentation in R/available_sugar.R +\name{AvailableSugar.forced} +\alias{AvailableSugar.forced} \title{Compute total availability of sugar} \usage{ -\method{SugarAvailability}{forced}(pars) +\method{AvailableSugar}{forced}(pars) } \arguments{ \item{pars}{a \link{list}} diff --git a/man/AvailableSugar.static.Rd b/man/AvailableSugar.static.Rd new file mode 100644 index 00000000..a1a642c6 --- /dev/null +++ b/man/AvailableSugar.static.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_sugar.R +\name{AvailableSugar.static} +\alias{AvailableSugar.static} +\title{Compute total availability of sugar} +\usage{ +\method{AvailableSugar}{static}(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +a \link{numeric} vector of length \code{nPatches} +} +\description{ +Computes the availability of sugar for the static model (do nothing) +} diff --git a/man/Bionomics.Ldynamic.Rd b/man/Bionomics.Ldynamic.Rd new file mode 100644 index 00000000..e402df62 --- /dev/null +++ b/man/Bionomics.Ldynamic.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bionomics.R +\name{Bionomics.Ldynamic} +\alias{Bionomics.Ldynamic} +\title{Set bionomic parameter rates relative to baseline} +\usage{ +\method{Bionomics}{Ldynamic}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +a \link{list} +} +\description{ +This calls Lbionomics for each species each time step +} diff --git a/man/Bionomics.Mdynamic.Rd b/man/Bionomics.Mdynamic.Rd new file mode 100644 index 00000000..a937c264 --- /dev/null +++ b/man/Bionomics.Mdynamic.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bionomics.R +\name{Bionomics.Mdynamic} +\alias{Bionomics.Mdynamic} +\title{Set bionomic parameter rates relative to baseline} +\usage{ +\method{Bionomics}{Mdynamic}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +a \link{list} +} +\description{ +This calls Mbionomics and Lbionmics for each species +} diff --git a/man/Bionomics.Rd b/man/Bionomics.Rd index d6ae0dbb..a4380186 100644 --- a/man/Bionomics.Rd +++ b/man/Bionomics.Rd @@ -17,5 +17,8 @@ Bionomics(t, y, pars) a \link{list} } \description{ -This calls Mbionomics and Lbionmics for each species +This calls Mbionomics and Lbionmics for each species. This function +resets bionomic parameters to their pre-control baseline value, which can later be +modified by vector control. In some models, the pre-control baseline is computed in +here as a function of resource availability. } diff --git a/man/Bionomics.dynamic.Rd b/man/Bionomics.dynamic.Rd new file mode 100644 index 00000000..1da9c4f7 --- /dev/null +++ b/man/Bionomics.dynamic.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bionomics.R +\name{Bionomics.dynamic} +\alias{Bionomics.dynamic} +\title{Set bionomic parameter rates relative to baseline} +\usage{ +\method{Bionomics}{dynamic}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +a \link{list} +} +\description{ +This calls Mbionomics and Lbionmics for each species +} diff --git a/man/Bionomics.setup.Rd b/man/Bionomics.setup.Rd new file mode 100644 index 00000000..db29bad4 --- /dev/null +++ b/man/Bionomics.setup.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bionomics.R +\name{Bionomics.setup} +\alias{Bionomics.setup} +\title{Set bionomic parameter rates relative to baseline} +\usage{ +\method{Bionomics}{setup}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +a \link{list} +} +\description{ +This calls Mbionomics and Lbionmics for each species +} diff --git a/man/Bionomics.static.Rd b/man/Bionomics.static.Rd new file mode 100644 index 00000000..bf5eff42 --- /dev/null +++ b/man/Bionomics.static.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bionomics.R +\name{Bionomics.static} +\alias{Bionomics.static} +\title{Set bionomic parameter rates relative to baseline} +\usage{ +\method{Bionomics}{static}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +a \link{list} +} +\description{ +This calls Mbionomics and Lbionmics for each species +} diff --git a/man/HabitatSearch.static.Rd b/man/EggLaying.dynamic.Rd similarity index 67% rename from man/HabitatSearch.static.Rd rename to man/EggLaying.dynamic.Rd index 648c4e4e..e47f7c61 100644 --- a/man/HabitatSearch.static.Rd +++ b/man/EggLaying.dynamic.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/egg_laying.R -\name{HabitatSearch.static} -\alias{HabitatSearch.static} -\title{Searching for Habitat} +\name{EggLaying.dynamic} +\alias{EggLaying.dynamic} +\title{Compute eggs laid} \usage{ -\method{HabitatSearch}{static}(t, y, pars) +\method{EggLaying}{dynamic}(t, y, pars) } \arguments{ \item{t}{the time} diff --git a/man/HabitatSearch.dynamic.Rd b/man/EggLaying.setup.Rd similarity index 67% rename from man/HabitatSearch.dynamic.Rd rename to man/EggLaying.setup.Rd index 900848a3..b9b07544 100644 --- a/man/HabitatSearch.dynamic.Rd +++ b/man/EggLaying.setup.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/egg_laying.R -\name{HabitatSearch.dynamic} -\alias{HabitatSearch.dynamic} -\title{Searching for Habitat} +\name{EggLaying.setup} +\alias{EggLaying.setup} +\title{Compute eggs laid} \usage{ -\method{HabitatSearch}{dynamic}(t, y, pars) +\method{EggLaying}{setup}(t, y, pars) } \arguments{ \item{t}{the time} diff --git a/man/EggLaying.simple.Rd b/man/EggLaying.simple.Rd new file mode 100644 index 00000000..f26142e1 --- /dev/null +++ b/man/EggLaying.simple.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/egg_laying.R +\name{EggLaying.simple} +\alias{EggLaying.simple} +\title{Compute eggs laid} +\usage{ +\method{EggLaying}{simple}(t, y, pars) +} +\arguments{ +\item{t}{the time} + +\item{y}{the state variables} + +\item{pars}{the model object} +} +\value{ +a \link{list} +} +\description{ +Computes eggs laid for the s^th species +} diff --git a/man/EggLaying.static.Rd b/man/EggLaying.static.Rd new file mode 100644 index 00000000..e73a7aa0 --- /dev/null +++ b/man/EggLaying.static.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/egg_laying.R +\name{EggLaying.static} +\alias{EggLaying.static} +\title{Compute eggs laid} +\usage{ +\method{EggLaying}{static}(t, y, pars) +} +\arguments{ +\item{t}{the time} + +\item{y}{the state variables} + +\item{pars}{the model object} +} +\value{ +a \link{list} +} +\description{ +Computes eggs laid for the s^th species +} diff --git a/man/F_EIR.Rd b/man/F_EIR.Rd index 1796c2e9..42a17057 100644 --- a/man/F_EIR.Rd +++ b/man/F_EIR.Rd @@ -4,7 +4,7 @@ \alias{F_EIR} \title{Entomological inoculation rate on human strata} \usage{ -F_EIR(t, y, pars, beta, s) +F_EIR(t, y, pars, i, s) } \arguments{ \item{t}{current simulation time} @@ -13,7 +13,7 @@ F_EIR(t, y, pars, beta, s) \item{pars}{a \link{list}} -\item{beta, }{a \link{matrix}} +\item{i}{the host species index} \item{s}{the vector species index} } diff --git a/man/F_beta.Rd b/man/F_beta.Rd index 2084edc8..c1db529e 100644 --- a/man/F_beta.Rd +++ b/man/F_beta.Rd @@ -2,24 +2,22 @@ % Please edit documentation in R/transmission.R \name{F_beta} \alias{F_beta} -\title{Compute the biting distribution matrix, beta} +\title{Compute beta, the biting distribution matrix} \usage{ -F_beta(t, y, pars, s, i) +F_beta(H, W, wts_f, TaR) } \arguments{ -\item{t}{current simulation time} +\item{H}{human / host population density} -\item{y}{state vector} +\item{W}{human / host availability in the patches} -\item{pars, }{a \link{list}} +\item{wts_f}{the blood feeding search weights} -\item{s}{the vector species index} - -\item{i}{the host species index} +\item{TaR}{(time at risk), a \link{matrix} dimensions \code{nPatches} by \code{nStrata}} } \value{ -\link{list} +a \link{matrix} of dimensions \code{nStrata} by \code{nPatches} } \description{ -This method dispatches on the type of \code{pars$xde} +Compute beta, the biting distribution matrix } diff --git a/man/F_kappa.Rd b/man/F_kappa.Rd index 05cfb8e0..b94ca2c7 100644 --- a/man/F_kappa.Rd +++ b/man/F_kappa.Rd @@ -4,7 +4,7 @@ \alias{F_kappa} \title{Net infectiousness of human population to mosquitoes} \usage{ -F_kappa(t, y, pars, beta, i) +F_kappa(t, y, pars, i, s) } \arguments{ \item{t}{current simulation time} @@ -13,9 +13,9 @@ F_kappa(t, y, pars, beta, i) \item{pars}{a \link{list}} -\item{beta, }{a \link{matrix}} - \item{i}{the host species index} + +\item{s}{the vector species index} } \value{ a \link{numeric} vector of length \code{nPatches} diff --git a/man/HabitatAvailability.Rd b/man/HabitatAvailability.Rd deleted file mode 100644 index c68c75b4..00000000 --- a/man/HabitatAvailability.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-interface.R -\name{HabitatAvailability} -\alias{HabitatAvailability} -\title{Update the availability of aquatic habitats} -\usage{ -HabitatAvailability(pars) -} -\arguments{ -\item{pars}{an \link{list}} -} -\value{ -a \link{list} -} -\description{ -This method dispatches on the type of \code{pars$RESOURCES}. -} diff --git a/man/HabitatAvailability.null.Rd b/man/HabitatAvailability.null.Rd deleted file mode 100644 index 1d94c4d8..00000000 --- a/man/HabitatAvailability.null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-null.R -\name{HabitatAvailability.null} -\alias{HabitatAvailability.null} -\title{Compute total availability of aquatic habitats} -\usage{ -\method{HabitatAvailability}{null}(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -a \link{numeric} vector of length \code{nPatches} -} -\description{ -Computes the availability of aquatic habitats for the null model (do nothing) -} diff --git a/man/HabitatDynamics.Rd b/man/HabitatDynamics.Rd index 713e9ff5..a230cb3d 100644 --- a/man/HabitatDynamics.Rd +++ b/man/HabitatDynamics.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/habitat_dynamics.R \name{HabitatDynamics} \alias{HabitatDynamics} -\title{Set the values of exogenous variables describing habitat_dynamics} +\title{Habitat Dynamics and Searching} \usage{ HabitatDynamics(t, pars) } @@ -15,5 +15,5 @@ HabitatDynamics(t, pars) \link{list} } \description{ -This method dispatches on the type of \code{pars$HABITAT_DYNAMICS}. +Set the values of habitat search weights and other exogenous variables describing habitat_dynamics. This method dispatches on the type of \code{pars$HABITAT_DYNAMICS}. } diff --git a/man/HabitatDynamics.null.Rd b/man/HabitatDynamics.null.Rd deleted file mode 100644 index 0efa4664..00000000 --- a/man/HabitatDynamics.null.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/habitat_dynamics.R -\name{HabitatDynamics.null} -\alias{HabitatDynamics.null} -\title{Set the values of exogenous variables describing habitat dynamics} -\usage{ -\method{HabitatDynamics}{null}(t, pars) -} -\arguments{ -\item{t}{current simulation time} - -\item{pars}{a \link{list}} -} -\value{ -\link{list} -} -\description{ -Implements \link{HabitatDynamics} for the null model of habitat_dynamics (do nothing) -} diff --git a/man/HabitatDynamics.static.Rd b/man/HabitatDynamics.static.Rd new file mode 100644 index 00000000..52c248e1 --- /dev/null +++ b/man/HabitatDynamics.static.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/habitat_dynamics.R +\name{HabitatDynamics.static} +\alias{HabitatDynamics.static} +\title{Set the values of habitat search weights and other exogenous variables describing habitat_dynamics} +\usage{ +\method{HabitatDynamics}{static}(t, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +Implements \link{HabitatDynamics} for the static model of habitat_dynamics (do nothing) +} diff --git a/man/LocalFrac.Rd b/man/LocalFrac.Rd new file mode 100644 index 00000000..15faed83 --- /dev/null +++ b/man/LocalFrac.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/local_fraction.R +\name{LocalFrac} +\alias{LocalFrac} +\title{Compute the local fraction} +\usage{ +LocalFrac(pars) +} +\arguments{ +\item{pars, }{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This method dispatches on the type of \code{pars$BFpar} +} diff --git a/man/LocalFrac.dynamic.Rd b/man/LocalFrac.dynamic.Rd new file mode 100644 index 00000000..89efd28a --- /dev/null +++ b/man/LocalFrac.dynamic.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/local_fraction.R +\name{LocalFrac.dynamic} +\alias{LocalFrac.dynamic} +\title{Compute transmission terms dynamically, no update required} +\usage{ +\method{LocalFrac}{dynamic}(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This method dispatches on the type of \code{pars$BFpar} +} diff --git a/man/LocalFrac.static.Rd b/man/LocalFrac.static.Rd new file mode 100644 index 00000000..30eb6fc1 --- /dev/null +++ b/man/LocalFrac.static.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/local_fraction.R +\name{LocalFrac.static} +\alias{LocalFrac.static} +\title{Compute transmission terms dynamically, no update required} +\usage{ +\method{LocalFrac}{static}(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This method dispatches on the type of \code{pars$BFpar} +} diff --git a/man/OtherBloodHosts.null.Rd b/man/OtherBloodHosts.static.Rd similarity index 60% rename from man/OtherBloodHosts.null.Rd rename to man/OtherBloodHosts.static.Rd index 1ef0dada..dd63a449 100644 --- a/man/OtherBloodHosts.null.Rd +++ b/man/OtherBloodHosts.static.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/other_blood_hosts.R -\name{OtherBloodHosts.null} -\alias{OtherBloodHosts.null} +\name{OtherBloodHosts.static} +\alias{OtherBloodHosts.static} \title{Set the values of exogenous variables describing other blood hosts} \usage{ -\method{OtherBloodHosts}{null}(t, pars) +\method{OtherBloodHosts}{static}(t, pars) } \arguments{ \item{t}{current simulation time} @@ -15,5 +15,5 @@ \link{list} } \description{ -Implements \link{OtherBloodHosts} for the null model of other_blood_hosts (do nothing) +Implements \link{OtherBloodHosts} for the static model of other_blood_hosts (do nothing) } diff --git a/man/Resources.Rd b/man/Resources.Rd index b3dd48ec..72a52d19 100644 --- a/man/Resources.Rd +++ b/man/Resources.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-interface.R +% Please edit documentation in R/resources.R \name{Resources} \alias{Resources} \title{Set the values of exogenous variables describing available mosquito resources} diff --git a/man/Resources.forced.Rd b/man/Resources.forced.Rd index b1e6dd85..4fa7c953 100644 --- a/man/Resources.forced.Rd +++ b/man/Resources.forced.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-forced.R +% Please edit documentation in R/resources.R \name{Resources.forced} \alias{Resources.forced} \title{Methods for resources} diff --git a/man/Resources.null.Rd b/man/Resources.setup.Rd similarity index 70% rename from man/Resources.null.Rd rename to man/Resources.setup.Rd index 8041c073..f1d2711e 100644 --- a/man/Resources.null.Rd +++ b/man/Resources.setup.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-null.R -\name{Resources.null} -\alias{Resources.null} +% Please edit documentation in R/resources.R +\name{Resources.setup} +\alias{Resources.setup} \title{Modify resources and resource availability} \usage{ -\method{Resources}{null}(t, y, pars) +\method{Resources}{setup}(t, y, pars) } \arguments{ \item{t}{current simulation time} diff --git a/man/Resources.static.Rd b/man/Resources.static.Rd new file mode 100644 index 00000000..3d5d052c --- /dev/null +++ b/man/Resources.static.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/resources.R +\name{Resources.static} +\alias{Resources.static} +\title{Modify resources and resource availability} +\usage{ +\method{Resources}{static}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{vector of state variables} + +\item{pars}{a \link{list}} +} +\value{ +none +} +\description{ +Implements \link{Resources} for the null model of resources +} diff --git a/man/SugarAvailability.Rd b/man/SugarAvailability.Rd deleted file mode 100644 index 51a6a397..00000000 --- a/man/SugarAvailability.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-interface.R -\name{SugarAvailability} -\alias{SugarAvailability} -\title{Update the availability of sugar} -\usage{ -SugarAvailability(pars) -} -\arguments{ -\item{pars}{an \link{list}} -} -\value{ -a \link{list} -} -\description{ -This method dispatches on the type of \code{pars$RESOURCES}. -} diff --git a/man/SugarAvailability.null.Rd b/man/SugarAvailability.null.Rd deleted file mode 100644 index 012840db..00000000 --- a/man/SugarAvailability.null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-null.R -\name{SugarAvailability.null} -\alias{SugarAvailability.null} -\title{Compute total availability of sugar} -\usage{ -\method{SugarAvailability}{null}(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -a \link{numeric} vector of length \code{nPatches} -} -\description{ -Computes the availability of sugar for the null model (do nothing) -} diff --git a/man/Sugar.Rd b/man/SugarDynamics.Rd similarity index 71% rename from man/Sugar.Rd rename to man/SugarDynamics.Rd index 5594e04d..434c7181 100644 --- a/man/Sugar.Rd +++ b/man/SugarDynamics.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sugar.R -\name{Sugar} -\alias{Sugar} +% Please edit documentation in R/sugar_dynamics.R +\name{SugarDynamics} +\alias{SugarDynamics} \title{Set the values of exogenous variables describing sugar} \usage{ -Sugar(t, pars) +SugarDynamics(t, pars) } \arguments{ \item{t}{current simulation time} diff --git a/man/Sugar.null.Rd b/man/SugarDynamics.static.Rd similarity index 51% rename from man/Sugar.null.Rd rename to man/SugarDynamics.static.Rd index 0f63dba6..779fb3ae 100644 --- a/man/Sugar.null.Rd +++ b/man/SugarDynamics.static.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sugar.R -\name{Sugar.null} -\alias{Sugar.null} +% Please edit documentation in R/sugar_dynamics.R +\name{SugarDynamics.static} +\alias{SugarDynamics.static} \title{Set the values of exogenous variables describing sugar} \usage{ -\method{Sugar}{null}(t, pars) +\method{SugarDynamics}{static}(t, pars) } \arguments{ \item{t}{current simulation time} @@ -15,5 +15,5 @@ \link{list} } \description{ -Implements \link{Sugar} for the null model of sugar (do nothing) +Implements \link{SugarDynamics} for the static model of sugar (do nothing) } diff --git a/man/Transmission.Rd b/man/Transmission.Rd index e40b4138..b6fd6ced 100644 --- a/man/Transmission.Rd +++ b/man/Transmission.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/transmission.R \name{Transmission} \alias{Transmission} -\title{Compute the biting distribution matrix, beta} +\title{Compute transmission terms dynamically} \usage{ Transmission(t, y, pars) } @@ -17,5 +17,5 @@ Transmission(t, y, pars) \link{list} } \description{ -This method dispatches on the type of \code{pars$xde} +This method dispatches on the type of \code{pars$BFpar} } diff --git a/man/Transmission.dynamic.Rd b/man/Transmission.dynamic.Rd new file mode 100644 index 00000000..2c9b333a --- /dev/null +++ b/man/Transmission.dynamic.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transmission.R +\name{Transmission.dynamic} +\alias{Transmission.dynamic} +\title{Compute transmission terms, the dynamic case} +\usage{ +\method{Transmission}{dynamic}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This method dispatches on the type of \code{pars$BFpar} +} diff --git a/man/Transmission.setup.Rd b/man/Transmission.setup.Rd new file mode 100644 index 00000000..3b5ce055 --- /dev/null +++ b/man/Transmission.setup.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transmission.R +\name{Transmission.setup} +\alias{Transmission.setup} +\title{Compute transmission terms, the dynamic case} +\usage{ +\method{Transmission}{setup}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This method dispatches on the type of \code{pars$BFpar} +} diff --git a/man/Transmission.static.Rd b/man/Transmission.static.Rd new file mode 100644 index 00000000..8c799920 --- /dev/null +++ b/man/Transmission.static.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transmission.R +\name{Transmission.static} +\alias{Transmission.static} +\title{Compute transmission terms dynamically, no update required} +\usage{ +\method{Transmission}{static}(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This method dispatches on the type of \code{pars$BFpar} +} diff --git a/man/Visitors.null.Rd b/man/Visitors.static.Rd similarity index 54% rename from man/Visitors.null.Rd rename to man/Visitors.static.Rd index bc64b8ca..9932942e 100644 --- a/man/Visitors.null.Rd +++ b/man/Visitors.static.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/visitors.R -\name{Visitors.null} -\alias{Visitors.null} -\title{Visitors, a null model} +\name{Visitors.static} +\alias{Visitors.static} +\title{Visitors, a static model} \usage{ -\method{Visitors}{null}(t, pars) +\method{Visitors}{static}(t, pars) } \arguments{ \item{t}{current simulation time} @@ -15,5 +15,5 @@ a \link{list} } \description{ -Implements \link{Visitors} for the null model (do nothing) +Implements \link{Visitors} for the static model (do nothing) } diff --git a/man/compute_AvailableHabitat.Rd b/man/compute_AvailableHabitat.Rd new file mode 100644 index 00000000..60ae16ab --- /dev/null +++ b/man/compute_AvailableHabitat.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_habitat.R +\name{compute_AvailableHabitat} +\alias{compute_AvailableHabitat} +\title{Compute total availability of aquatic habitats} +\usage{ +compute_AvailableHabitat(pars, s) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{s}{the vector species index} +} +\value{ +a \link{numeric} vector of length \code{nPatches} +} +\description{ +Computes the availability of aquatic habitats +} diff --git a/man/compute_AvailableHosts.Rd b/man/compute_AvailableHosts.Rd new file mode 100644 index 00000000..53b394f2 --- /dev/null +++ b/man/compute_AvailableHosts.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/available_blood.R +\name{compute_AvailableHosts} +\alias{compute_AvailableHosts} +\title{Compute availability blood hosts of the i^th species} +\usage{ +compute_AvailableHosts(t, y, pars, s) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} + +\item{s}{the vector species index} +} +\value{ +a \link{numeric} vector of length \code{nPatches} +} +\description{ +Compute the availability for the pathogen's hosts for blood feeding +} diff --git a/man/compute_EIR.Rd b/man/compute_EIR.Rd new file mode 100644 index 00000000..990fc047 --- /dev/null +++ b/man/compute_EIR.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transmission.R +\name{compute_EIR} +\alias{compute_EIR} +\title{Compute EIR} +\usage{ +compute_EIR(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars, }{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This function computes the EIR for each stratum of each host species +} diff --git a/man/compute_EIR_full.Rd b/man/compute_EIR_full.Rd new file mode 100644 index 00000000..9f79cd15 --- /dev/null +++ b/man/compute_EIR_full.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transmission.R +\name{compute_EIR_full} +\alias{compute_EIR_full} +\title{Compute EIR for each vector-host pair} +\usage{ +compute_EIR_full(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This function computes the EIR from each vector species for each stratum of each host species +} diff --git a/man/HabitatSearch.Rd b/man/compute_EggsLaid.Rd similarity index 72% rename from man/HabitatSearch.Rd rename to man/compute_EggsLaid.Rd index 75fe3a95..eec484f4 100644 --- a/man/HabitatSearch.Rd +++ b/man/compute_EggsLaid.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/egg_laying.R -\name{HabitatSearch} -\alias{HabitatSearch} -\title{Searching for Habitat} +\name{compute_EggsLaid} +\alias{compute_EggsLaid} +\title{Compute eggs laid} \usage{ -HabitatSearch(t, y, pars) +compute_EggsLaid(t, y, pars) } \arguments{ \item{t}{the time} diff --git a/man/compute_beta.Rd b/man/compute_beta.Rd index a259d40a..acc2a67e 100644 --- a/man/compute_beta.Rd +++ b/man/compute_beta.Rd @@ -2,20 +2,20 @@ % Please edit documentation in R/transmission.R \name{compute_beta} \alias{compute_beta} -\title{Compute beta, the biting distribution matrix} +\title{Compute beta} \usage{ -compute_beta(H, wts_f, TaR) +compute_beta(t, y, pars) } \arguments{ -\item{H}{the human population size} +\item{t}{current simulation time} -\item{wts_f}{the blood feeding search weights} +\item{y}{state vector} -\item{TaR}{(time at risk), a \link{matrix} dimensions \code{nPatches} by \code{nStrata}} +\item{pars, }{a \link{list}} } \value{ -a \link{matrix} of dimensions \code{nStrata} by \code{nPatches} +\link{list} } \description{ -Compute beta, the biting distribution matrix +This function computes the mixing matrix, beta } diff --git a/man/compute_calU.Rd b/man/compute_calU.Rd new file mode 100644 index 00000000..6598d113 --- /dev/null +++ b/man/compute_calU.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/egg_laying.R +\name{compute_calU} +\alias{compute_calU} +\title{Compute calU} +\usage{ +compute_calU(t, y, pars) +} +\arguments{ +\item{t}{the time} + +\item{y}{the state variables} + +\item{pars}{the model object} +} +\value{ +a \link{list} +} +\description{ +Computes the egg laying matrices +} diff --git a/man/compute_kappa.Rd b/man/compute_kappa.Rd new file mode 100644 index 00000000..c7723363 --- /dev/null +++ b/man/compute_kappa.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/transmission.R +\name{compute_kappa} +\alias{compute_kappa} +\title{Compute kappa} +\usage{ +compute_kappa(t, y, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{y}{state vector} + +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +This function computes kappa for each vector species in each patch +} diff --git a/man/compute_local_frac.Rd b/man/compute_local_frac.Rd index 55406689..ece50af0 100644 --- a/man/compute_local_frac.Rd +++ b/man/compute_local_frac.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-forced.R +% Please edit documentation in R/local_fraction.R \name{compute_local_frac} \alias{compute_local_frac} \title{Compute the local fraction} diff --git a/man/make_TaR.Rd b/man/make_TaR.Rd index 3b945619..09a1025d 100644 --- a/man/make_TaR.Rd +++ b/man/make_TaR.Rd @@ -1,23 +1,23 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time_at_risk.R +% Please edit documentation in R/blood_feeding.R \name{make_TaR} \alias{make_TaR} -\title{Make a mosquito dispersal matrix, called TaR} +\title{Make TaR} \usage{ -make_TaR(nPatches, residence, TaR, opts = list()) +make_TaR(t, pars, i, s) } \arguments{ -\item{nPatches}{is the number of patches} +\item{t}{the time} -\item{residence}{is the residence vector} +\item{pars}{a \link{list}} -\item{TaR}{a matrix; or a string} +\item{i}{the host species index} -\item{opts}{a list of options to configure TaR} +\item{s}{the vector species index} } \value{ -a \link{matrix} +none } \description{ -Make a mosquito dispersal matrix, called TaR +Make a time at risk matrix (TaR) from a time spent matrix and a circadian function } diff --git a/man/make_TaR.as_matrix.Rd b/man/make_TaR.as_matrix.Rd deleted file mode 100644 index 2daffab8..00000000 --- a/man/make_TaR.as_matrix.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time_at_risk.R -\name{make_TaR.as_matrix} -\alias{make_TaR.as_matrix} -\title{Pass a pre-configured TaR} -\usage{ -\method{make_TaR}{as_matrix}(nPatches, residence, TaR, opts = list()) -} -\arguments{ -\item{nPatches}{is the number of patches} - -\item{residence}{is the residence vector} - -\item{TaR}{a matrix; or a string} - -\item{opts}{a list of options to configure TaR} -} -\value{ -a \link{matrix} -} -\description{ -Implements \link{make_TaR} for as_matrix -} diff --git a/man/make_TaR.athome.Rd b/man/make_TaR.athome.Rd deleted file mode 100644 index d1366667..00000000 --- a/man/make_TaR.athome.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time_at_risk.R -\name{make_TaR.athome} -\alias{make_TaR.athome} -\title{Make a mosquito dispersal matrix, called TaR with a here / away} -\usage{ -\method{make_TaR}{athome}(nPatches, residence, TaR = "athome", opts = list()) -} -\arguments{ -\item{nPatches}{is the number of patches} - -\item{residence}{is the residence vector} - -\item{TaR}{a matrix; or a string} - -\item{opts}{a list of options to configure TaR} -} -\value{ -a \link{matrix} -} -\description{ -Implements \link{make_TaR} for as_matrix -} diff --git a/man/make_TaR.xy.Rd b/man/make_TaR.xy.Rd deleted file mode 100644 index 8ee92d59..00000000 --- a/man/make_TaR.xy.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time_at_risk.R -\name{make_TaR.xy} -\alias{make_TaR.xy} -\title{Develop a mosquito dispersal matrix from a kernel and xy-coordinates} -\usage{ -\method{make_TaR}{xy}(nPatches, residence, TaR = "xy", opts = list()) -} -\arguments{ -\item{nPatches}{is the number of patches} - -\item{residence}{is the residence vector} - -\item{TaR}{a matrix; or a string} - -\item{opts}{a list of options to configure TaR} -} -\value{ -a \link{matrix} -} -\description{ -Implements \link{make_TaR} for kernels -} diff --git a/man/make_TimeSpent.Rd b/man/make_TimeSpent.Rd new file mode 100644 index 00000000..f6012538 --- /dev/null +++ b/man/make_TimeSpent.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/time_spent.R +\name{make_TimeSpent} +\alias{make_TimeSpent} +\title{Make a time spent matrix, called TimeSpent} +\usage{ +make_TimeSpent(pars, i, TimeSpent, opts = list()) +} +\arguments{ +\item{pars}{an \link{list}} + +\item{i}{the host species index} + +\item{TimeSpent}{a matrix; or a string} + +\item{opts}{a list of options to configure TimeSpent} +} +\value{ +a \link{list} +} +\description{ +Make a time spent matrix, called TimeSpent +} diff --git a/man/make_TimeSpent.as_matrix.Rd b/man/make_TimeSpent.as_matrix.Rd new file mode 100644 index 00000000..e5fb78fd --- /dev/null +++ b/man/make_TimeSpent.as_matrix.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/time_spent.R +\name{make_TimeSpent.as_matrix} +\alias{make_TimeSpent.as_matrix} +\title{Pass a pre-configured TimeSpent} +\usage{ +\method{make_TimeSpent}{as_matrix}(pars, i, TimeSpent, opts = list()) +} +\arguments{ +\item{pars}{an \link{list}} + +\item{i}{the host species index} + +\item{TimeSpent}{a matrix; or a string} + +\item{opts}{a list of options to configure TimeSpent} +} +\value{ +a \link{list} +} +\description{ +Implements \link{make_TimeSpent} for as_matrix +} diff --git a/man/make_TimeSpent.athome.Rd b/man/make_TimeSpent.athome.Rd new file mode 100644 index 00000000..06887c57 --- /dev/null +++ b/man/make_TimeSpent.athome.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/time_spent.R +\name{make_TimeSpent.athome} +\alias{make_TimeSpent.athome} +\title{Make a mosquito dispersal matrix, called TimeSpent with a here / away} +\usage{ +\method{make_TimeSpent}{athome}(pars, i, TimeSpent = "athome", opts = list()) +} +\arguments{ +\item{pars}{an \link{list}} + +\item{i}{the host species index} + +\item{TimeSpent}{a matrix; or a string} + +\item{opts}{a list of options to configure TimeSpent} +} +\value{ +a \link{list} +} +\description{ +Implements \link{make_TimeSpent} for as_matrix +} diff --git a/man/make_TimeSpent.xy.Rd b/man/make_TimeSpent.xy.Rd new file mode 100644 index 00000000..958b0053 --- /dev/null +++ b/man/make_TimeSpent.xy.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/time_spent.R +\name{make_TimeSpent.xy} +\alias{make_TimeSpent.xy} +\title{Develop a mosquito dispersal matrix from a kernel and xy-coordinates} +\usage{ +\method{make_TimeSpent}{xy}(pars, i, TimeSpent = "xy", opts = list()) +} +\arguments{ +\item{pars}{an \link{list}} + +\item{i}{the host species index} + +\item{TimeSpent}{a matrix; or a string} + +\item{opts}{a list of options to configure TimeSpent} +} +\value{ +a \link{list} +} +\description{ +Implements \link{make_TimeSpent} for kernels +} diff --git a/man/make_TaR_athome.Rd b/man/make_TimeSpent_athome.Rd similarity index 55% rename from man/make_TaR_athome.Rd rename to man/make_TimeSpent_athome.Rd index 39718722..663bd3d7 100644 --- a/man/make_TaR_athome.Rd +++ b/man/make_TimeSpent_athome.Rd @@ -1,10 +1,16 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time_at_risk.R -\name{make_TaR_athome} -\alias{make_TaR_athome} -\title{Make a mosquito dispersal matrix, called TaR} +% Please edit documentation in R/time_spent.R +\name{make_TimeSpent_athome} +\alias{make_TimeSpent_athome} +\title{Make a mosquito dispersal matrix, called TimeSpent} \usage{ -make_TaR_athome(nPatches, residence, opts = list(), atHome = 1, travel = 0) +make_TimeSpent_athome( + nPatches, + residence, + opts = list(), + atHome = 1, + travel = 0 +) } \arguments{ \item{nPatches}{is the number of patches} @@ -21,5 +27,5 @@ make_TaR_athome(nPatches, residence, opts = list(), atHome = 1, travel = 0) a \link{matrix} } \description{ -Make a mosquito dispersal matrix, called TaR +Make a mosquito dispersal matrix, called TimeSpent } diff --git a/man/make_TaR_xy.Rd b/man/make_TimeSpent_xy.Rd similarity index 59% rename from man/make_TaR_xy.Rd rename to man/make_TimeSpent_xy.Rd index bf6cfb5c..bc0c526b 100644 --- a/man/make_TaR_xy.Rd +++ b/man/make_TimeSpent_xy.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time_at_risk.R -\name{make_TaR_xy} -\alias{make_TaR_xy} -\title{Make a mosquito dispersal matrix, called TaR} +% Please edit documentation in R/time_spent.R +\name{make_TimeSpent_xy} +\alias{make_TimeSpent_xy} +\title{Make a mosquito dispersal matrix, called TimeSpent} \usage{ -make_TaR_xy(xy, residence, kern, stay, travel) +make_TimeSpent_xy(xy, residence, kern, stay, travel) } \arguments{ \item{xy}{is the xy-locations of the patches} @@ -21,5 +21,5 @@ make_TaR_xy(xy, residence, kern, stay, travel) a \link{matrix} } \description{ -Make a mosquito dispersal matrix, called TaR +Make a mosquito dispersal matrix, called TimeSpent } diff --git a/man/make_calU.Rd b/man/make_calU.Rd index 57a89b13..a4768f9f 100644 --- a/man/make_calU.Rd +++ b/man/make_calU.Rd @@ -1,15 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aquatic-interface.R +% Please edit documentation in R/egg_laying.R \name{make_calU} \alias{make_calU} \title{Make the egg distribution matrix, calU} \usage{ -make_calU(calN, searchQ = 1) +make_calU(calN, searchWts = 1) } \arguments{ \item{calN}{the habitat membership matrix} -\item{searchQ}{the habitat search weights} +\item{searchWts}{the habitat search weights} } \value{ a \link{matrix} of dimensions \code{nHabitats} by \code{nPatches} diff --git a/man/make_calU_s.Rd b/man/make_calU_s.Rd new file mode 100644 index 00000000..63e7bbdf --- /dev/null +++ b/man/make_calU_s.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/egg_laying.R +\name{make_calU_s} +\alias{make_calU_s} +\title{Make the egg distribution matrix, calU} +\usage{ +make_calU_s(pars, s) +} +\arguments{ +\item{pars}{the model object} + +\item{s}{vector species index} +} +\value{ +\link{list} +} +\description{ +Make the egg distribution matrix, calU +} diff --git a/man/make_parameters_demography_null.Rd b/man/make_parameters_demography_null.Rd index d5976a62..5d25dfe9 100644 --- a/man/make_parameters_demography_null.Rd +++ b/man/make_parameters_demography_null.Rd @@ -4,18 +4,12 @@ \alias{make_parameters_demography_null} \title{Make parameters for null human demography model} \usage{ -make_parameters_demography_null(pars, H, residence, searchWts, TaR) +make_parameters_demography_null(pars, H) } \arguments{ \item{pars}{a \link{list}} \item{H}{size of human population in each strata} - -\item{residence}{is a vector describing patch residency} - -\item{searchWts}{is a vector describing blood feeding search weights} - -\item{TaR}{is a matrix describing time spent among patches} } \value{ none diff --git a/man/setup_BFpar_static.Rd b/man/setup_BFpar_static.Rd new file mode 100644 index 00000000..08e07ae5 --- /dev/null +++ b/man/setup_BFpar_static.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blood_feeding.R +\name{setup_BFpar_static} +\alias{setup_BFpar_static} +\title{Set up the blood feeding model} +\usage{ +setup_BFpar_static(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +none +} +\description{ +This sets up a list that stores all the information required by the +blood feeding model, including information about humans (the residence vector, search +weights for blood feeding mosquitoes); the mosquitoes circadian pattern (F_circadian); +and derived structures, including the time spent (TimeSpent) and the time at risk (TaR) +matrices. This also sets up the objects required for blood feeding, including host availability +for each species (Wi) and for all hosts (W), other blood hosts (Other), and total blood +availability (B). Finally, it sets up the lists that will hold the mixing matrix (beta), and +the transmission terms describing the entomological inoculation rate (EIR and eir), and the force +of infection (FoI), and the net infectiousness (kappa and ni). +} diff --git a/man/setup_BloodFeeding.Rd b/man/setup_BloodFeeding.Rd new file mode 100644 index 00000000..d1be1dc6 --- /dev/null +++ b/man/setup_BloodFeeding.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blood_feeding.R +\name{setup_BloodFeeding} +\alias{setup_BloodFeeding} +\title{Set up blood feeding} +\usage{ +setup_BloodFeeding( + pars, + i, + s = 1, + BFopts = list(), + residence = 1, + searchWts = 1, + F_circadian = NULL +) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{i}{the host species index} + +\item{s}{the vector species index} + +\item{BFopts}{a \link{list}} + +\item{residence}{is the patch where each stratum resides} + +\item{searchWts}{is the blood feeding search weight for each stratum} + +\item{F_circadian}{is a function that computes relative mosquito blood feeding activity rates by time of day} +} +\value{ +none +} +\description{ +This sets up a list that stores all the information +} diff --git a/man/setup_EGGpar_static.Rd b/man/setup_EGGpar_static.Rd new file mode 100644 index 00000000..e8191308 --- /dev/null +++ b/man/setup_EGGpar_static.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/egg_laying.R +\name{setup_EGGpar_static} +\alias{setup_EGGpar_static} +\title{Setup the structures required for egg laying} +\usage{ +setup_EGGpar_static(pars) +} +\arguments{ +\item{pars}{the model object} +} +\value{ +a \link{list} vector +} +\description{ +This sets up the object EGGpar, which holds information +about the egg laying model. Several terms are expected to differ by +vector species, including the search weights (searchWts), the fraction +of eggs laid in habitat that is sometimes suitable (Qfrac), the +egg deposition matrix (calU), and the habitat egg laying rate (eggs_laid). +This function sets up lists. +} diff --git a/man/setup_EggLaying.Rd b/man/setup_EggLaying_simple.Rd similarity index 77% rename from man/setup_EggLaying.Rd rename to man/setup_EggLaying_simple.Rd index df0542c6..4a106a0f 100644 --- a/man/setup_EggLaying.Rd +++ b/man/setup_EggLaying_simple.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/egg_laying.R -\name{setup_EggLaying} -\alias{setup_EggLaying} +\name{setup_EggLaying_simple} +\alias{setup_EggLaying_simple} \title{Setup egg laying for most models} \usage{ -setup_EggLaying(pars, s, searchQ = 1, Lopts = list()) +setup_EggLaying_simple(pars, s, searchQ = 1, Lopts = list()) } \arguments{ \item{pars}{the model object} diff --git a/man/setup_EggLaying_static.Rd b/man/setup_EggLaying_static.Rd new file mode 100644 index 00000000..2321c193 --- /dev/null +++ b/man/setup_EggLaying_static.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/egg_laying.R +\name{setup_EggLaying_static} +\alias{setup_EggLaying_static} +\title{Setup egg laying for most models} +\usage{ +setup_EggLaying_static(pars, s, searchQ = 1, Lopts = list()) +} +\arguments{ +\item{pars}{the model object} + +\item{s}{the vector species index} + +\item{searchQ}{the membership matrix} + +\item{Lopts}{a \link{list} of options to override defaults} +} +\value{ +a \link{list} vector +} +\description{ +Sets up the egg-deposition matrix calU for the s^th species +} diff --git a/man/setup_Hpar.Rd b/man/setup_Hpar_static.Rd similarity index 51% rename from man/setup_Hpar.Rd rename to man/setup_Hpar_static.Rd index 9c0448be..7207ff5c 100644 --- a/man/setup_Hpar.Rd +++ b/man/setup_Hpar_static.Rd @@ -1,21 +1,17 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/demography-interface.R -\name{setup_Hpar} -\alias{setup_Hpar} +\name{setup_Hpar_static} +\alias{setup_Hpar_static} \title{A utility to set up Hpar} \usage{ -setup_Hpar(pars, HPop = 1000, residence = 1, searchWts = 1, Hopts = NULL) +setup_Hpar_static(pars, i, HPop = 1000) } \arguments{ \item{pars}{a \link{list}} -\item{HPop}{a \link{numeric} vector of population densities} - -\item{residence}{is the patch where each stratum resides} +\item{i}{the host species index} -\item{searchWts}{is the blood feeding search weight for each stratum} - -\item{Hopts}{a \link{list} to overwrite default values} +\item{HPop}{a \link{numeric} vector of population densities} } \value{ a \link{list} diff --git a/man/setup_bionomics_static.Rd b/man/setup_bionomics_static.Rd new file mode 100644 index 00000000..d560f8fa --- /dev/null +++ b/man/setup_bionomics_static.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bionomics.R +\name{setup_bionomics_static} +\alias{setup_bionomics_static} +\title{Make parameters for the static model bionomics} +\usage{ +setup_bionomics_static(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +\link{list} +} +\description{ +Make parameters for the static model bionomics +} diff --git a/man/setup_habitat_dynamics_null.Rd b/man/setup_habitat_dynamics_null.Rd deleted file mode 100644 index 1a1c84b8..00000000 --- a/man/setup_habitat_dynamics_null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/habitat_dynamics.R -\name{setup_habitat_dynamics_null} -\alias{setup_habitat_dynamics_null} -\title{Make parameters for the null model for habitat dynamics (do nothing)} -\usage{ -setup_habitat_dynamics_null(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -\link{list} -} -\description{ -Make parameters for the null model for habitat dynamics (do nothing) -} diff --git a/man/setup_habitat_dynamics_static.Rd b/man/setup_habitat_dynamics_static.Rd new file mode 100644 index 00000000..0ac5d06a --- /dev/null +++ b/man/setup_habitat_dynamics_static.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/habitat_dynamics.R +\name{setup_habitat_dynamics_static} +\alias{setup_habitat_dynamics_static} +\title{Setup the egg laying object} +\usage{ +setup_habitat_dynamics_static(pars) +} +\arguments{ +\item{pars}{the model object} +} +\value{ +a \link{list} vector +} +\description{ +Sets up the egg-deposition matrix calU for the s^th species +} diff --git a/man/setup_local_fraction_simple.Rd b/man/setup_local_fraction_simple.Rd new file mode 100644 index 00000000..899295e6 --- /dev/null +++ b/man/setup_local_fraction_simple.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/local_fraction.R +\name{setup_local_fraction_simple} +\alias{setup_local_fraction_simple} +\title{Set up the local_fraction for static models} +\usage{ +setup_local_fraction_simple(pars, local_frac = 1) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{local_frac}{is the fraction of the ambient human / host population that is not a visitor} +} +\value{ +\link{list} +} +\description{ +The local fraction +} diff --git a/man/setup_other_blood_hosts_null.Rd b/man/setup_other_blood_hosts_null.Rd deleted file mode 100644 index dae3d935..00000000 --- a/man/setup_other_blood_hosts_null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/other_blood_hosts.R -\name{setup_other_blood_hosts_null} -\alias{setup_other_blood_hosts_null} -\title{Make parameters for the null model for other blood hosts (do nothing)} -\usage{ -setup_other_blood_hosts_null(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -\link{list} -} -\description{ -Make parameters for the null model for other blood hosts (do nothing) -} diff --git a/man/setup_other_blood_hosts_static.Rd b/man/setup_other_blood_hosts_static.Rd new file mode 100644 index 00000000..cb741f1b --- /dev/null +++ b/man/setup_other_blood_hosts_static.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/other_blood_hosts.R +\name{setup_other_blood_hosts_static} +\alias{setup_other_blood_hosts_static} +\title{Make parameters for the static model for other blood hosts (do nothing)} +\usage{ +setup_other_blood_hosts_static(pars, Other = 0) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{Other}{the availability of other blood hosts} +} +\value{ +\link{list} +} +\description{ +Make parameters for the static model for other blood hosts (do nothing) +} diff --git a/man/setup_resources_forced.Rd b/man/setup_resources_forced.Rd index e646f084..bce15260 100644 --- a/man/setup_resources_forced.Rd +++ b/man/setup_resources_forced.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-forced.R +% Please edit documentation in R/resources.R \name{setup_resources_forced} \alias{setup_resources_forced} \title{Set up a model for mass medical} diff --git a/man/setup_resources_null.Rd b/man/setup_resources_null.Rd index 41564995..80397222 100644 --- a/man/setup_resources_null.Rd +++ b/man/setup_resources_null.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resources-null.R +% Please edit documentation in R/resources.R \name{setup_resources_null} \alias{setup_resources_null} \title{Set up parameters for the null model for resource availability} diff --git a/man/setup_resources_static.Rd b/man/setup_resources_static.Rd new file mode 100644 index 00000000..db5f282f --- /dev/null +++ b/man/setup_resources_static.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/resources.R +\name{setup_resources_static} +\alias{setup_resources_static} +\title{Set up parameters for the null model for resource availability} +\usage{ +setup_resources_static(pars) +} +\arguments{ +\item{pars}{a \link{list}} +} +\value{ +none +} +\description{ +Set up parameters for the null model for resource availability +} diff --git a/man/setup_sugar_null.Rd b/man/setup_sugar_null.Rd deleted file mode 100644 index 30c2c7a4..00000000 --- a/man/setup_sugar_null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sugar.R -\name{setup_sugar_null} -\alias{setup_sugar_null} -\title{Make parameters for the null model for sugar (do nothing)} -\usage{ -setup_sugar_null(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -\link{list} -} -\description{ -Make parameters for the null model for sugar (do nothing) -} diff --git a/man/setup_sugar_static.Rd b/man/setup_sugar_static.Rd new file mode 100644 index 00000000..3a70ee86 --- /dev/null +++ b/man/setup_sugar_static.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sugar_dynamics.R +\name{setup_sugar_static} +\alias{setup_sugar_static} +\title{Make parameters for the static model for sugar (do nothing)} +\usage{ +setup_sugar_static(pars, Sugar = 0) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{Sugar}{describes sugar availability} +} +\value{ +\link{list} +} +\description{ +Make parameters for the static model for sugar (do nothing) +} diff --git a/man/setup_travel_null.Rd b/man/setup_travel_null.Rd deleted file mode 100644 index 95004f6e..00000000 --- a/man/setup_travel_null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/travel_malaria-null.R -\name{setup_travel_null} -\alias{setup_travel_null} -\title{A function to set up malaria importation} -\usage{ -setup_travel_null(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -a \link{list} -} -\description{ -Setup a null model for travel malaria -} diff --git a/man/setup_travel_static.Rd b/man/setup_travel_static.Rd new file mode 100644 index 00000000..9eb6f703 --- /dev/null +++ b/man/setup_travel_static.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/travel_malaria-static.R +\name{setup_travel_static} +\alias{setup_travel_static} +\title{A function to set up malaria importation} +\usage{ +setup_travel_static(pars, delta = 0) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{delta}{the travel FoI} +} +\value{ +a \link{list} +} +\description{ +Setup a static model for travel malaria +} diff --git a/man/setup_visitors_null.Rd b/man/setup_visitors_null.Rd deleted file mode 100644 index 10c5d2bd..00000000 --- a/man/setup_visitors_null.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/visitors.R -\name{setup_visitors_null} -\alias{setup_visitors_null} -\title{Make parameters for the null model visitors (no visitors)} -\usage{ -setup_visitors_null(pars) -} -\arguments{ -\item{pars}{a \link{list}} -} -\value{ -\link{list} -} -\description{ -Make parameters for the null model visitors (no visitors) -} diff --git a/man/setup_visitors_static.Rd b/man/setup_visitors_static.Rd new file mode 100644 index 00000000..6e0fde6a --- /dev/null +++ b/man/setup_visitors_static.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visitors.R +\name{setup_visitors_static} +\alias{setup_visitors_static} +\title{Make parameters for the static model visitors (no visitors)} +\usage{ +setup_visitors_static(pars, local_frac = 1, Visitors = 0, x_visitors = 0) +} +\arguments{ +\item{pars}{a \link{list}} + +\item{local_frac}{is the fraction of humans / hosts that are not visitors} + +\item{Visitors}{is the availability of visitors} + +\item{x_visitors}{is the net infectiousness of the visitors} +} +\value{ +\link{list} +} +\description{ +Make parameters for the static model visitors (no visitors) +} diff --git a/man/travel_malaria.null.Rd b/man/travel_malaria.null.Rd deleted file mode 100644 index bbd49b78..00000000 --- a/man/travel_malaria.null.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/travel_malaria-null.R -\name{travel_malaria.null} -\alias{travel_malaria.null} -\title{travel, a null model} -\usage{ -\method{travel_malaria}{null}(t, pars) -} -\arguments{ -\item{t}{current simulation time} - -\item{pars}{a \link{list}} -} -\value{ -a \link{numeric} -} -\description{ -Implements \link{travel_malaria} for the null model (do nothing) -} diff --git a/man/travel_malaria.static.Rd b/man/travel_malaria.static.Rd new file mode 100644 index 00000000..45ac16ad --- /dev/null +++ b/man/travel_malaria.static.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/travel_malaria-static.R +\name{travel_malaria.static} +\alias{travel_malaria.static} +\title{travel, a static model} +\usage{ +\method{travel_malaria}{static}(t, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{pars}{a \link{list}} +} +\value{ +a \link{numeric} +} +\description{ +Implements \link{travel_malaria} for the static model (do nothing) +} diff --git a/man/xde_setup.Rd b/man/xde_setup.Rd index e78bb6a3..9b59bd5d 100644 --- a/man/xde_setup.Rd +++ b/man/xde_setup.Rd @@ -20,11 +20,12 @@ xde_setup( EIPname = "static", EIPopts = list(), Xopts = list(), - Hopts = list(), + BFopts = list(), residence = 1, searchB = 1, - TaR = "athome", - TaRopts = list(), + F_circadian = NULL, + TimeSpent = "athome", + TimeSpentOpts = list(), searchQ = 1, Lopts = list() ) @@ -60,15 +61,17 @@ xde_setup( \item{Xopts}{a list to configure the X model} -\item{Hopts}{a list to configure the H model} +\item{BFopts}{a list to configure the blood feeding model} \item{residence}{is a vector that describes the patch where each human stratum lives} \item{searchB}{is a vector of search weights for blood feeding} -\item{TaR}{is either a TaR matrix or a string to call a function that sets it up} +\item{F_circadian}{is a function describing mosquito daily activity} -\item{TaRopts}{are the options to setup TaR} +\item{TimeSpent}{is either a TimeSpent matrix or a string to call a function that sets it up} + +\item{TimeSpentOpts}{are the options to setup TimeSpent} \item{searchQ}{is a vector of search weights for egg laying} diff --git a/man/xde_setup_cohort.Rd b/man/xde_setup_cohort.Rd index 42ff218d..32837257 100644 --- a/man/xde_setup_cohort.Rd +++ b/man/xde_setup_cohort.Rd @@ -10,8 +10,8 @@ xde_setup_cohort( Xname = "SIS", HPop = 1000, searchB = 1, - Xopts = list(), - Hopts = list() + residence = 1, + Xopts = list() ) } \arguments{ @@ -25,9 +25,9 @@ xde_setup_cohort( \item{searchB}{is a vector of search weights for blood feeding} -\item{Xopts}{a list to configure the X model} +\item{residence}{is a vector that describes the patch where each human stratum lives} -\item{Hopts}{a list to configure the H model} +\item{Xopts}{a list to configure the X model} } \value{ a \link{list} diff --git a/man/xde_setup_human.Rd b/man/xde_setup_human.Rd index e864e830..9b00e091 100644 --- a/man/xde_setup_human.Rd +++ b/man/xde_setup_human.Rd @@ -10,11 +10,12 @@ xde_setup_human( HPop = 1000, MYZopts = list(), Xopts = list(), - Hopts = list(), + BFopts = list(), residence = 1, searchB = 1, - TaR = "athome", - TaRopts = list() + F_circadian = NULL, + TimeSpent = "athome", + TimeSpentOpts = list() ) } \arguments{ @@ -28,15 +29,17 @@ xde_setup_human( \item{Xopts}{a list to configure the X model} -\item{Hopts}{a list to configure the H model} +\item{BFopts}{a list to configure the blood feeding model} \item{residence}{is a vector that describes the patch where each human stratum lives} \item{searchB}{is a vector of search weights for blood feeding} -\item{TaR}{is either a TaR matrix or a string to call a function that sets it up} +\item{F_circadian}{is a function describing mosquito daily activity} -\item{TaRopts}{are the options to setup TaR} +\item{TimeSpent}{is either a TimeSpent matrix or a string to call a function that sets it up} + +\item{TimeSpentOpts}{are the options to setup TimeSpent} } \value{ a \link{list} diff --git a/tests/testthat/test-aqua-basic.R b/tests/testthat/test-aqua-basic.R index 1113e8a3..fba0c8f4 100644 --- a/tests/testthat/test-aqua-basic.R +++ b/tests/testthat/test-aqua-basic.R @@ -7,22 +7,22 @@ test_that("basic competition stays at equilibrium", { nHabitats <- 3 alpha <- c(10, 50, 20) - eta <- c(250, 500, 170) + eggs_laid <- c(250, 500, 170) psi <- 1/10 phi <- 1/12 L <- alpha/psi - theta <- (eta - psi*L - phi*L)/(L^2) + theta <- (eggs_laid - psi*L - phi*L)/(L^2) params <- make_parameters_xde() params$nHabitats = nHabitats # ODE - params = make_parameters_L_basic(pars = params, psi = psi, phi = phi, theta = theta) + params = make_parameters_L_basic(pars = params, psi = psi, phi = phi, theta=theta) params = make_inits_L_basic(pars = params, L0 = L) params = make_indices(params) - params$eta = list() - params$eta[[1]] = eta + params$eggs_laid = list() + params$eggs_laid[[1]] = eggs_laid y0 <- rep(0, 3) diff --git a/tests/testthat/test-equilibrium-RM-SIP.R b/tests/testthat/test-equilibrium-RM-SIP.R index 7480ed9b..91c40dbc 100644 --- a/tests/testthat/test-equilibrium-RM-SIP.R +++ b/tests/testthat/test-equilibrium-RM-SIP.R @@ -94,8 +94,9 @@ test_that("test equilibrium with RM adults (ODE), SIP humans, trace", { params = make_parameters_MYZ_RM(pars = params, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, solve_as="ode") params = make_inits_MYZ_RM_ode(pars = params, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z)) - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIP(pars = params, b = b, c = c, r = r, eta=eta, rho=rho, xi=xi) params = make_inits_X_SIP(pars = params, H-I-Px, I, Px) params = make_parameters_L_trace(pars = params, Lambda = as.vector(Lambda)) @@ -206,8 +207,9 @@ test_that("test equilibrium with RM adults (DDE), SIP humans, trace", { params = make_parameters_MYZ_RM(pars = params, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, solve_as="ode") params = make_inits_MYZ_RM_dde(pars = params, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z), Upsilon0=OmegaEIP) - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIP(pars = params, b = b, c = c, r = r, eta=eta, rho=rho, xi=xi) params = make_inits_X_SIP(pars = params, H-I-Px, I, Px) params = make_parameters_L_trace(pars = params, Lambda = as.vector(Lambda)) diff --git a/tests/testthat/test-equilibrium-RM-SIS.R b/tests/testthat/test-equilibrium-RM-SIS.R index 0eadb1d5..5c31f251 100644 --- a/tests/testthat/test-equilibrium-RM-SIS.R +++ b/tests/testthat/test-equilibrium-RM-SIS.R @@ -90,8 +90,9 @@ test_that("test equilibrium with RM adults (ODE), SIS humans, trace", { params = make_parameters_MYZ_RM(pars = params, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, solve_as="ode") params = make_inits_MYZ_RM_ode(pars = params, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z)) - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIS(pars = params, b = b, c = c, r = r) params = make_inits_X_SIS(pars = params, H-I, I) params = make_parameters_L_trace(pars = params, Lambda = as.vector(Lambda)) @@ -198,8 +199,9 @@ test_that("test equilibrium with RM adults (DDE), SIS humans, trace", { params = make_parameters_MYZ_RM(pars = params, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch) params = make_inits_MYZ_RM_dde(pars = params, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z), Upsilon0=OmegaEIP) - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIS(pars = params, b = b, c = c, r = r) params = make_inits_X_SIS(pars = params, H-I, I) params = make_parameters_L_trace(pars = params, Lambda = as.vector(Lambda)) diff --git a/tests/testthat/test-equilibrium-RM-hMoI.R b/tests/testthat/test-equilibrium-RM-hMoI.R index 2312910b..20db1bc1 100644 --- a/tests/testthat/test-equilibrium-RM-hMoI.R +++ b/tests/testthat/test-equilibrium-RM-hMoI.R @@ -98,8 +98,9 @@ test_that("test equilibrium with RM adults (ODE), hMoI humans, trace", { params = make_parameters_MYZ_RM(pars = params, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, solve_as="ode") params = make_inits_MYZ_RM_ode(pars = params, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z)) - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_hMoI(pars = params, b = b, c1 = c1, c2 = c2, r1 = r1, r2 = r2) params = make_inits_X_hMoI(pars = params, m10 = rep(m10,2), m20 = rep(m20,2)) params = make_parameters_L_trace(pars = params, Lambda = as.vector(Lambda)) @@ -215,8 +216,9 @@ test_that("test equilibrium with RM adults (DDE), hMoI humans, trace", { params = make_parameters_MYZ_RM(pars = params, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, solve_as="ode") params = make_inits_MYZ_RM_dde(pars = params, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z), Upsilon0=OmegaEIP) - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_hMoI(pars = params, b = b, c1 = c1, c2 = c2, r1 = r1, r2 = r2) params = make_inits_X_hMoI(pars = params, m10 = rep(m10,2), m20 = rep(m20,2)) params = make_parameters_L_trace(pars = params, Lambda = as.vector(Lambda)) diff --git a/tests/testthat/test-human-hMoI.R b/tests/testthat/test-human-hMoI.R index bade05aa..cd771c98 100644 --- a/tests/testthat/test-human-hMoI.R +++ b/tests/testthat/test-human-hMoI.R @@ -22,8 +22,9 @@ test_that("human hybrid MoI model remains at equilibrium", { params$nStrata = nStrata params$nHosts <- 1 params$nPatches = 1 - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_hMoI(pars = params, b = b, c1 = c1, c2 = c2, r1 = r1, r2 = r2) params = make_inits_X_hMoI(pars = params, m10 = rep(m10,nStrata), m20 = rep(m20,nStrata)) diff --git a/tests/testthat/test-human-sip.R b/tests/testthat/test-human-sip.R index 6d4d53e6..42db0301 100644 --- a/tests/testthat/test-human-sip.R +++ b/tests/testthat/test-human-sip.R @@ -25,8 +25,9 @@ test_that("human SIP model remains at equilibrium", { params$nHosts <- 1 params$nPatches <- 1 - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIP(pars = params, b = b, c = c, r = r, eta=eta, rho=rho, xi=xi) params = make_inits_X_SIP(pars = params, H-I-P, I, P) diff --git a/tests/testthat/test-human-sis.R b/tests/testthat/test-human-sis.R index 8da4b344..5ab2bce0 100644 --- a/tests/testthat/test-human-sis.R +++ b/tests/testthat/test-human-sis.R @@ -21,8 +21,9 @@ test_that("human SIS model remains at equilibrium", { params$nHosts <- 1 params$nPatches <- 1 - params = make_parameters_demography_null(pars = params, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + params = make_parameters_demography_null(pars = params, H=H) + params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) + params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIS(pars = params, b = b, c = c, r = r) params = make_inits_X_SIS(pars = params, H-I, I) diff --git a/tests/testthat/test-vc-lemenach.R b/tests/testthat/test-vc-lemenach.R index ac30c9db..449187e1 100644 --- a/tests/testthat/test-vc-lemenach.R +++ b/tests/testthat/test-vc-lemenach.R @@ -76,8 +76,9 @@ test_that("Le Menach VC model with 0 coverage stays roughly at equilibrium", { Lambda <- Omega %*% M # set parameters - pars = make_parameters_demography_null(pars = pars, H=H, residence=residence, - searchWts=searchWtsH, TaR=TaR) + pars = make_parameters_demography_null(pars = pars, H=H) + pars = setup_BloodFeeding(pars, 1, 1, residence=residence, searchWts=searchWtsH) + pars$BFpar$TaR[[1]][[1]]=TaR pars = make_parameters_MYZ_RM(pars = pars, g = g, sigma = sigma, calK = calK, eip = eip, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, solve_as="ode") pars = make_inits_MYZ_RM_dde(pars = pars, M0 = as.vector(M), P0 = as.vector(P), Y0 = as.vector(Y), Z0 = as.vector(Z), Upsilon0=Upsilon) pars = make_parameters_L_trace(pars = pars, Lambda = as.vector(Lambda)) diff --git a/vignettes/adult_GeRM.Rmd b/vignettes/adult_GeRM.Rmd index aaeee187..c3b0fa5a 100644 --- a/vignettes/adult_GeRM.Rmd +++ b/vignettes/adult_GeRM.Rmd @@ -123,6 +123,10 @@ library(data.table) library(ggplot2) ``` +```{r, echo=FALSE} +#devtools::load_all() +``` + Here we show an example of starting and solving a model at equilibrium. Please note that this only runs this adult mosquito model and that most users should read [our fully worked example](ex_534.html) to run a full simulation. diff --git a/vignettes/adult_RM.Rmd b/vignettes/adult_RM.Rmd index 425c43f1..e60ca3b0 100644 --- a/vignettes/adult_RM.Rmd +++ b/vignettes/adult_RM.Rmd @@ -122,7 +122,7 @@ library(data.table) library(ggplot2) ``` -```{r, echo=F, eval=F} +```{r, echo=F} #devtools::load_all() ``` @@ -271,8 +271,7 @@ To set up the model, we call `xde_setup` with Otherwise, setup takes care of all the internals: ```{r using setup} -xde_setup("MYZeg", - MYZname = "RM", Xname = "trace", Lname = "trace", +xde_setup(MYZname = "RM", Xname = "trace", Lname = "trace", nPatches=3, calK=calK, membership = c(1:3), residence = c(1:3), HPop = rep(1, 3), MYZopts = MYZo, Xopts = Xo, Lopts = Lo) -> MYZeg diff --git a/vignettes/aqua_basic.Rmd b/vignettes/aqua_basic.Rmd index 83c03589..eb32fbd2 100644 --- a/vignettes/aqua_basic.Rmd +++ b/vignettes/aqua_basic.Rmd @@ -59,6 +59,7 @@ library(ggplot2) ```{r, echo=F} #devtools::load_all() ``` + ## The long way Here we run a simple example with 3 aquatic habitats at equilibrium. We use `exDE::make_parameters_L_basic` to @@ -77,10 +78,10 @@ theta <- (eta - psi*L - phi*L)/(L^2) ```{r} params <- make_parameters_xde() params$nHabitats = nHabitats -params$eta = list() -params$eta[[1]] = eta +params$eggs_laid = list() +params$eggs_laid[[1]] = eta F_eta = function(t, pars){ - pars$eta[[1]] + pars$eggs_laid[[1]] } params = make_parameters_L_basic(pars = params, psi = psi, phi = phi, theta = theta) @@ -91,7 +92,7 @@ params = make_indices(params) ```{r} xDE_aquatic = function(t, y, pars, F_eta) { - pars$eta[[1]] <- F_eta(t, pars) + pars$eggs_laid[[1]] <- F_eta(t, pars) dL <- dLdt(t, y, pars, 1) return(list(c(dL))) } @@ -141,7 +142,7 @@ Mo = list(Gm = c(250, 500, 170)) ```{r} -xde_setup_aquatic("aqbasic", nHabitats = 3, Lname = "basic", Lopts = Lo, MYZopts = Mo) -> aqbasic +xde_setup_aquatic(nHabitats = 3, Lname = "basic", Lopts = Lo, MYZopts = Mo) -> aqbasic xde_solve(aqbasic, Tmax=50, dt=1)$output$orbits$deout -> out2 sum(abs(out1-out2)) == 0 ``` diff --git a/vignettes/aqua_trace.Rmd b/vignettes/aqua_trace.Rmd index a1adedb3..6d8fdb60 100644 --- a/vignettes/aqua_trace.Rmd +++ b/vignettes/aqua_trace.Rmd @@ -103,6 +103,8 @@ to `exDE::xDE_diffeqn_mosy`. ```{r} params = make_parameters_xde() +class(params$BFpar) <- "static" +class(params$EGGpar) <- "simple" params$nVectors = 1 params$nHosts = 1 params$nPatches = nPatches @@ -167,8 +169,7 @@ MYZo = list( ``` ```{r} -xde_setup_mosy("mosy1", - MYZname = "basicM", Lname = "trace", +xde_setup_mosy(MYZname = "basicM", Lname = "trace", nPatches = 3, membership = c(1,2,3,3), MYZopts = MYZo, calK = calK, Lopts = Lo, kappa = c(0.1, 0.075, 0.025))->mosy1 diff --git a/vignettes/ex_534.Rmd b/vignettes/ex_534.Rmd index 3f624f0a..bf37a0d2 100644 --- a/vignettes/ex_534.Rmd +++ b/vignettes/ex_534.Rmd @@ -22,6 +22,10 @@ library(ggplot2) library(deSolve) ``` +```{r, echo=F} +#devtools::load_all() +``` + # Introduction We show how to setup, solve, and analyze models of mosquito-borne pathogen transmission dynamics and control using modular software. This vignette is designed to explain modular notation by constructing a model with five aquatic habitats ($l=5$), three patches ($p=3$), and four human population strata ($n=4$). We call it `5-3-4`. @@ -92,9 +96,11 @@ The egg dispersal matrix $\mathcal{U}$ is a $l \times p$ matrix describing how e ```{r} xi <- matrix(c(.7, .2, .1, .8, .2), 5, 1) +params$EGGpar$searchWts[[1]] <- as.vector(xi) params$calU[[1]]<- t(calN %*% diag(as.vector(xi))) ``` + ## Aquatic Mosquito Parameters For this simulation, we use the basic competition model of larval dynamics (see more [here](aqua_basic.html)). It requires specification of three parameters, $\psi$ (maturation rates), $\phi$ (density-independent mortality rates), and $\theta$ (density-dependent mortality terms), and initial conditions. The function `exDE::make_parameters_L_basic` does basic checking of the input parameters and returns a list with the correct class for method dispatch. The returned list is attached to the main parameter list with name `Lpar`. @@ -149,11 +155,19 @@ params = make_inits_MYZ_RM_ode(params, M0=M0, P0=P0, ## Mixing +We use the static demographic model, which assumes a constant population size (constant $H$). + +```{r} +H <- matrix(c(10,90, 100, 900), 4, 1) +params = setup_Hpar_static(params, 1, HPop=H) +``` + In this model, we define four population strata. We can describe their residency with a vector describing residence: ```{r} residence = c(2,2,3,3) searchWtsH = c(1,1,1,1) +params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) ``` Although not directly used in this example, we create the residency membership matrix $\mathcal{J}$, a $p \times n$ matrix indicating which patch each human population strata resides in. @@ -193,17 +207,11 @@ TaR <- t(matrix( c(.95,.92,.04,.02), c(.04,.02,.959,.929)), 4, 3 )) +params$BFpar$TaR[[1]][[1]] <- TaR ``` We use the basic SIS (Susceptible-Infected-Susceptible) model for the human component (see more [here](human_sis.html)). We set it up like the rest of the components, using `exDE::make_parameters_X_SIS` to make the correct return type, which is attached to the parameter list with name `Xpar`. -We use the null demographic model, which assumes a constant population size (constant $H$). - -```{r} -H <- matrix(c(10,90, 100, 900), 4, 1) -params = setup_Hpar(params, HPop=H, residence=residence, searchWts=searchWtsH) -params$Hpar[[1]]$TaR <- TaR -``` ```{r} I0 <- as.vector(0.2*H) @@ -232,11 +240,16 @@ Now we can set the initial conditions of the model. y0 = get_inits(params) ``` +```{r} +params <- EggLaying(0, y0, params) +``` + ## Numerical Solution Now we can pass the vector of initial conditions, `y`, our parameter list `params`, and the function `exDE::xDE_diffeqn` to the differential equation solvers in `deSolve::ode` to generate a numerical trajectory. The classes of `Xpar`, `MYZpar`, and `Lpar` in `params` will ensure that the right methods are invoked (dispatched) to solve your model. ```{r} + out <- deSolve::ode(y = y0, times = 0:365, func = xDE_diffeqn, parms = params, method = "lsoda") out1 <- out @@ -309,7 +322,7 @@ xde_setup("mod534", "RM", "SIS", "basic", membership=c(1,1,1,2,2), EIPopts = EIPo, MYZopts=MYZo, calK=calK, Xopts=Xo, residence=c(2,2,3,3), searchB=searchWtsH, - TaR=TaR, searchQ = c(7,2,1,8,2), Lopts = Lo) -> mod534 + TimeSpent=TaR, searchQ = c(7,2,1,8,2), Lopts = Lo) -> mod534 ``` We solve and take the differences to check: @@ -317,7 +330,6 @@ We solve and take the differences to check: ```{r} mod534 <- xde_solve(mod534,Tmax=365,dt=1) mod534$outputs$orbits$deout -> out2 -sum(abs(out2-out1)) ``` Interestingly, the differences are small: @@ -325,31 +337,3 @@ Interestingly, the differences are small: ```{r} approx_equal(tail(out2, 1), tail(out1,1), tol = 1e-5) ``` - -After some sleuthing, it appears that these arise from a very small difference in $\cal U$. Note that `mod534$calU` appears to match `params$calU`: - -```{r} -mod534$egg_laying[[1]]$calU -> U1 -params$egg_laying[[1]]$calU -> U2 -``` -but there is a very small difference that only shows up by taking the difference: - -```{r} -U1-U2 -``` - -We can test the idea: - -```{r} -mod534$egg_laying[[1]]$calU = U2 -mod534 <- xde_solve(mod534,Tmax=365,dt=1) -mod534$outputs$orbits$deout -> out2 -sum(abs(out2-out1)) -``` - -```{r} -out2l = parse_deout(out2, mod534) -names(out2l) -``` - - diff --git a/vignettes/human_hmoi.Rmd b/vignettes/human_hmoi.Rmd index 9234e856..4b02e84d 100644 --- a/vignettes/human_hmoi.Rmd +++ b/vignettes/human_hmoi.Rmd @@ -63,6 +63,10 @@ library(data.table) library(ggplot2) ``` +```{r, echo=FALSE} +#devtools::load_all() +``` + Here we run a simple example with 3 population strata at equilibrium. We use `exDE::make_parameters_X_hMoI` to set up parameters. Please note that this only runs the human population component and that most users should read [our fully worked example](ex_534.html) to run a full simulation. @@ -104,8 +108,10 @@ F_eir = function(t, pars){ pars$EIR[[1]] = pars$eir } -params = make_parameters_demography_null(pars = params, H=H, residence=residence, searchWts=searchWtsH, TaR=TaR) +params = make_parameters_demography_null(pars = params, H=H) +params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) +params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_hMoI(pars = params, b = b, c1 = c1, c2 = c2, r1 = r1, r2 = r2) params = make_inits_X_hMoI(pars = params, rep(m10, nStrata), rep(m20, nStrata)) params = make_indices(params) diff --git a/vignettes/human_sip.Rmd b/vignettes/human_sip.Rmd index 76a0a40c..2d4e111e 100644 --- a/vignettes/human_sip.Rmd +++ b/vignettes/human_sip.Rmd @@ -51,6 +51,11 @@ library(data.table) library(ggplot2) ``` + +```{r, echo=FALSE} +#devtools::load_all() +``` + Here we run a simple example with 3 population strata at equilibrium. We use `exDE::make_parameters_X_SIP` to set up parameters. Please note that this only runs the human population component and that most users should read [our fully worked example](ex_534.html) to run a full simulation. @@ -90,7 +95,10 @@ F_eir = function(t, pars){ pars$EIR[[1]] = params$eir } -params = make_parameters_demography_null(pars = params, H=H, residence=residence, searchWts=searchWtsH, TaR=TaR) +params = make_parameters_demography_null(pars = params, H=H) + +params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts =searchWtsH) +params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIP(pars = params, b = b, c = c, r = r, rho = rho, eta = eta, xi=xi) params = make_inits_X_SIP(pars = params, H-I-P, I, as.vector(P)) diff --git a/vignettes/human_sis.Rmd b/vignettes/human_sis.Rmd index 4d2ba877..f1323527 100644 --- a/vignettes/human_sis.Rmd +++ b/vignettes/human_sis.Rmd @@ -65,6 +65,11 @@ library(data.table) library(ggplot2) ``` + +```{r, echo=FALSE} +#devtools::load_all() +``` + Here we run a simple example with 3 population strata at equilibrium. We use `exDE::make_parameters_X_SIS` to set up parameters. Please note that this only runs the human population component and that most users should read [our fully worked example](ex_534.html) to run a full simulation. @@ -102,8 +107,10 @@ F_eir = function(t, pars){ pars$EIR[[1]] = pars$eir } -params = make_parameters_demography_null(pars = params, - H=H, residence=residence, searchWts=searchWtsH, TaR=TaR) +params = make_parameters_demography_null(pars = params, H=H) + +params = setup_BloodFeeding(params, 1, 1, residence=residence, searchWts=searchWtsH) +params$BFpar$TaR[[1]][[1]]=TaR params = make_parameters_X_SIS(pars = params, b = b, c = c, r = r) diff --git a/vignettes/vc_lemenach.Rmd b/vignettes/vc_lemenach.Rmd index 1e2f406c..0ca6c237 100644 --- a/vignettes/vc_lemenach.Rmd +++ b/vignettes/vc_lemenach.Rmd @@ -26,6 +26,11 @@ library(data.table) library(ggplot2) ``` + +```{r, echo=FALSE} +#devtools::load_all() +``` + ## Parameters This case study will use a simple model with 3 patches, 3 population strata, and 3 aquatic habitats. As usual, we set up parameter values and compute the values of state variables at equilibrium. As part of the equilibrium calculation we must compute $\Upsilon(0) = \exp\left(-\int_{-\tau}^{0} \Omega(s) ds \right)$; the value of the integrated mosquito demography matrix at the initial time point. To simplify things, we simply assume that conditions were constant prior to $t=0$ so that $\Upsilon(0) = e^{-\Omega\tau}$. @@ -145,10 +150,10 @@ MYZo = list(f=f, q=q, g=g, sigma=sigma, ``` ```{r} -xde_setup("itn_mod", "RM", "SIS", "basic", +xde_setup(MYZname="RM", Xname="SIS", Lname="basic", nPatches=3, HPop=Hpop, membership=c(1:3), MYZopts=MYZo, calK=calK, Xopts=Xo, residence=1:3, searchB=rep(1,3), - TaR=TaR, searchQ=rep(1,3), Lopts=Lo) -> itn_mod + TimeSpent =TaR, searchQ=rep(1,3), Lopts=Lo) -> itn_mod ``` ```{r} @@ -184,7 +189,7 @@ colnames(out)[itn_mod$ix$MYZ[[1]]$M_ix+1] <- paste0('M_', 1:itn_mod$nPatches) colnames(out)[itn_mod$ix$MYZ[[1]]$P_ix+1] <- paste0('P_', 1:itn_mod$nPatches) colnames(out)[itn_mod$ix$MYZ[[1]]$Y_ix+1] <- paste0('Y_', 1:itn_mod$nPatches) colnames(out)[itn_mod$ix$MYZ[[1]]$Z_ix+1] <- paste0('Z_', 1:itn_mod$nPatches) -colnames(out)[itn_mod$ix$X[[1]]$X_ix+1] <- paste0('X_', 1:itn_mod$nStrata) +colnames(out)[itn_mod$ix$X[[1]]$X_ix+1] <- paste0('X_', 1:itn_mod$Hpar[[1]]$nStrata) out <- out[, -c(itn_mod$ix$MYZ[[1]]$sigma_ix+1)] out <- out[, -c(itn_mod$ix$MYZ[[1]]$g_ix+1)]