UC Davis Seroepidemiology Research Group (UCD-SERG)
2026-08-10
1 Overview
This guide helps users migrate code from serocalculator v1.3.0 to v1.4.0. The main changes are function renamings for improved clarity and consistency.
If you have existing code using v1.3.0, use this guide to update your function calls.
The intermediate names estimate_scr() and estimate_scr_by() were used briefly in early v1.4.0 development but replaced with the final names shown above.
# Stratified estimation by Countryresults_by_group<-est_seroincidence_by( pop_data =pop_data, sr_params =sr_params, noise_params =noise_params, strata ="Country", antigen_isos =antigen_isos)#> Warning: `curve_params` is missing all strata variables and will be used unstratified.#> ℹ To avoid this warning, specify the desired set of stratifying variables in#> the `curve_strata_varnames` and `noise_strata_varnames` arguments to#> `est_seroincidence_by()`.#> Warning: `noise_params` is missing all strata variables and will be used unstratified.#> ℹ To avoid this warning, specify the desired set of stratifying variables in#> the `curve_strata_varnames` and `noise_strata_varnames` arguments to#> `est_seroincidence_by()`.summary(results_by_group)#> Seroincidence estimated given the following setup:#> a) Antigen isotypes : HlyE_IgA, HlyE_IgG #> b) Strata : Country #> #> Seroincidence estimates:#> # A tibble: 1 × 14#> Stratum Country n est.start incidence.rate SE CI.lwr CI.upr se_type#> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> #> 1 Stratum 1 Pakistan 100 0.1 0.166 0.0178 0.135 0.205 standa…#> # ℹ 5 more variables: coverage <dbl>, log.lik <dbl>, iterations <int>,#> # antigen.isos <chr>, nlm.convergence.code <ord>
3.3 Example 3: Simulating Data
Old code (v1.3.0):
# Simulate cross-sectional data (v1.3.0 - DEPRECATED)simulated_data<-sim.cs( curve_params =curve_params, n =100)# Simulate multiple datasetsmultiple_sims<-sim.cs.multi( curve_params =curve_params, n =100, n_reps =10)
New code (v1.4.0):
Code
# Biologic noise distribution for simulationnoise_limits<-matrix(c(0, 0.5), nrow =length(antigen_isos), ncol =2, byrow =TRUE, dimnames =list(antigen_isos, c("min", "max")))# Simulate cross-sectional datasimulated_data<-sim_pop_data( curve_params =sr_params, noise_limits =noise_limits, antigen_isos =antigen_isos, n_samples =100, add_noise =TRUE, format ="long")#> Warning: Some dimension variables are not factors.#> ℹ These dimensions will be ordered by first appearance.#> ℹ Check results using `dimnames()`.head(simulated_data)#> # A tibble: 6 × 4#> age id antigen_iso value#> <dbl> <chr> <chr> <dbl>#> 1 14.8 1 HlyE_IgA 679. #> 2 14.8 1 HlyE_IgG 22.6 #> 3 17.2 2 HlyE_IgA 0.405#> 4 17.2 2 HlyE_IgG 0.519#> 5 0.85 3 HlyE_IgA 1064. #> 6 0.85 3 HlyE_IgG 418.# Simulate multiple datasetsmultiple_sims<-sim_pop_data_multi( curve_params =sr_params, noise_limits =noise_limits, antigen_isos =antigen_isos, sample_sizes =100, nclus =3, lambdas =0.1, num_cores =1, add_noise =TRUE, format ="long")#> Warning: Some dimension variables are not factors.#> ℹ These dimensions will be ordered by first appearance.#> ℹ Check results using `dimnames()`.#> Some dimension variables are not factors.#> ℹ These dimensions will be ordered by first appearance.#> ℹ Check results using `dimnames()`.#> Some dimension variables are not factors.#> ℹ These dimensions will be ordered by first appearance.#> ℹ Check results using `dimnames()`.nrow(multiple_sims)#> [1] 600
4 New Features in v1.4.0
In addition to the renamed functions, v1.4.0 includes several new features:
compare_seroincidence(): New function for statistical comparison of seroincidence rates between groups
Enhanced plotting: Additional options for autoplot.curve_params() including log_x, log_y, and chain_color
Extended simulation analysis: New analyze_sims() and autoplot.sim_results() functions
Improved documentation: Multi-version pkgdown documentation with version dropdown
Many internal improvements to error messages and warnings
Warning
Important: Not all functions changed their parameter names. Functions like sim_pop_data() and graph_loglik() still use curve_params as the parameter name. Only the main estimation functions use sr_params.