diff --git a/.gitignore b/.gitignore index d0cb56a..92b603f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ docs/*.html /docs docs/reference/ar_compare.html *.html +/docs/articles +/docs diff --git a/R/scaling.R b/R/scaling.R index c79bb60..43c501d 100644 --- a/R/scaling.R +++ b/R/scaling.R @@ -17,11 +17,10 @@ xde_scaling_eir = function(model, N=25){ for(i in 1:N){ model$EIRpar$eir <- aEIR[i]/365 model <- ramp.xds::xds_solve_cohort(model, A=10, da=1) - XH <- model$outputs$orbits$XH[[1]] - terms <- model$outputs$orbits$terms[[1]] + XH <- get_XH(model, 1) pr_t = tail(XH$true_pr, 365); pr[i] = mean(pr_t) ni_t = tail(XH$ni, 365); ni[i]= mean(ni_t) - eir_t = tail(terms$EIR, 365); eir[i] = mean(eir_t) + eir_t = tail(XH$eir, 365); eir[i] = mean(eir_t) scaling[[i]] = list(aeir = eir_t*365, eir = eir_t, pr = pr_t, ni = ni_t) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 85ce111..0cee6fa 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -62,3 +62,8 @@ reference: - xde_scaling_Z - xde_scaling_eir - xde_scaling_lambda +- title: Demography + desc: | + No methods to set subclass + contents: + - UnevenAgingMatrix diff --git a/docs/articles/Analysis.html b/docs/articles/Analysis.html index 83848d2..d9d270a 100644 --- a/docs/articles/Analysis.html +++ b/docs/articles/Analysis.html @@ -4,72 +4,84 @@ - - + Analysis • ramp.work - - - + + + - + + - - Skip to contents + -
- - + +
+ + -
-
+
+ + + - + diff --git a/docs/articles/Fitting.html b/docs/articles/Fitting.html index 365b03d..77d90e8 100644 --- a/docs/articles/Fitting.html +++ b/docs/articles/Fitting.html @@ -1,127 +1,181 @@ -Fitting Models to Data • ramp.work + + + + + +Fitting Models to Data • ramp.work + + + + + + + + - Skip to contents + + + -
- - + +
+ + -
-
- - - - + + - + + diff --git a/docs/articles/Fitting_pr2eir.html b/docs/articles/Fitting_pr2eir.html index 5dfec0f..04217e3 100644 --- a/docs/articles/Fitting_pr2eir.html +++ b/docs/articles/Fitting_pr2eir.html @@ -4,81 +4,93 @@ - - + Time Series PR to EIR • ramp.work - - - + + + - + + - - Skip to contents + -
- - + +
+ + -
-
- + + + + - + diff --git a/docs/articles/Scaling.html b/docs/articles/Scaling.html index f64a26c..37355ee 100644 --- a/docs/articles/Scaling.html +++ b/docs/articles/Scaling.html @@ -4,116 +4,135 @@ - - + Scaling for Malaria Metrics • ramp.work - - - + + + - + + - - Skip to contents + -
- - + +
+ + -
-
+

The results are attached as sis$outputs$eirpr

+

+
## Loading required package: viridis
## Loading required package: viridisLite
-
-clrs = turbo(25)
+clrs = turbo(25)
+
 plot_eirpr(sis)
 
 with(sis$output$eirpr,{
@@ -123,121 +142,63 @@ 

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

-

+

-
-

+
+

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 in mob_library/Work

We can run this for 50 randomly chosen values of the PfPR.

-
+
 preir_i = xde_pr2eir(c(0.001, runif(25, 0, 1), 0.999), sis)

The function flags any values that are outside of the acceptable range. This may not seem important for the SIS model, but the range of other models can be bounded, so we don’t want to return nonsense values.

-
+
 preir_i$errors
##         pr1         pr2         pr3 
 ## 0.001000000 0.007399441 0.999000000

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"))
-

-
-
-

Scaling -

-
-

Seasonality -

-
-sis0 <- xds_setup_cohort(Xname = "SIS", F_season = F_sin)
-xde_scaling_eir(sis0, 25) -> sis0
-
-clrs = turbo(25)
-with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-lines(sis$outputs$eirpr$aeir, sis0$outputs$eirpr$pr, col = "tomato", lwd=2) 
-
-with(sis0$outputs$eirpr, points(aeir, pr, col = clrs))
-with(sis0$outputs$eirpr, lines(scaling[[5]]$aeir, scaling[[5]]$pr, col = clrs[5]))
-with(sis0$outputs$eirpr, lines(scaling[[10]]$aeir, scaling[[10]]$pr, col = clrs[10]))
-with(sis0$outputs$eirpr, lines(scaling[[15]]$aeir, scaling[[15]]$pr, col = clrs[15]))
-with(sis0$outputs$eirpr, lines(scaling[[20]]$aeir, scaling[[20]]$pr, col = clrs[20]))
-

-
-
-

Drug taking -

-
-sip = xds_setup_cohort(Xname = "SIP", F_season=F_sin)
-sip$Xpar[[1]]$eta = 1/40
-xde_scaling_eir(sip, 25) -> sip
-
-sip1 = setup_exposure_nb(sip, 1/50)
-xde_scaling_eir(sip1, 25) -> sip1
-
-with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-with(sip$outputs$eirpr, lines(aeir, pr, col = "darkorange"))
-with(sip1$outputs$eirpr, lines(aeir, pr, col = "brown"))
-

-
-
-

Environmental Heterogeneity -

-
-sis4 <- setup_exposure_nb(sis, 1/50)
-xde_scaling_eir(sis4, 25) -> sis4
-
-with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-#with(sis2$outputs$eir, lines(aeir, pr, col = "blue"))
-#with(sis3$outputs$eir, lines(aeir, pr, col = "purple"))
-with(sis4$outputs$eir, lines(aeir, pr, col = "darkblue"))
-

-
-
-

Travel -

-
-sis5 <- setup_travel_static(sis, delta = 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"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-with(sis5$outputs$eir, lines(aeir, pr, col = "darkgreen")) 
-

-
+

+
+ + - +
-
+ diff --git a/docs/articles/Scaling_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/Scaling_files/figure-html/unnamed-chunk-11-1.png index 87ccd4f..ab34b11 100644 Binary files a/docs/articles/Scaling_files/figure-html/unnamed-chunk-11-1.png and b/docs/articles/Scaling_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/docs/articles/Scaling_files/figure-html/unnamed-chunk-8-1.png b/docs/articles/Scaling_files/figure-html/unnamed-chunk-8-1.png index 62156d8..7b083d5 100644 Binary files a/docs/articles/Scaling_files/figure-html/unnamed-chunk-8-1.png and b/docs/articles/Scaling_files/figure-html/unnamed-chunk-8-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 8fd8926..598b87d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,51 +1,61 @@ -Articles • ramp.workArticles • ramp.work - Skip to contents + -
-
-
+
+ - + diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 0d89f96..7ff7008 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -6,7 +6,7 @@ articles: Fitting_pr2eir: Fitting_pr2eir.html Fitting: Fitting.html Scaling: Scaling.html -last_built: 2024-10-04T19:06Z +last_built: 2024-10-14T15:12Z urls: reference: https://dd-harp.github.io/ramp.xds/reference article: https://dd-harp.github.io/ramp.xds/articles diff --git a/docs/reference/F_sse.html b/docs/reference/F_sse.html index da37063..cb67f54 100644 --- a/docs/reference/F_sse.html +++ b/docs/reference/F_sse.html @@ -1,61 +1,70 @@ -Sum of squared errors. Works as F_gof in xde_maximize_gof — F_sse • ramp.workSum of squared errors. Works as F_gof in xde_maximize_gof — F_sse • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
F_sse(obs, pred)
-
-

Arguments

+
+

Arguments

obs

a set of observations

@@ -64,29 +73,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ + - + diff --git a/docs/reference/ar_compare.html b/docs/reference/ar_compare.html index 4a3300b..ebe7ee6 100644 --- a/docs/reference/ar_compare.html +++ b/docs/reference/ar_compare.html @@ -1,61 +1,70 @@ -Compute the attack rate to get — ar_compare • ramp.workCompute the attack rate to get — ar_compare • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
ar_compare(ar, pr, get_pr, model, n = 1)
-
-

Arguments

+
+

Arguments

ar

the attack rate

@@ -76,29 +85,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ + - + diff --git a/docs/reference/dts_compute_gof.html b/docs/reference/dts_compute_gof.html index f24d7a4..7869919 100644 --- a/docs/reference/dts_compute_gof.html +++ b/docs/reference/dts_compute_gof.html @@ -1,61 +1,70 @@ -sum of squared errors — dts_compute_gof • ramp.worksum of squared errors — dts_compute_gof • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
dts_compute_gof(ppp, data, model, F_obs, put_par, F_gof, Tmax = 365)
-
-

Arguments

+
+

Arguments

ppp

the parameters to be fitted

@@ -84,29 +93,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ + - + diff --git a/docs/reference/dts_init_by_pr.html b/docs/reference/dts_init_by_pr.html index 6a2cd69..cf0e68a 100644 --- a/docs/reference/dts_init_by_pr.html +++ b/docs/reference/dts_init_by_pr.html @@ -1,61 +1,70 @@ -Initialize a dts model such that — dts_init_by_pr • ramp.workInitialize a dts model such that — dts_init_by_pr • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
dts_init_by_pr(pr, model, get_pr, n = 365, tol = 1e-08)
-
-

Arguments

+
+

Arguments

pr

a PR time series

@@ -76,29 +85,33 @@

Arguments -

Value

+
+

Value

the model, initialized

-

+
+ + - + diff --git a/docs/reference/dts_maximize_gof.html b/docs/reference/dts_maximize_gof.html index cb45f43..e06442e 100644 --- a/docs/reference/dts_maximize_gof.html +++ b/docs/reference/dts_maximize_gof.html @@ -1,56 +1,65 @@ -sum of squared errors — dts_maximize_gof • ramp.worksum of squared errors — dts_maximize_gof • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
dts_maximize_gof(
   data,
   model,
@@ -64,8 +73,8 @@ 

Usage )

-
-

Arguments

+
+

Arguments

data

a set of observations

@@ -102,29 +111,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ + - + diff --git a/docs/reference/dts_pr2ar_step.html b/docs/reference/dts_pr2ar_step.html index 1d072ea..d873c6e 100644 --- a/docs/reference/dts_pr2ar_step.html +++ b/docs/reference/dts_pr2ar_step.html @@ -1,61 +1,70 @@ -Compute the attack rates for a set of strata for a step-ahead algorithm — dts_pr2ar_step • ramp.workCompute the attack rates for a set of strata for a step-ahead algorithm — dts_pr2ar_step • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
dts_pr2ar_step(pr, model, get_pr, n = 365, tol = 1e-08)
-
-

Arguments

+
+

Arguments

pr

next value of the PfPR

@@ -76,29 +85,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ + - + diff --git a/docs/reference/dts_pr2ar_ts.html b/docs/reference/dts_pr2ar_ts.html index 5cdb167..a27cbd3 100644 --- a/docs/reference/dts_pr2ar_ts.html +++ b/docs/reference/dts_pr2ar_ts.html @@ -1,61 +1,70 @@ -Compute the attack rate to get — dts_pr2ar_ts • ramp.workCompute the attack rate to get — dts_pr2ar_ts • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
dts_pr2ar_ts(pr, model, get_pr, tol = 1e-08)
-
-

Arguments

+
+

Arguments

pr

a PR time series

@@ -72,29 +81,33 @@

Arguments -

Value

+
+

Value

a vector of attack rates, as a time series

-

+
+ + - + diff --git a/docs/reference/index.html b/docs/reference/index.html index 580b9bd..3712db9 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,215 +1,211 @@ -Function reference • ramp.workFunction reference • ramp.work - Skip to contents + -
-
-
+
+
+ -
-

All functions

- - -
- - - +
+
+ -
- - F_sse() -
-
Sum of squared errors. Works as F_gof in xde_maximize_gof
-
- - ar_compare() -
-
Compute the attack rate to get
-
- - dts_compute_gof() -
-
sum of squared errors
-
- - dts_init_by_pr() -
-
Initialize a dts model such that
-
- - dts_maximize_gof() -
-
sum of squared errors
-
- - dts_pr2ar_step() -
-
Compute the attack rates for a set of strata for a step-ahead algorithm
-
- - dts_pr2ar_ts() -
-
Compute the attack rate to get
-
- - lines_eirVpr() -
-
Add lines for the EIR(t) *vs.* the PR(t)
-
- - lines_eirpr() -
-
Add lines for an eir-pr scaling relationship
-
- - mean_phase_peak() -
-
Compute the phase of the peak
-
- - plot_eirVpr() -
-
Plot EIR(t) *vs.* the PR(t)
-
- - plot_eirpr() -
-
Plot the eir-pr scaling relationship
-
- - pr2Lambda() -
-
Using the eirpr matrix and a RM model, convert pr to Lambda
-
- - split_stratum_by_biting() -
-
Split a stratum into two strata, assigning
-
- - ssMYZ() -
-
Set up the MYZss object for `xde_scaling_lambda`
-
- - update_by_ar() -
-
Compute the next y
-
- - xde_compute_gof() -
-
sum of squared errors
-
- - xde_eir2ni() -
-
Convert eir to ni
-
- - xde_eir2pr() -
-
Convert eir to pr
-
- - xde_maximize_gof() -
-
sum of squared errors
-
- - xde_pr2eir() -
-
Convert pr to eir
-
- - xde_pr2lambda() -
-
Convert pr to lambda
-
- - xde_pr2m() -
-
Convert pr to mosquito density
-
- - xde_pr2ni() -
-
Convert pr to ni
-
- - xde_scaling() -
-
Construct an eirpr object for an arbitary model
-
- - xde_scaling_Z() -
-
Compute eir-pr scaling relationships
-
- - xde_scaling_eir() -
-
Compute eir-pr scaling relationships
-
- - xde_scaling_lambda() -
-
Compute lambda from an eirpr object using the Ross-Macdonald model
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

No methods yet

+

Methods do not exist

+
+

No subclass exists

+

No methods to set subclass

+
+

ar_compare()

+

Compute the attack rate to get

+

lines_eirVpr()

+

Add lines for the EIR(t) *vs.* the PR(t)

+

lines_eirpr()

+

Add lines for an eir-pr scaling relationship

+

mean_phase_peak()

+

Compute the phase of the peak

+

ssMYZ()

+

Set up the MYZss object for `xde_scaling_lambda`

+

Fitting

+

No methods to set subclass

+
+

update_by_ar()

+

Compute the next y

+

xde_compute_gof()

+

sum of squared errors

+

dts_compute_gof()

+

sum of squared errors

+

dts_init_by_pr()

+

Initialize a dts model such that

+

dts_maximize_gof()

+

sum of squared errors

+

dts_pr2ar_step()

+

Compute the attack rates for a set of strata for a step-ahead algorithm

+

dts_pr2ar_ts()

+

Compute the attack rate to get

+

F_sse()

+

Sum of squared errors. Works as F_gof in xde_maximize_gof

+

Scaling

+

No methods to set subclass

+
+

plot_eirVpr()

+

Plot EIR(t) *vs.* the PR(t)

+

plot_eirpr()

+

Plot the eir-pr scaling relationship

+

pr2Lambda()

+

Using the eirpr matrix and a RM model, convert pr to Lambda

+

xde_eir2ni()

+

Convert eir to ni

+

xde_eir2pr()

+

Convert eir to pr

+

xde_maximize_gof()

+

sum of squared errors

+

xde_pr2eir()

+

Convert pr to eir

+

xde_pr2lambda()

+

Convert pr to lambda

+

xde_pr2m()

+

Convert pr to mosquito density

+

xde_pr2ni()

+

Convert pr to ni

+

xde_scaling()

+

Construct an eirpr object for an arbitary model

+

xde_scaling_Z()

+

Compute eir-pr scaling relationships

+

xde_scaling_eir()

+

Compute eir-pr scaling relationships

+

xde_scaling_lambda()

+

Compute lambda from an eirpr object using the Ross-Macdonald model

+

Demography

+

No methods to set subclass

+
+

UnevenAgingMatrix()

+

Create a cohort matrix

+ + + - + diff --git a/docs/reference/lines_eirVpr.html b/docs/reference/lines_eirVpr.html index dbc0e6b..3d6621b 100644 --- a/docs/reference/lines_eirVpr.html +++ b/docs/reference/lines_eirVpr.html @@ -1,61 +1,70 @@ -Add lines for the EIR(t) *vs.* the PR(t) — lines_eirVpr • ramp.workAdd lines for the EIR(t) *vs.* the PR(t) — lines_eirVpr • ramp.work - Skip to contents + -
-
-
-
+

Add lines for the EIR(t) *vs.* the PR(t)

-
-

Usage

+
lines_eirVpr(eir, pr, nStrata, clrs = "black", llty = 1)
-
-

Arguments

+
+

Arguments

eir

the daily EIR

@@ -77,22 +86,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/lines_eirpr.html b/docs/reference/lines_eirpr.html index eb2c575..2fc0808 100644 --- a/docs/reference/lines_eirpr.html +++ b/docs/reference/lines_eirpr.html @@ -1,61 +1,70 @@ -Add lines for an eir-pr scaling relationship — lines_eirpr • ramp.workAdd lines for an eir-pr scaling relationship — lines_eirpr • ramp.work - Skip to contents + -
-
-
-
+

Add lines for an eir-pr scaling relationship

-
-

Usage

+
lines_eirpr(pars, clrs = "black", llty = 1)
-
-

Arguments

+
+

Arguments

pars

a [list] *e.g.*, generated by `ramp.xds::xde_setup()` that defines a model in `ramp.xds`

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/plot_eirVpr.html b/docs/reference/plot_eirVpr.html index ebe6903..5d985d3 100644 --- a/docs/reference/plot_eirVpr.html +++ b/docs/reference/plot_eirVpr.html @@ -1,56 +1,65 @@ -Plot EIR(t) *vs.* the PR(t) — plot_eirVpr • ramp.workPlot EIR(t) *vs.* the PR(t) — plot_eirVpr • ramp.work - Skip to contents + -
-
-
-
+

Plot EIR(t) *vs.* the PR(t)

-
-

Usage

+
plot_eirVpr(
   pars,
   i = 1,
@@ -61,8 +70,8 @@ 

Usage )

-
-

Arguments

+
+

Arguments

pars

a [list] that defines an `ramp.xds` model (*e.g.*, generated by `ramp.xds::xde_setup()`)

@@ -88,22 +97,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/plot_eirpr.html b/docs/reference/plot_eirpr.html index c900850..d95c949 100644 --- a/docs/reference/plot_eirpr.html +++ b/docs/reference/plot_eirpr.html @@ -1,61 +1,70 @@ -Plot the eir-pr scaling relationship — plot_eirpr • ramp.workPlot the eir-pr scaling relationship — plot_eirpr • ramp.work - Skip to contents + -
-
-
-
+

Plot the eir-pr scaling relationship

-
-

Usage

+
plot_eirpr(pars, clrs = "black", llty = 1)
-
-

Arguments

+
+

Arguments

pars

a [list] *e.g.*, generated by `ramp.xds::xde_setup()` that defines a model in `ramp.xds`

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/pr2Lambda.html b/docs/reference/pr2Lambda.html index 8075757..f1269c8 100644 --- a/docs/reference/pr2Lambda.html +++ b/docs/reference/pr2Lambda.html @@ -1,64 +1,72 @@ -Using the eirpr matrix and a RM model, convert pr to Lambda — pr2Lambda • ramp.workUsing the eirpr matrix and a RM model, convert pr to Lambda — pr2Lambda • ramp.work - Skip to contents + -
-
-
-
+

This takes a model and uses the XH component to define the eirpr relationship using `xde_scaling_eir` then calls `xde_scaling_lambda`

-
-

Usage

+
pr2Lambda(pr, model, constrain = TRUE)
-
-

Arguments

+
+

Arguments

pr

a vector

@@ -72,22 +80,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/ssMYZ.html b/docs/reference/ssMYZ.html index 4ead593..849b063 100644 --- a/docs/reference/ssMYZ.html +++ b/docs/reference/ssMYZ.html @@ -1,82 +1,95 @@ -Set up the MYZss object for `xde_scaling_lambda` — ssMYZ • ramp.workSet up the MYZss object for `xde_scaling_lambda` — ssMYZ • ramp.work - Skip to contents + -
-
-
-
+

This function computes several quantities that are require

-
-

Usage

+
ssMYZ(model)
-
-

Arguments

+
+

Arguments

model

a list that defines an `ramp.xds` model (*e.g.*, generated by `xds_setup()`)

-
+
+ +
-
+
+ diff --git a/docs/reference/update_by_ar.html b/docs/reference/update_by_ar.html index 7f56627..34612e2 100644 --- a/docs/reference/update_by_ar.html +++ b/docs/reference/update_by_ar.html @@ -1,61 +1,70 @@ -Compute the next y — update_by_ar • ramp.workCompute the next y — update_by_ar • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
update_by_ar(ar, model, n = 365)
-
-

Arguments

+
+

Arguments

ar

the attack rate

@@ -68,29 +77,33 @@

Arguments -

Value

+
+

Value

a vector of state variables, y

-

+
+ +
-
+
+ diff --git a/docs/reference/xde_compute_gof.html b/docs/reference/xde_compute_gof.html index 756b780..e8245cc 100644 --- a/docs/reference/xde_compute_gof.html +++ b/docs/reference/xde_compute_gof.html @@ -1,61 +1,70 @@ -sum of squared errors — xde_compute_gof • ramp.worksum of squared errors — xde_compute_gof • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
xde_compute_gof(ppp, data, model, F_obs, put_par, F_gof, Tmax = 3650)
-
-

Arguments

+
+

Arguments

ppp

the parameters to be fitted

@@ -84,29 +93,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ +
-
+
+ diff --git a/docs/reference/xde_eir2ni.html b/docs/reference/xde_eir2ni.html index 2b62104..d1c1eb5 100644 --- a/docs/reference/xde_eir2ni.html +++ b/docs/reference/xde_eir2ni.html @@ -1,61 +1,70 @@ -Convert eir to ni — xde_eir2ni • ramp.workConvert eir to ni — xde_eir2ni • ramp.work - Skip to contents + -
-
-
-
+

Use the outputs$eirpr table to interpolate

-
-

Usage

+
xde_eir2ni(eir, model, extend = FALSE)
-
-

Arguments

+
+

Arguments

eir

a [vector]

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_eir2pr.html b/docs/reference/xde_eir2pr.html index 929c9f3..5d563b4 100644 --- a/docs/reference/xde_eir2pr.html +++ b/docs/reference/xde_eir2pr.html @@ -1,61 +1,70 @@ -Convert eir to pr — xde_eir2pr • ramp.workConvert eir to pr — xde_eir2pr • ramp.work - Skip to contents + -
-
-
-
+

Use the outputs$eirpr table to interpolate

-
-

Usage

+
xde_eir2pr(eir, model, extend = FALSE)
-
-

Arguments

+
+

Arguments

eir

a [vector]

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_maximize_gof.html b/docs/reference/xde_maximize_gof.html index 42ebc29..480d11b 100644 --- a/docs/reference/xde_maximize_gof.html +++ b/docs/reference/xde_maximize_gof.html @@ -1,56 +1,65 @@ -sum of squared errors — xde_maximize_gof • ramp.worksum of squared errors — xde_maximize_gof • ramp.work - Skip to contents + -
-
-
-
+

Compute the sum of squared errors

-
-

Usage

+
xde_maximize_gof(
   data,
   model,
@@ -63,8 +72,8 @@ 

Usage )

-
-

Arguments

+
+

Arguments

data

a set of observations

@@ -97,29 +106,33 @@

Arguments -

Value

+
+

Value

the sum of squared errors

-

+
+ +
-
+
+ diff --git a/docs/reference/xde_pr2eir.html b/docs/reference/xde_pr2eir.html index c956efa..2aa005e 100644 --- a/docs/reference/xde_pr2eir.html +++ b/docs/reference/xde_pr2eir.html @@ -1,61 +1,70 @@ -Convert pr to eir — xde_pr2eir • ramp.workConvert pr to eir — xde_pr2eir • ramp.work - Skip to contents + -
-
-
-
+

Use the outputs$eirpr table to convert a set of pr values into eir values

-
-

Usage

+
xde_pr2eir(pr, model, extend = FALSE)
-
-

Arguments

+
+

Arguments

pr

a [vector]

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_pr2lambda.html b/docs/reference/xde_pr2lambda.html index d20a5b2..dec32d8 100644 --- a/docs/reference/xde_pr2lambda.html +++ b/docs/reference/xde_pr2lambda.html @@ -1,61 +1,70 @@ -Convert pr to lambda — xde_pr2lambda • ramp.workConvert pr to lambda — xde_pr2lambda • ramp.work - Skip to contents + -
-
-
-
+

Use the outputs$lambdapr table to convert a set of pr values into lambda values

-
-

Usage

+
xde_pr2lambda(pr, model, extend = FALSE)
-
-

Arguments

+
+

Arguments

pr

a [vector]

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_pr2m.html b/docs/reference/xde_pr2m.html index effa617..b24f89c 100644 --- a/docs/reference/xde_pr2m.html +++ b/docs/reference/xde_pr2m.html @@ -1,61 +1,70 @@ -Convert pr to mosquito density — xde_pr2m • ramp.workConvert pr to mosquito density — xde_pr2m • ramp.work - Skip to contents + -
-
-
-
+

Use the outputs$eirpr table to convert a set of pr values into scaled mosquito density values

-
-

Usage

+
xde_pr2m(pr, model, extend = FALSE)
-
-

Arguments

+
+

Arguments

pr

a [vector]

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_pr2ni.html b/docs/reference/xde_pr2ni.html index eb01478..2378c69 100644 --- a/docs/reference/xde_pr2ni.html +++ b/docs/reference/xde_pr2ni.html @@ -1,61 +1,70 @@ -Convert pr to ni — xde_pr2ni • ramp.workConvert pr to ni — xde_pr2ni • ramp.work - Skip to contents + -
-
-
-
+

Use the outputs$eirpr table to interpolate

-
-

Usage

+
xde_pr2ni(pr, model, extend = FALSE)
-
-

Arguments

+
+

Arguments

pr

a [vector]

@@ -69,22 +78,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_scaling.html b/docs/reference/xde_scaling.html index 14f6c0d..53bef92 100644 --- a/docs/reference/xde_scaling.html +++ b/docs/reference/xde_scaling.html @@ -1,64 +1,72 @@ -Construct an eirpr object for an arbitary model — xde_scaling • ramp.workConstruct an eirpr object for an arbitary model — xde_scaling • ramp.work - Skip to contents + -
-
-
-
+

This takes a model and uses the XH component to define the eirpr relationship using `xde_scaling_eir` then calls `xde_scaling_lambda`

-
-

Usage

+
xde_scaling(model, N = 25, F_eir = NULL)
-
-

Arguments

+
+

Arguments

model

a list that defines an `ramp.xds` model (*e.g.*, generated by `xde_setup()`)

@@ -72,22 +80,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_scaling_Z.html b/docs/reference/xde_scaling_Z.html index f3da1a4..daee09b 100644 --- a/docs/reference/xde_scaling_Z.html +++ b/docs/reference/xde_scaling_Z.html @@ -1,64 +1,72 @@ -Compute eir-pr scaling relationships — xde_scaling_Z • ramp.work - Skip to contents + -
-
-
-
+

This function computes average annual values for the eir, the pr, and other interesting terms and returns a table. It is computed for a model of class "human"

-
-

Usage

+
xde_scaling_Z(model, N = 25)
-
-

Arguments

+
+

Arguments

model

a list that defines an `ramp.xds` model generated by `xde_setup_human()`

@@ -68,22 +76,26 @@

Arguments

+
+ +
-
+ diff --git a/docs/reference/xde_scaling_eir.html b/docs/reference/xde_scaling_eir.html index a88e7d9..1988e14 100644 --- a/docs/reference/xde_scaling_eir.html +++ b/docs/reference/xde_scaling_eir.html @@ -1,64 +1,72 @@ -Compute eir-pr scaling relationships — xde_scaling_eir • ramp.work - Skip to contents + -
-
-
-
+

This function calls [xde_solve_cohort] computes average annual values for the eir, the pr, and other interesting terms and returns a table. It is computed for a model of class "cohort"

-
-

Usage

+
xde_scaling_eir(model, N = 25)
-
-

Arguments

+
+

Arguments

model

a list that defines an `ramp.xds` model generated by `xde_setup_cohort()`

@@ -67,29 +75,33 @@

Arguments -

Value

+
+

Value

**`xds`** model object

-

+
+ +
-
+
+ diff --git a/docs/reference/xde_scaling_lambda.html b/docs/reference/xde_scaling_lambda.html index 5151f47..482b69e 100644 --- a/docs/reference/xde_scaling_lambda.html +++ b/docs/reference/xde_scaling_lambda.html @@ -1,85 +1,97 @@ -Compute lambda from an eirpr object using the Ross-Macdonald model — xde_scaling_lambda • ramp.workCompute lambda from an eirpr object using the Ross-Macdonald model — xde_scaling_lambda • ramp.work - Skip to contents + -
-
-
-
+

This function computes `m` and `lambda` for the output of one of `xde_scaling_eir` or `xde_scaling_Z`. The outputs are attached to eirpr

-
-

Usage

+
xde_scaling_lambda(model)
-
-

Arguments

+
+

Arguments

model

a list that defines an `ramp.xds` model (*e.g.*, generated by `xds_setup()`)

-
+
+ +
-
+
+ diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 924bbc6..2e99fe0 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -33,6 +33,9 @@ https://dd-harp.github.io/ramp.xds/reference/F_sse.html + + https://dd-harp.github.io/ramp.xds/reference/UnevenAgingMatrix.html + https://dd-harp.github.io/ramp.xds/reference/ar_compare.html diff --git a/vignettes/Scaling.R b/vignettes/Scaling.R index 3ce238a..96c1009 100644 --- a/vignettes/Scaling.R +++ b/vignettes/Scaling.R @@ -1,11 +1,10 @@ ## ----------------------------------------------------------------------------- library(ramp.xds) -library(deSolve) -library(rootSolve) library(ramp.work) +library(deSolve) ## ----echo=F------------------------------------------------------------------- -devtools::load_all() +#devtools::load_all() ## ----Fsin--------------------------------------------------------------------- tt <- seq(0, 730, by=5) @@ -51,54 +50,3 @@ plot_eirpr(sis) with(sis$outputs$eirpr, points(aeir, pr, pch = 15)) with(preir_i, points(365*eir, pr, pch = 19, col = "red")) -## ----------------------------------------------------------------------------- -sis0 <- xds_setup_cohort(Xname = "SIS", F_season = Fsin) -xde_scaling_eir(sis0, 25) -> sis0 - -## ----------------------------------------------------------------------------- -clrs = turbo(25) -with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR")) -axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000)) -lines(sis$outputs$eirpr$aeir, sis0$outputs$eirpr$pr, col = "tomato", lwd=2) - -with(sis0$outputs$eirpr, points(aeir, pr, col = clrs)) -with(sis0$outputs$eirpr, lines(scaling[[5]]$aeir, scaling[[5]]$pr, col = clrs[5])) -with(sis0$outputs$eirpr, lines(scaling[[10]]$aeir, scaling[[10]]$pr, col = clrs[10])) -with(sis0$outputs$eirpr, lines(scaling[[15]]$aeir, scaling[[15]]$pr, col = clrs[15])) -with(sis0$outputs$eirpr, lines(scaling[[20]]$aeir, scaling[[20]]$pr, col = clrs[20])) - -## ----eval=F------------------------------------------------------------------- -# sip = xds_setup_cohort(Xname = "SIP", F_season=Fsin) -# sip$Xpar[[1]]$eta = 1/40 -# xde_scaling_eir(sip, 25) -> sip - -## ----eval=F------------------------------------------------------------------- -# sip1 = setup_exposure_nb(sip, 1/50) -# xde_scaling_eir(sip1, 25) -> sip1 - -## ----eval=F------------------------------------------------------------------- -# with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR")) -# axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000)) -# with(sip$outputs$eirpr, lines(aeir, pr, col = "darkorange")) -# with(sip1$outputs$eirpr, lines(aeir, pr, col = "brown")) - -## ----------------------------------------------------------------------------- -sis4 <- setup_exposure_nb(sis, 1/50) -xde_scaling_eir(sis4, 25) -> sis4 - -## ----------------------------------------------------------------------------- -with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR")) -axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000)) -#with(sis2$outputs$eir, lines(aeir, pr, col = "blue")) -#with(sis3$outputs$eir, lines(aeir, pr, col = "purple")) -with(sis4$outputs$eir, lines(aeir, pr, col = "darkblue")) - -## ----------------------------------------------------------------------------- -sis5 <- setup_travel_static(sis, delta = 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")) -axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000)) -with(sis5$outputs$eir, lines(aeir, pr, col = "darkgreen")) - diff --git a/vignettes/Scaling.html b/vignettes/Scaling.html index 4a8fb37..2c71deb 100644 --- a/vignettes/Scaling.html +++ b/vignettes/Scaling.html @@ -10,7 +10,7 @@ - + Scaling for Malaria Metrics @@ -374,37 +374,41 @@

Scaling for Malaria Metrics

-

October 09, 2024

+

October 14, 2024

Load the required packages:

library(ramp.xds)
-library(deSolve)
-library(rootSolve)
-library(ramp.work)
-
## ℹ Loading ramp.work
-
-

Scaling

-

This is a dog.

+library(ramp.work) +library(deSolve) +

An important question in malaria is the relationship between various +metrics, especially the relationship between the annual entomological +inoculation rate (aEIR) and the parasite rate (PR). To facilitate +analysis of malaria data, we have developed some functions to compute +scaling relationships.

xde_scaling

The function xde_scaling() defines the relationship -between the EIR and the PR, and it outputs stable orbits for each value -of aEIR in a mesh from \(10^{-1}\) up -to \(10^{3}\) The code is in +between the EIR and the PR. It analyzes stable orbits and outputs the +average annual EIR and average annual PR for an even mesh of +log(aEIR) values running from \(10^{-1}\) up to \(10^{3}\) The code is in mob_library/Work

-

The cohort trace functions in ramp.xds take the form of -F(a, bday=0, scale=1).

+

To illustrate, we pick a function describing a seasonal pattern using +ramp.xds::make_F_sin

tt <- seq(0, 730, by=5) 
 p1 <- makepar_F_sin(floor=0.1)
 Fsin <- make_function(p1)
 plot(tt, Fsin(tt), type="l")

+

Next, we set up a cohort model:

xds_setup_cohort(Xname = "SIS", F_season=Fsin) -> sis
xds_solve_cohort(sis) -> sis
+

The function xde_scaling_eir runs the model over a mesh +of N=25 values:

xde_scaling_eir(sis, 25) -> sis
+

The results are attached as sis$outputs$eirpr

plot_eirpr(sis)

require(viridis)
@@ -436,65 +440,13 @@

xde_pr2eir()

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

preir_i$errors
-
##         pr1         pr2         pr3         pr4 
-## 0.001000000 0.004284405 0.012302189 0.999000000
+
##        pr1        pr2        pr3 
+## 0.00100000 0.01081455 0.99900000

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"))
-

-
-
-

Scaling

-
-

Seasonality

-
sis0 <- xds_setup_cohort(Xname = "SIS", F_season = Fsin)
-xde_scaling_eir(sis0, 25) -> sis0
-
clrs = turbo(25)
-with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-lines(sis$outputs$eirpr$aeir, sis0$outputs$eirpr$pr, col = "tomato", lwd=2) 
-
-with(sis0$outputs$eirpr, points(aeir, pr, col = clrs))
-with(sis0$outputs$eirpr, lines(scaling[[5]]$aeir, scaling[[5]]$pr, col = clrs[5]))
-with(sis0$outputs$eirpr, lines(scaling[[10]]$aeir, scaling[[10]]$pr, col = clrs[10]))
-with(sis0$outputs$eirpr, lines(scaling[[15]]$aeir, scaling[[15]]$pr, col = clrs[15]))
-with(sis0$outputs$eirpr, lines(scaling[[20]]$aeir, scaling[[20]]$pr, col = clrs[20]))
-

-
-
-

Drug taking

-
sip = xds_setup_cohort(Xname = "SIP", F_season=Fsin)
-sip$Xpar[[1]]$eta = 1/40
-xde_scaling_eir(sip, 25) -> sip
-
sip1 = setup_exposure_nb(sip, 1/50)
-xde_scaling_eir(sip1, 25) -> sip1
-
with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-with(sip$outputs$eirpr, lines(aeir, pr, col = "darkorange"))
-with(sip1$outputs$eirpr, lines(aeir, pr, col = "brown"))
-
-
-

Environmental Heterogeneity

-
sis4 <- setup_exposure_nb(sis, 1/50)
-xde_scaling_eir(sis4, 25) -> sis4
-
with(sis$outputs$eirpr, plot(aeir, pr, type = "l", log = "x", xaxt= "n", xlab = "aEIR", ylab = "PR"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-#with(sis2$outputs$eir, lines(aeir, pr, col = "blue"))
-#with(sis3$outputs$eir, lines(aeir, pr, col = "purple"))
-with(sis4$outputs$eir, lines(aeir, pr, col = "darkblue"))
-

-
-
-

Travel

-
sis5 <- setup_travel_static(sis, delta = 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"))
-axis(1, 10^(-1:3), c(0.1, 1, 10, 100, 1000))
-with(sis5$outputs$eir, lines(aeir, pr, col = "darkgreen")) 
-

-
-
+