Skip to content

Commit

Permalink
fix: replace run_seromodel by fit_seromodel in examples and vigne…
Browse files Browse the repository at this point in the history
…ttes
  • Loading branch information
ntorresd committed Apr 30, 2024
1 parent df425fe commit 20555d6
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 31 deletions.
2 changes: 1 addition & 1 deletion R/model_comparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(serodata = chagas2012)
#' model_constant <- run_seromodel(
#' model_constant <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant",
#' iter = 1500
Expand Down
6 changes: 4 additions & 2 deletions R/modelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ validate_prepared_serodata <- function(serodata) {
#' the implementation of the model. For further details refer to
#' [fit_seromodel].
#' @examples
#' \dontrun{
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' run_seromodel(
#' serodata,
#' foi_model = "constant"
#' )
#' }
#' @export
run_seromodel <- function(
serodata,
Expand Down Expand Up @@ -512,7 +514,7 @@ get_foi_central_estimates <- function(seromodel_object,
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant"
#' )
Expand Down Expand Up @@ -587,7 +589,7 @@ extract_seromodel_summary <- function(seromodel_object,
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant"
#' )
Expand Down
10 changes: 5 additions & 5 deletions R/visualisation.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ plot_seroprev <- function(serodata,
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant",
#' iter = 1000
Expand Down Expand Up @@ -173,7 +173,7 @@ plot_seroprev_fitted <- function(seromodel_object,
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant",
#' iter = 1000
Expand Down Expand Up @@ -267,7 +267,7 @@ plot_foi <- function(seromodel_object,
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant",
#' iter = 1000
Expand Down Expand Up @@ -343,7 +343,7 @@ plot_rhats <- function(seromodel_object,
#' @examples
#' data(chagas2012)
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant",
#' iter = 1000
Expand Down Expand Up @@ -421,7 +421,7 @@ plot_seromodel <- function(seromodel_object,
#' @return ggplot object summarizing the information in `info_table`
#' @examples
#' serodata <- prepare_serodata(chagas2012)
#' seromodel_object <- run_seromodel(
#' seromodel_object <- fit_seromodel(
#' serodata = serodata,
#' foi_model = "constant",
#' iter = 1000
Expand Down
2 changes: 1 addition & 1 deletion man/extract_seromodel_summary.Rd

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

2 changes: 1 addition & 1 deletion man/get_prev_expanded.Rd

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

2 changes: 1 addition & 1 deletion man/get_table_rhats.Rd

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

2 changes: 1 addition & 1 deletion man/plot_foi.Rd

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

2 changes: 1 addition & 1 deletion man/plot_info_table.Rd

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

2 changes: 1 addition & 1 deletion man/plot_rhats.Rd

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

2 changes: 1 addition & 1 deletion man/plot_seromodel.Rd

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

2 changes: 1 addition & 1 deletion man/plot_seroprev_fitted.Rd

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

2 changes: 2 additions & 0 deletions man/run_seromodel.Rd

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

18 changes: 18 additions & 0 deletions man/serofoi-package.Rd

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

12 changes: 6 additions & 6 deletions vignettes/foi_models.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ The number of positive cases follows a binomial distribution, where $n$ is the n
$$
p(a,t) \sim binom(n(a,t), P(a,t))
$$
In ***serofoi***, for the constant model, the *FoI* ($\lambda$) is modelled within a Bayesian framework using a uniform prior distribution $\sim U(0,2)$. Future versions of the package may allow to choose different default distributions. This model can be implemented for the previously prepared dataset `data_test` by means of the `run_seromodel` function specifying `run_seromodel="constant"`.
In ***serofoi***, for the constant model, the *FoI* ($\lambda$) is modelled within a Bayesian framework using a uniform prior distribution $\sim U(0,2)$. Future versions of the package may allow to choose different default distributions. This model can be implemented for the previously prepared dataset `data_test` by means of the `fit_seromodel` function specifying `fit_seromodel="constant"`.

The object `simdata_constant` contains a minimal simulated dataset that emulates an hypothetical endemic situation where the *FoI* is constant with value 0.2 and includes data for 250 samples of individuals between 2 and 47 years old with a number of trials $n=5$. The following code shows how to implement the constant model to this simulated serosurvey:

```{r model_1, include = TRUE, echo = TRUE, results="hide", errors = FALSE, warning = FALSE, message = FALSE, fig.width=4, fig.asp=1.5, fig.align="center", out.width ="50%", fig.keep="none"}
data("simdata_constant")
serodata_constant <- prepare_serodata(simdata_constant)
model_1 <- run_seromodel(
model_1 <- fit_seromodel(
serodata = serodata_constant,
foi_model = "constant",
iter = 800
Expand Down Expand Up @@ -102,7 +102,7 @@ The object `simdata_sw_dec` contains a minimal simulated dataset that emulates a
```{r model_2, include = TRUE, echo = TRUE, results="hide", errors = FALSE, warning = FALSE, message = FALSE, fig.width=4, fig.asp=1.5, fig.align="center", out.width ="50%", fig.keep="none"}
data("simdata_sw_dec")
serodata_sw_dec <- prepare_serodata(simdata_sw_dec)
model_2 <- run_seromodel(
model_2 <- fit_seromodel(
serodata = serodata_sw_dec,
foi_model = "tv_normal",
iter = 1500
Expand Down Expand Up @@ -140,7 +140,7 @@ In order to test this model we use the minimal simulated dataset contained in th
```{r model_3, include = TRUE, echo = TRUE, results="hide", errors = FALSE, warning = FALSE, message = FALSE, fig.width=4, fig.asp=1.5, fig.align="center", out.width ="50%", fig.keep="none"}
data("simdata_large_epi")
serodata_large_epi <- prepare_serodata(simdata_large_epi)
model_3 <- run_seromodel(
model_3 <- fit_seromodel(
serodata = serodata_large_epi,
foi_model = "tv_normal_log",
iter = 1500
Expand Down Expand Up @@ -191,7 +191,7 @@ Above we showed that the fast epidemic model (`tv_normal_log`) is able to identi
Now, we would like to know whether this model actually fits this dataset better than the other available models in ***serofoi***. For this, we also implement both the endemic model (`constant`) and the slow time-varying normal model (`tv_normal`):

```{r model_comparison, include = FALSE, echo = TRUE, results="hide", errors = FALSE, warning = FALSE, message = FALSE }
model_1 <- run_seromodel(
model_1 <- fit_seromodel(
serodata = serodata_large_epi,
foi_model = "constant",
iter = 800
Expand All @@ -201,7 +201,7 @@ model_1_plot <- plot_seromodel(model_1,
size_text = 6
)
model_2 <- run_seromodel(
model_2 <- fit_seromodel(
serodata = serodata_large_epi,
foi_model = "tv_normal",
iter = 1500
Expand Down
2 changes: 1 addition & 1 deletion vignettes/serofoi.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ library(serofoi)
data(chagas2012)
serodata_test <- prepare_serodata(chagas2012)
# Model implementation
model_constant <- run_seromodel(
model_constant <- fit_seromodel(
serodata = serodata_test,
foi_model = "constant"
)
Expand Down
16 changes: 8 additions & 8 deletions vignettes/use_cases.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ data("chik2015")
chik2015p <- prepare_serodata(chik2015)
# Implementation of the models
m1_chik <- run_seromodel(
m1_chik <- fit_seromodel(
serodata = chik2015p,
foi_model = "constant",
iter = 1000,
thin = 2
)
m2_chik <- run_seromodel(
m2_chik <- fit_seromodel(
serodata = chik2015p,
foi_model = "tv_normal",
iter = 1500,
thin = 2
)
m3_chik <- run_seromodel(
m3_chik <- fit_seromodel(
serodata = chik2015p,
foi_model = "tv_normal_log",
iter = 1500,
Expand Down Expand Up @@ -112,21 +112,21 @@ data("veev2012")
veev2012p <- prepare_serodata(veev2012)
# Implementation of the models
m1_veev <- run_seromodel(
m1_veev <- fit_seromodel(
serodata = veev2012p,
foi_model = "constant",
iter = 500,
thin = 2
)
m2_veev <- run_seromodel(
m2_veev <- fit_seromodel(
serodata = veev2012p,
foi_model = "tv_normal",
iter = 500,
thin = 2
)
m3_veev <- run_seromodel(
m3_veev <- fit_seromodel(
serodata = veev2012p,
foi_model = "tv_normal_log",
iter = 500,
Expand Down Expand Up @@ -172,12 +172,12 @@ data("chagas2012")
chagas2012p <- prepare_serodata(chagas2012)
# Implementation of the models
m1_cha <- run_seromodel(
m1_cha <- fit_seromodel(
serodata = chagas2012p,
foi_model = "constant",
iter = 800
)
m2_cha <- run_seromodel(
m2_cha <- fit_seromodel(
serodata = chagas2012p,
foi_model = "tv_normal",
iter = 800
Expand Down

0 comments on commit 20555d6

Please sign in to comment.