Git Product home page Git Product logo

serosurvey's Introduction


Disclaimer

This package is a work in progress. It has been released to get feedback from users that we can incorporate in future releases.

serosurvey

DOI Lifecycle: experimental CRAN status Codecov test coverage R-CMD-check

The goal of serosurvey is to gather Serological Survey Analysis functions and workflow templates for Prevalence Estimation Under Misclassification.

Installation

You can install the developmental version of serosurvey from GitHub with:

if(!require("remotes")) install.packages("remotes")
remotes::install_github("avallecam/serosurvey")

Brief description

The current workflow is divided in two steps:

  1. survey: Estimate multiple prevalences, and
  2. serology: Estimate prevalence Under misclassification for a device with Known or Unknown test performance

More

Contributing

Feel free to fill an issue or contribute with your functions or workflows in a pull request.

Code of Conduct

Please note that the serosurvey project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Contact

Andree Valle Campos | @avallecam | [email protected]

Project Link: https://github.com/avallecam/serosurvey

Acknowledgements

Many thanks to the Centro Nacional de Epidemiología, Prevención y Control de Enfermedades (CDC Perú) for the opportunity to work on this project.

How to cite this R package

citation("serosurvey")
#> 
#> To cite package ‘serosurvey’ in publications use:
#> 
#> Valle Campos A (2020). "serosurvey: Serological Survey Analysis For
#> Prevalence Estimation Under Misclassification." _Zenodo_. doi:
#> 10.5281/zenodo.4065080 (URL: https://doi.org/10.5281/zenodo.4065080), R
#> package version 1.0, <URL: https://avallecam.github.io/serosurvey/>.
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Article{,
#>     author = {Andree {Valle Campos}},
#>     title = {serosurvey: Serological Survey Analysis For Prevalence Estimation Under Misclassification},
#>     journal = {Zenodo},
#>     month = {oct},
#>     year = {2020},
#>     doi = {10.5281/zenodo.4065080},
#>     note = {R package version 1.0},
#>     url = {https://avallecam.github.io/serosurvey/},
#>   }

serosurvey's People

Contributors

avallecam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

llabans

serosurvey's Issues

error when using pmap and srvyr_prop_step_02

library(serosurvey)
library(tidyverse)
library(srvyr)
#> 
#> Attaching package: 'srvyr'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#> 
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#> 
#>     expand, pack, unpack
#> Loading required package: survival
#> 
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#> 
#>     dotchart
data(api)
dstrata <- apistrat %>% as_survey_design(strata = stype, weights = pw)
dstrata2 <- apistrat %>%
  mutate(pw2=1) %>%
  as_survey_design(strata = stype, weights = pw2)
dstrata %>%
  summarise(pct = survey_mean(awards=="Yes",proportion = TRUE))
#> # A tibble: 1 × 2
#>     pct pct_se
#>   <dbl>  <dbl>
#> 1 0.639 0.0349
dstrata2 %>%
  summarise(pct = survey_mean(awards=="Yes",proportion = TRUE))
#> # A tibble: 1 × 2
#>     pct pct_se
#>   <dbl>  <dbl>
#> 1 0.565 0.0331

srvyr_prop_step_01(design = dstrata,
                     numerator = awards,
                     denominator = stype) %>%
  mutate(resultado=pmap(.l = select(.,design=design,
                                    numerator = numerator,
                                    denominator = denominator,
                                    numerator_level=numerator_level),
                       .f = srvyr_prop_step_02))
#> Error in `mutate()`:
#> ! Problem while computing `resultado = pmap(...)`.
#> ℹ The error occurred in group 1: stype = E.
#> Caused by error in `pmap()`:
#> ℹ In index: 1.
#> Caused by error in `dplyr::summarise()`:
#> ! Problem while computing `prop = survey_mean(...)`.
#> ℹ The error occurred in group 1: stype = E.
#> Caused by error in `.data$numerator_level`:
#> ! Column `numerator_level` not found in `.data`.

#> Backtrace:
#>      ▆
#>   1. ├─... %>% ...
#>   2. ├─dplyr::mutate(...)
#>   3. ├─dplyr:::mutate.data.frame(...)
#>   4. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
#>   5. │   ├─base::withCallingHandlers(...)
#>   6. │   └─mask$eval_all_mutate(quo)
#>   7. ├─purrr::pmap(...)
#>   8. │ └─purrr:::pmap_("list", .l, .f, ..., .progress = .progress)
#>   9. │   ├─purrr:::with_indexed_errors(...)
#>  10. │   │ └─base::withCallingHandlers(...)
#>  11. │   ├─purrr:::call_with_cleanup(...)
#>  12. │   └─serosurvey (local) .f(...)
#>  13. │     └─... %>% ... at serosurvey/R/serosurvey_srvyr.R:154:2
#>  14. ├─dplyr::rename_at(...)
#>  15. │ └─dplyr:::tbl_at_vars(.tbl, .vars, .include_group_vars = TRUE)
#>  16. │   └─dplyr::tbl_vars(tbl)
#>  17. │     ├─dplyr:::new_sel_vars(tbl_vars_dispatch(x), group_vars(x))
#>  18. │     │ └─base::structure(...)
#>  19. │     └─dplyr:::tbl_vars_dispatch(x)
#>  20. ├─dplyr::ungroup(.)
#>  21. ├─dplyr::summarize(...)
#>  22. ├─srvyr:::summarise.grouped_svy(...)
#>  23. │ ├─dplyr::summarise(.data$variables, !!!.dots, .groups = .groups)
#>  24. │ └─dplyr:::summarise.grouped_df(.data$variables, !!!.dots, .groups = .groups)
#>  25. │   └─dplyr:::summarise_cols(.data, dplyr_quosures(...), caller_env = caller_env())
#>  26. │     ├─base::withCallingHandlers(...)
#>  27. │     └─dplyr:::map(quosures, summarise_eval_one, mask = mask)
#>  28. │       └─base::lapply(.x, .f, ...)
#>  29. │         └─dplyr (local) FUN(X[[i]], ...)
#>  30. │           └─mask$eval_all_summarise(quo)
#>  31. ├─srvyr::survey_mean(...)
#>  32. │ └─srvyr:::stop_for_factor(x)
#>  33. │   └─base::is.factor(x)
#>  34. ├─numerator_level
#>  35. ├─rlang:::`$.rlang_data_pronoun`(.data, numerator_level)
#>  36. │ └─rlang:::data_pronoun_get(...)
#>  37. └─rlang:::abort_data_pronoun(x, call = y)
#>  38.   └─rlang::abort(msg, "rlang_error_data_pronoun_not_found", call = call)
ᘀ娂Ȼ
#> Error in eval(expr, envir, enclos): object 'ᘀ娂Ȼ' not found

Create snapshot test to functions in serosurvey_srvy.R

Use this package:
library(testthat)

A quick solution is to use this combo:
testthat::test_that()
testthat::expect_snapshot()

To load all the functions written in the project:
devtools::load_all()

To run a test:
devtools::test()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.