From 84fe8919df25f862e2889979ab880d20e6092f47 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 15 Mar 2024 08:39:29 -0700 Subject: [PATCH] fixed error in RMG --- R/MYZmod-RMG.R | 5 +- man/make_MYZpar_RMG.Rd | 2 +- vignettes/MYZmod-RMG.R | 3 ++ vignettes/MYZmod-RMG.Rmd | 4 ++ vignettes/MYZmod-RMG.html | 8 +-- vignettes/Scaling.html | 110 ++++++++------------------------------ 6 files changed, 38 insertions(+), 94 deletions(-) diff --git a/R/MYZmod-RMG.R b/R/MYZmod-RMG.R index 14686e5..121133c 100644 --- a/R/MYZmod-RMG.R +++ b/R/MYZmod-RMG.R @@ -10,7 +10,7 @@ MBionomics.RMG <- function(t, y, pars, s) { pars$MYZpar[[s]]$f <- f0 pars$MYZpar[[s]]$q <- q0 pars$MYZpar[[s]]$g <- g0 - pars$MYZpar[[s]]$phi <- 1/phi0 + pars$MYZpar[[s]]$phi <- phi0 pars$MYZpar[[s]]$sigma <- sigma0 pars$MYZpar[[s]]$nu <- nu0 @@ -111,7 +111,7 @@ setup_MYZpar.RMG = function(MYZname, pars, s, MYZopts=list(), EIPmod, calK){ #' @return a [list] #' @export make_MYZpar_RMG = function(nPatches, MYZopts=list(), EIPmod, calK, - g=1/12, sigma=1/8, f=0.3, q=0.95, + g=1/12, sigma=1/8, f=0.5, q=0.95, nu=1, eggsPerBatch=60){ stopifnot(is.matrix(calK)) @@ -131,6 +131,7 @@ make_MYZpar_RMG = function(nPatches, MYZopts=list(), EIPmod, calK, MYZpar$q <- checkIt(q, nPatches) MYZpar$nu <- checkIt(nu, nPatches) MYZpar$eggsPerBatch <- eggsPerBatch + MYZpar$phi <- 1/MYZpar$eip # Store as baseline values MYZpar$g0 <- MYZpar$g diff --git a/man/make_MYZpar_RMG.Rd b/man/make_MYZpar_RMG.Rd index 521c277..313f38b 100644 --- a/man/make_MYZpar_RMG.Rd +++ b/man/make_MYZpar_RMG.Rd @@ -11,7 +11,7 @@ make_MYZpar_RMG( calK, g = 1/12, sigma = 1/8, - f = 0.3, + f = 0.5, q = 0.95, nu = 1, eggsPerBatch = 60 diff --git a/vignettes/MYZmod-RMG.R b/vignettes/MYZmod-RMG.R index d718dca..86c0a64 100644 --- a/vignettes/MYZmod-RMG.R +++ b/vignettes/MYZmod-RMG.R @@ -14,3 +14,6 @@ xde_plot_M(model) xde_plot_YZ(model, add_axes = F) xde_plot_YZ_fracs(model) +## ----------------------------------------------------------------------------- +xde_plot_YZ_fracs(model) + diff --git a/vignettes/MYZmod-RMG.Rmd b/vignettes/MYZmod-RMG.Rmd index 6420d7c..1fdc288 100644 --- a/vignettes/MYZmod-RMG.Rmd +++ b/vignettes/MYZmod-RMG.Rmd @@ -129,5 +129,9 @@ xde_plot_YZ(model, add_axes = F) xde_plot_YZ_fracs(model) ``` +```{r} +xde_plot_YZ_fracs(model) +``` + diff --git a/vignettes/MYZmod-RMG.html b/vignettes/MYZmod-RMG.html index ad4e0f9..efa1655 100644 --- a/vignettes/MYZmod-RMG.html +++ b/vignettes/MYZmod-RMG.html @@ -10,7 +10,7 @@ - + The adult mosquito model RMG @@ -375,7 +375,7 @@

The adult mosquito model RMG

A Behavioral State Model

-

February 02, 2024

+

March 15, 2024

@@ -501,7 +501,9 @@

Implementation

xde_plot_M(model) xde_plot_YZ(model, add_axes = F) xde_plot_YZ_fracs(model) -

+

+
xde_plot_YZ_fracs(model)
+


diff --git a/vignettes/Scaling.html b/vignettes/Scaling.html index 27dd71c..8279e3f 100644 --- a/vignettes/Scaling.html +++ b/vignettes/Scaling.html @@ -10,7 +10,7 @@ - + Scaling for Malaria Metrics @@ -374,7 +374,7 @@

Scaling for Malaria Metrics

-

February 26, 2024

+

March 15, 2024

@@ -426,8 +426,8 @@

February 26, 2024

lines(scaling[[20]]$aeir, scaling[[20]]$pr, col = clrs[20]) })

-
-

xde_pr2eir()

+
+

xde_pr2eir()

Since xde_scaling defines the relationship between the EIR and the PR, we can now run xde_pr2eir() to get the predicted value of the eir, for any given value of the pr. The code is @@ -440,19 +440,19 @@

xde_pr2eir()

other models can be bounded, so we don’t want to return nonsense values.

preir_i$errors
-
##          pr1          pr2          pr3          pr4 
-## 0.0010000000 0.0007699528 0.9962306528 0.9990000000
+
##   pr1   pr2 
+## 0.001 0.999

We can plot the others:

plot_eirpr(sis)
 with(sis$outputs$eirpr, points(aeir, pr, pch = 15))
 with(preir_i, points(365*eir, pr, pch = 19, col = "red"))
-

+

-
-

xde_calibrate()

+
+

xde_calibrate()

-
-

split_stratum()

+
+

split_stratum()

In ~/mob_library/Stratification.Rmd we define the S3 function split_stratum_by_biting. Here, we use it to split a population into

@@ -468,8 +468,9 @@

split_stratum()

Scaling

-
-

\(\oplus\)

+
+
+

\(\oplus\)

To do

  • Codify the plotting protocols for \(\cal X\)

  • @@ -478,8 +479,8 @@

    \(\oplus\)

  • Get SIP up and running

-
-

Seasonality

+
+

Seasonality

F_eir0 = function(a, bday=0, scale=1){scale*(0*a+1)}
sis0 = xde_setup_cohort(F_eir0)
 xde_scaling_eir(sis0, 25) -> sis0
@@ -495,8 +496,8 @@

Seasonality

with(sis$outputs$eirpr, lines(scaling[[20]]$aeir, scaling[[20]]$pr, col = clrs[20]))

-
-

Drug taking

+
+

Drug taking

sip = xde_setup_cohort(F_eir0, Xname = "SIP")
 sip$Xpar[[1]]$eta = 1/40
 xde_scaling_eir(sip, 25) -> sip
@@ -508,8 +509,8 @@ 

Drug taking

with(sip1$outputs$eirpr, lines(aeir, pr, col = "brown"))

-
-

Heterogeneity

+
+

Heterogeneity

#sis3 <- setup_exposure_nb(sis2, 1/50)
 sis4 <- setup_exposure_nb(sis, 1/50)
 #xde_scaling_eir(sis3, 25) -> sis3
@@ -521,8 +522,8 @@ 

Heterogeneity

with(sis4$outputs$eir, lines(aeir, pr, col = "darkblue"))

-
-

travel

+
+

travel

sis5 <- setup_travel_foi(sis, delta_scale = 1/5/365)
 xde_scaling_eir(sis5, 25) -> sis5
with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
@@ -530,73 +531,6 @@ 

travel

with(sis5$outputs$eir, lines(aeir, pr, col = "darkgreen"))

-
-

cohorts

-

To do

-

Fix eir2pr so it works.

-

source_mob_library()

-

eir2pr_steady(rm) -> ep

-
-
-
-

\(\boxplus\)

-
-

\(\oplus\)

-
-
-

What is a model?

-

Model -scoping

-
-

Scoping is the act of identifying a subset of elements within a -larger set. When you scope a data model, you create a diagram to hold -all the elements that are part of your scope. The diagram represents a -view of your scope. Attributes that are part of the scope are -highlighted with a color. Attributes that are not part of the scope are -set as non-persistent.

-
-

[Model Features]

-

range / skill / adequacy

-
-
-

parse_deout

-
    -
  • the function parse_deout should compute and store -all of these quantities

    -
      -
    • the true PR

      -
        -
      • by season

      • -
      • by age from age_membership

      • -
      • by sex from sex_membership

      • -
      • by location - requires -patch_membership

      • -
      • by trait - requires -trait_membership

      • -
    • -
    • the observed PR

      -
        -
      • with generic simple detection

      • -
      • by light microscopy (if defined)

      • -
      • by RDT (if defined)

      • -
      • by PCR (if defined)

      • -
    • -
    • the EIR

    • -
  • -
-
-
-

other exDE

-
    -
  • Finalize the changes to accommodate Exogenous -Forcing

  • -
  • I/O

  • -
  • copy solving.R to steady.R and copy the -xde_solve family of functions to -xde_steady

  • -
-
-