Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input validation #92

Merged
merged 6 commits into from
Oct 5, 2023
Merged

Add input validation #92

merged 6 commits into from
Oct 5, 2023

Conversation

jamesmbaazam
Copy link
Member

This PR closes #91. The solution is described in the linked issue.

@jamesmbaazam jamesmbaazam changed the title Added argument matching in fit_seromodel() Add argument matching in fit_seromodel() Jul 6, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2023

Codecov Report

Merging #92 (ba1740a) into main (d7f66d7) will increase coverage by 0.08%.
The diff coverage is 100.00%.

❗ Current head ba1740a differs from pull request most recent head 295eebe. Consider uploading reports for the commit 295eebe to get more accurate results

@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
+ Coverage   82.18%   82.26%   +0.08%     
==========================================
  Files          10       10              
  Lines        1684     1692       +8     
==========================================
+ Hits         1384     1392       +8     
  Misses        300      300              
Files Changed Coverage Δ
R/modelling.R 86.17% <100.00%> (+0.14%) ⬆️
R/seroprevalence_data.R 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jamesmbaazam jamesmbaazam changed the title Add argument matching in fit_seromodel() Add input validation Aug 3, 2023
@ntorresd ntorresd changed the base branch from main to dev August 17, 2023 12:56
@ntorresd ntorresd merged commit d9fad81 into dev Oct 5, 2023
5 checks passed
@ntorresd ntorresd deleted the check_seromodel_args branch October 5, 2023 13:42
Bisaloo pushed a commit that referenced this pull request Oct 10, 2023
* Added argument matching in fit_seromodel()

* Added allowed options to arg foi_model

* Added input validation to prepare_serodata()

* Fixed the check for required columns

* Regenerated the docs

---------

Co-authored-by: ntorresd <[email protected]>
ntorresd added a commit that referenced this pull request Oct 10, 2023
* Added argument matching in fit_seromodel()

* Added allowed options to arg foi_model

* Added input validation to prepare_serodata()

* Fixed the check for required columns

* Regenerated the docs

---------

Co-authored-by: ntorresd <[email protected]>
ntorresd added a commit that referenced this pull request Oct 11, 2023
* Added argument matching in fit_seromodel()

* Added allowed options to arg foi_model

* Added input validation to prepare_serodata()

* Fixed the check for required columns

* Regenerated the docs

---------

Co-authored-by: ntorresd <[email protected]>
ntorresd added a commit that referenced this pull request Oct 11, 2023
* Added argument matching in fit_seromodel()

* Added allowed options to arg foi_model

* Added input validation to prepare_serodata()

* Fixed the check for required columns

* Regenerated the docs

---------

Co-authored-by: ntorresd <[email protected]>
ntorresd added a commit that referenced this pull request Nov 8, 2023
* remove serodata .Rdata and .Rd files

* remove R/serodata.R

* doc: update functions  documentation replacing  for  in examples

* doc: update README and vignettes
This commit changes the removed preloaded dataset `serodata` for the identical `chagas2012`.

* fix: minor correction to test_modelling

* feat: add function `get_foi_central_estimates()` to the modelling module.
This change is meant to simplify `fit_seromodel()`. This commit also changes the name of the stanfit object in the output of `fit_seromodel()` from `fit` to `seromodel_fit`.

* fix: minor corrections to tests according to commit 052c90c

* fix: change  to  in model_comparison

* doc: add documentation file for

* doc: minor correction to  documentation

* refac: updates

* refac: reduce the output of

* fix(tests): change storing format of  model object files from .json to .RDS and updates test_visualization accordingly

* Remove `serodata` from pre-loaded datasets of the package (#107)

* remove serodata .Rdata and .Rd files

* remove R/serodata.R

* doc: update functions  documentation replacing  for  in examples

* doc: update serofoi logo

* doc: update README and vignettes
This commit changes the removed preloaded dataset `serodata` for the identical `chagas2012`.

* fix: minor correction to test_modelling

* Fixes #115 (#116)

* 82 tidyverse dependency (#120)

* Enabling CMD check when doing pull request on `dev`

* Removed tidyverse dependency

* refac: `fit_seromodel` returns stanfit object (#117)

* refac: `fit_seromodel` returns a stanfit object
`fit_seromodel` returns a stanfit object now, which induces changes all across the pachage
- `seromodel_object$seromodel_fit -> seromodel_object`:
    * `get_foi_central_estimates`
    * `extract_seromodel_summary`
    * `plot_seroprev_fitted`
    * `plot_foi`
    * `plot_rhats`
    * `plot_seromodel`
    * `get_table_rhats`
- add `serodata` as input:
    * `get_foi_central_estimates`
    * `extract_seromodel_summary`
    * `plot_seroprev_fitted`
    * `plot_seromodel`
    * `plot_rhats`
    * `plot_foi`
    * `get_table_rhats`
- use of `exposure_years` (this suggest adding a function for this purpose):
    * `get_foi_central_estimates`
    * `get_table_rhats`
- minor corrections:
    * `plot_seromodel` -> correction to exception

* tests(refac): re-generate .RDS files used in tests

* tests(refac): update tests according to 7be19f9
- change `model_object$seromodel_fit` to `model_object`
- add `serodata` as input where needed
- minor syntax changes to test_issue_47.R

* fix examples
Fix examples of functions across the package in accordance to the
new output of `fit_seromodel`.

Updated examples:
- `get_table_rhats`
- `get_foi_central_estimates`
- `get_prev_expanded`
- `extract_seromodel_summary`
- `plot_seroprev_fitted`
- `plot_foi`
- `plot_rhats`
- `plot_seromodel`
- `plot_info_table`

* refac: replace `get_exposure_ages` for `get_cohort_ages`

add `get_cohort_ages`: this function serves as replacement for
`get_exposure_ages` and also includes the information of
`exposure_years`, which was being used in some functions.

Affected functions:
- `fit_seromodel`
- `get_exposure_matrix`
- `get_table_rhats`

* test: add test for `get_cohort_ages` to the test_modelling.R

* refac: replace `serodata` for `cohort_ages` where needed

Affected functions:
- `get_table_rhats`
- `get_foi_central_estimates`
- `extract_seromodel_summary`
- `plot_foi`
- `plot_rhats`
- `plot_seromodel`

* doc: update documentation
use @inheritParams to simplify documentation

* add comment to exception in `fit_seromodel`

* refac: specify argument `parameter_name`
Explicitely specify argument `parameter_name = "logLikelihood"`
in `loo::loo`

* change condition to check whether sampling is done or not

* doc: update vignettes according to changes

* doc: update documentation and examples

* doc: parameter description correction

parameter `seromodel_object` description correction in
`get_foi_central_estimates`

* doc: minor corrections to functions documentation

* fix: add input check for `age_mean_f` column (#123)

add input check for `age_mean_f` in `serodata` in the following functions
- `prepare_serodata`
- `prepare_bin_data`

* Add input validation (#92)

* Added argument matching in fit_seromodel()

* Added allowed options to arg foi_model

* Added input validation to prepare_serodata()

* Fixed the check for required columns

* Regenerated the docs

---------

Co-authored-by: ntorresd <[email protected]>

* Remove test_visualisation and related files

* Convert logo to png
To keep a reasonable repo size

* Add functions to simulate datasets to the seroprevalence_data module. (#58)

* fix: add exception to function plot_foi() to plot a FOI trend with different length along with the data for the case when their sizes don't coincide

* clean test_visualisation

* feature: add three functions to simulate datasets. get_sim_counts() generates a list with simulated counts by age following a binomial distribution. generate_sim_data() uses the counts generated by get_sim_counts() to create a dataframe with the necessary structure to use other functions of the package. group_sim_data() serves to group the previously generated dataset by age group; right now it groups the data by periods of 5 years.

* add test_simulate_data to test the data simulation functions in the seroprevalence_data module

* doc: update generate_sim_data description

* doc: complete get_sim_counts documentation and remove corresponding TODO item in seroprevalence_data.R

* feat: add function get_sim_prob to seroprevalence_data.R. This function generates a list containing a seropositivity destribution by age following the specified force of infection.

* doc: complete documentation of generate_sim_data in seroprevalence_data.R. Remove corresponding TODO item.

* feat: add function `get_age_group` to seroprevalence_data.R.
This function was taken from vaccineff [vaccineff](https://github.com/epiverse-trace/vaccineff).
Minor changes to `group_sim_data` description.

* feat (refac): use `get_age_group` function to generate the age groups in `group_sim_data`

* doc: add or update documentation for data simulation functions

* refac: minor changes to `get_sim_prob()`
Move seed setting from `get_sim_prob()` to `get_sim_counts()`. Remove unnecessary parameters from documentation in `get_sim_prob()`

* doc: update documentation for data simulation functions
update `foi` parameter description
- `get_sim_prob()`
- `get_sim_counts`
- `generate_sim_data`
update `birth_year` parameter description
- `prepare_serodata()`
- `prepare_bin_data()`
- `get_sim_counts()`
- `get_sim_prob()`
update function descriptions
- `get_sim_counts()`
- `generate_sim_data()`
update return description
- `get_sim_counts()`
remove export
- `prepare_bin_data()`
- `get_sim_prob()`
remove unnecessary input parameters
- `get_sim_prob()`
- `get_sim_counts()`

* refac: change `size_age_class` for `sample_size_by_age`

* doc: update documentation of data simulation functions
update @return description for `get_age_group()`
update documentation files for
- `generate_sim_data()`
- `get_age_group()`
- `get_sim_counts()`
- `group_sim_data()`

* doc: remove example for `get_age_group()`

* refac: change name and output of `get_sim_prob`
change name of `get_sim_prob` to `get_sim_n_seropositive`.
The function now returns a dataframe containing the exposure ages and the number of seropositive cases for each age.

* doc: add example for `get_sim_counts()`

* Revert "refac: change name and output of `get_sim_prob`"

This reverts commit 966e463.

* refac: change name and output of `get_sim_prob()`
change name of `get_sim_prob()` to `get_sim_probability`.
The output of the function is now a dataframe.

* refac: change name and output of `get_sim_counts`
change name of function `get_sim_counts` to `get_sim_n_seropositive` and update the documentation accordingly.
minor correction to documentation of `get_sim_probability`

* doc: minor correction to function documentation
minor correction to function `get_age_group` documentation

* doc: remove function `group_sim_data` from export
remove function `group_sim_data` from export and the corresponding
example

* refac: simplify function `get_age_group`
Remove unnecessary parameters from `get_age_group`.
Now the function takes an age vector as input rather than a dataframe
containing an specific age column.

* test: remove data writing from test
Remove data writing from `test_simulate_data.R` as well as the corresponding
.csv files.

* clean: remove unused data paths from test
Remove unused data paths from `test_simulate_data`

* test: add tests for `get_sim_` functionalities
Add tests for `get_sim_probability` and `get_sim_n_seropositive`

* test(refac): modify test for data sim functions
Modify test for `generate_sim_data` and `group_sim_data` functions.
Remove unnecessary model running.
Remove `expect_doppleganger` tests.

* add test for values from `get_sim_probability`

Add `get_sim_probability` to export to enable testing.
Test the values of the probabilities.

* test: add statistical test for `generate_sim_data`

The idea of the test is to make sure that the foi trend used to simulate
the data is in the confidence interval of a suitable model.

Add possibility to test for:
- constant FoI
- smooth-descendent FoI

Minor clean up of `plot_foi`.

* add pracma to dependencies

* add parameter descriptions in `generate_sim_data`

* doc: update documentation

* test: add analytical test for constant foi

Add analytical test for constant foi for large sample sizes.

* test: add test for data simulation with time-varying foi

* small syntax corrections in test_sim_data.R

---------

Co-authored-by: ntorresd <[email protected]>
Co-authored-by: Nicolás Torres Domínguez <[email protected]>
Co-authored-by: Jaime Pavlich-Mariscal <[email protected]>
Co-authored-by: James Azam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add failsafe for foi_model argument in fit_seromodel() to avoid errors
3 participants