Recent Releases of serofoi
serofoi - serofoi 1.0.3
serofoi 1.0.3
New features
- Add options to plot single FOI estimates and r-hats:
We introduced parameters plot_constant and x_axis to the visualisation functions of the package. These enable the option to plot constant FoI estimates and their corresponding r-hat values, avoiding ambiguity in the specification of the x-axis by means of x_axis = "time" or x_axis = "age".
Minor changes
- Documentation corrections
- Fix incorrect cross referencing in documentation
- Update table 1 in article
foi_modelsto show the prior specification options available in the package. - Add example of a particular model specification using the package in article
foi_models - Complete missing documentation and tags.
- Shorten long function and internal parameter names (mainly in the simulation module)
- Change
seroprevalence_andseropositive_forseroprev_ - Change
probability_forprob_ - Remove
_model
- Change
- Other
- Make consistent use of Force-of-Infection (FoI) acronym across the package
- Fix broken link to contributing guidelines in
README
Internal changes
- Implement
lintr v3.2.0new suggestions - Update the stan code to use new syntax.
- Update workflows based on Epiverse template.
- Remove
Hmiscdependency. - Replace
Matrixpackage forexpm - Add
donttestto examples taking too long to run
- R
Published by ntorresd over 1 year ago
serofoi - serofoi 1.0.2
serofoi 1.0.2
New features
- Serological surveys simulation functionalities
- Introduce enhanced data simulation functionalities to support a broader range of use cases for serosurvey analysis.
- Add a dedicated vignette for data simulation to guide users on simulating data for serosurveys.
Now it is possible to simulate serological surveys using serofoi. This is done by specifying two separate aspects:
- The serocatalytic model to be used (either
"constant","time","age","age-time"), including the FOI describing the disease transmission patterns (foi_df) - The features of the particular serological survey that are being used to uncover these dynamics
For example, consider a disease described by the following seroreversion rate and age-dependent FOI:
r
max_age <- 80
ages <- seq(1, max_age, 1)
foi_age_varying <- data.frame(
age = ages,
foi = 0.03 * exp(-0.03 * ages)
)
seroreversion_rate <- 0.01
Now, suppose that we carry out a serological survey which randomly samples the population. For simplicity, consider that all individual one-year group ages are sampled and the sample size in each age is the same: $n=15$. This can be specified as follows:
r
n_sample <- 15
survey_features <- data.frame(
age_min = seq(1, max_age, 1),
age_max = seq(1, max_age, 1),
n_sample = rep(n_sample, max_age))
We then put these pieces together and simulate a serosurvey:
r
serosurvey_age <- simulate_serosurvey(
model = "age",
foi = foi_age_varying,
seroreversion_rate = seroreversion_rate,
survey_features = survey_features
)
Further details about serological survey simulation can be found in the website article Simulating Serosurveys.
- Enables the implementation of a wide variety of new models
- Add forward random walk age-varying models with uniform and normal priors.
- Improves previous implementation of forward random walk time-varying models.
- Enables prior distributions specifications by means of package specific functions like
sf_normal()andsf_uniform(). - Support for seroreversion rate estimation for all models with uniform and normal priors.
serofoi now supports the implementation of a wide variety of constant, age-varying, and time-varying FOI models, including the possibility to estimate the seroreversion rate. We achieved this by allowing a flexible specification of the priors for each model. For example, to fit an age-dependent model to the previously simulated serosurvey considering a seroreversion prior normally distributed around the "real" value and setting the first FOI close to 0.03:
r
seromodel_age <- fit_seromodel(
serosurvey = serosurvey_age,
model_type = "age",
foi_prior = sf_normal(3e-2, 1e-3),
is_seroreversion = TRUE,
seroreversion_prior = sf_normal(0.01, 1e-3),
iter = 5000
)
So far, age and time dependent models only allow for forward random walk, meaning that the prior specifies the knowledge about the first age/year to be estimated, from which the next values are estimated recursively.
Breaking changes
- Replaced old modelling and visualization functions, making Bayesian model selection and specification more flexible.
- New models and functionalities include constant, time-varying, and age-varying models, as well as options for estimating seroreversion rates.
- Updated the R-hat convergence threshold for model convergence diagnostics to R-hat<1.01, following Vehtari et al. (2021).
Minor changes
- Remove the
simdata_*datasets from the package and replaced them with code-based simulation in vignettes. - Add missing examples to exported functions
- Add missing documentation entries
Internal changes
Unit testing
- Added unit tests for key package functionalities, including:
fit_seromodel()function (#213).- Visualization functionalities (#215).
build_stan_dataand related functions (#232).- Validation functions (#235).
- Test coverage increased to 100%
Refactorization of simulation examples
- Replaced static simulated datasets in tests and vignettes with dynamic examples using data simulation functions.
Documentation improvements
- Enhanced documentation for new functionalities and updated vignettes to reflect recent changes.
- R
Published by ntorresd over 1 year ago
serofoi - serofoi 0.1.0
serofoi 0.1.0
New features
- Data simulation functions from time-varying or age-varying force of infection trends. The following is an example to simulate from a constant (in time) force of infection: ``` foisimconstant <- rep(0.02, 50)
serodataconstant <- generatesimdata(
simdata = data.frame(
age=seq(1,50),
tsur=2050),
foi=foisimconstant,
samplesizebyage = 5
)
``
To generate grouped serosurveys the functiongroupsimdatacan be used:
``
serodataconstant <- groupsimdata(serodata_constant , step = 5)
```
Breaking changes
Simplifies
fit_seromodeloutput- Before, the output of
fit_seromodelwas a list:seromodel_object <- list( fit = fit, seromodel_fit = seromodel_fit, serodata = serodata, serodata = serodata, stan_data = stan_data, ... ) - Now, the output is a
stan_fitobject as obtained fromrstan::sampling. Because of this, some plotting functionalities now requireserodataas an input.
- Before, the output of
Initial prior distribution parameters
foi_locationandfoi_scalecan be specified explicitely infit_seromodel:seromodel <- fit_seromodel( serodata, foi_model = "tv_normal", foi_location = 0, foi_scale = 1 )Depending on the selected modelfoi_model, the meaning of the parameters change. For thetv_normal_logmodel these parameters must be in logarithmic scale; the recommended usage is:seromodel <- fit_seromodel( serodata, foi_model = "tv_normal_log", foi_location = -6, foi_scale = 4 )Chunks structure specification is now possible
- Before, the models estimated one value of the force of infection per year in the time spanned by the serosurvey:
data(chagas2012) serodata <- prepare_serodata(chagas2012) seromodel <- fit_seromodel(serodata, foi_model = "tv_normal") - Now, the amount of force of infection values estimated by the models depend on the specified chunk structure. This can either be specified by size:
seromodel <- fit_seromodel(serodata, foi_model = "tv_normal", chunk_size = 10)
- Before, the models estimated one value of the force of infection per year in the time spanned by the serosurvey:
or explicitly:
chunks <- rep(c(1, 2, 3, 4, 5), c(10, 10, 15, 15, max(serodata$age_mean_f)-50))
seromodel <- fit_seromodel(serodata, foi_model = "tv_normal", chunks = chunks)
- Deprecate
run_seromodel. Initially this function was intended to be a handler forfit_seromodelfor cases when the user may need to implement the same model to multiple independent serosurveys; now we plan to showcase examples of this using the current functionalities of the package (to be added in future versions to the vignettes).
Minor changes
Refactorization of the visualization module
plot_seroprevallows for data binning (age group manipulation) by means of parametersbin_data=TRUEandbin_step.- Automatic selection of
yminandymaxaesthetics plotting functions (with the exception ofplot_rhats). - Correct input validation
Remove duplicated data in
veev2012dataset
Internal changes
Remove large files from git history (see #77).
Added input validation for the following functions:
prepare_serodatagenerate_sim_dataget_age_groupfit_seromodelextract_seromodel_summaryplot_seroprevplot_seroprev_fittedplot_foiplot_seromodel
Unit testing:
- Separate modelling testings by model
- Use of
dplyr::nearto test models statistical validity - Add tests for data simulation functions
Update package template in accordance to {packagetemplate}
- R
Published by ntorresd about 2 years ago
serofoi - serofoi 0.0.9
This release of serofoi, includes the following:
- Implementation of package modules: Incorporates data preparation, modeling, and visualization modules, they enable efficient handling of data, perform statistical modeling, and generate visual representations of the results.
- Documentation: It consists of vignettes, a website, and uses cases that provide detailed instructions on how to use the package effectively.
- Implementation of 3 models for calculating the Force-of-Infection (FoI): The first model is the constant or endemic model, which assumes a stable FoI over time. The second and third models are time-varying, with the normal FoI model representing a slow change in FoI and the normal-log FoI model representing a fast epidemic change in FoI.
- Definition of coverage test to assurance the quality of the package.
Overall, this release introduces essential package functionality, comprehensive documentation, various FoI models, and a coverage test, enabling users to analyze seroprevalence data and calculate the Force-of-infection.
- R
Published by GeraldineGomez almost 3 years ago