Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b84b0be
try to not skip
d-morrison Jun 27, 2025
9cb8930
Merge branch 'main' into sim-pop-multi-no-skip
d-morrison Aug 27, 2025
5a6269b
Change "seroconversion" to "seroincidence" in plot axis titles
kristinawlai Jun 2, 2026
4b37d32
update news
kristinawlai Jun 2, 2026
51f95ce
update wordlist
kristinawlai Jun 2, 2026
9f5f1e7
update tests
kristinawlai Jun 2, 2026
cb16b92
Remove ssdtools dependency from sim_pop_data_multi test (#447)
github-actions[bot] Jun 4, 2026
b731d32
Merge remote-tracking branch 'origin/main' into sim-pop-multi-no-skip
claude Jun 4, 2026
cac5607
Bump dev version to 1.4.0.9014
claude Jun 4, 2026
7ab6678
Add 'gh' to WORDLIST to fix spellcheck
claude Jun 4, 2026
b823bc9
fix(test): lower snapshot precision to 3 sig figs for cross-platform …
github-actions[bot] Jun 5, 2026
db7aa64
Merge remote-tracking branch 'origin/main' into sim-pop-multi-no-skip
claude Jun 5, 2026
78854cd
Bump dev version to 1.4.0.9015
claude Jun 5, 2026
a633ded
Quantize simulated inter-infection times for cross-platform reproduci…
claude Jun 10, 2026
b6505b0
Fix lint and spelling in cross-platform reproducibility change
claude Jun 10, 2026
0fa572b
test: regenerate sim_pop_data snapshots after quantize fix
github-actions[bot] Jun 11, 2026
32e9447
update roxygen2
kristinawlai Jun 11, 2026
3a085ab
Merge branch 'main' into bugfix/summary_axis_labels
kristinawlai Jun 11, 2026
ff2bd4b
increment version
kristinawlai Jun 11, 2026
4496107
Merge branch 'bugfix/summary_axis_labels' of https://github.com/UCD-S…
kristinawlai Jun 11, 2026
12abd38
Merge pull request #532 from UCD-SERG/bugfix/summary_axis_labels
d-morrison Jun 13, 2026
a01cf73
Merge remote-tracking branch 'origin/main' into sim-pop-multi-no-skip
claude Jun 15, 2026
5c2dd46
Bump dev version to 1.4.0.9016
claude Jun 15, 2026
28b6cec
Merge pull request #447 from UCD-SERG/sim-pop-multi-no-skip
d-morrison Jun 15, 2026
ce688e1
Merge remote-tracking branch 'origin/feat/intro-lecture-slides' into …
claude Jun 22, 2026
a0f3ccd
Replace copyrighted slide figures with freely-licensed equivalents
claude Jun 22, 2026
1b17339
Add maps to Suggests for methodology vignette
claude Jun 22, 2026
509122e
Re-add skip_on_cran() to sim_pop_data_multi test; sharpen NEWS bullet
claude Jun 22, 2026
4854034
Fix inaccurate comment: t_end may be fractional, not t0
claude Jun 22, 2026
9f57f8f
Merge feat/intro-lecture-slides; resolve methodology.qmd conflicts
claude Jun 22, 2026
8c36a9c
ci: expose pkgdown build errors (quiet = FALSE) for diagnostics
claude Jun 22, 2026
f508ced
chore: bump version to 1.4.1.9000 to satisfy serodynamics >= 1.4.1
claude Jun 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: serocalculator
Title: Estimating Infection Rates from Serological Data
Version: 1.4.0.9014
Version: 1.4.0.9016
Authors@R: c(
person("Kristina", "Lai", , "kwlai@ucdavis.edu", role = c("aut", "cre")),
person("Chris", "Orwa", role = "aut"),
Expand Down Expand Up @@ -72,7 +72,7 @@ LinkingTo:
Config/testthat/edition: 3
Config/Needs/roxygen2: roxygen2, moodymudskipper/devtag
Config/Needs/lint: r-lib/lintr
Config/Needs/website: quarto, lewinfox/foodwebr, serodynamics
Config/Needs/website: quarto, lewinfox/foodwebr, serodynamics, maps
Config/Needs/check: readr
Encoding: UTF-8
Language: en-US
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@

## Bug fixes

* `sim_pop_data()` and `sim_pop_data_multi()` now produce identical results
across operating systems. Simulated inter-infection times are now rounded to
whole days, so the number of random draws consumed no longer depends on
platform-specific floating-point results of `log()` (which previously
shifted the random-number stream out of sync and made simulated values, and
Comment thread
d-morrison marked this conversation as resolved.
their snapshots, differ between macOS, Windows, and Linux). Simulated
values change slightly as a result of this fix. (#447)
* Removed lingering terminology discrepancies
* `load_noise_params()` and `load_sr_params()` now fail gracefully with informative messages when internet resources are unavailable, complying with CRAN policy (#505)
* Added Version Crosswalk article to pkgdown website to help users migrate code from v1.3.0 to v1.4.0
- Provides clear tables comparing old and new function names
Expand Down
20 changes: 20 additions & 0 deletions R/quantize_t_next.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#' Quantize an inter-infection time to whole days
#'
#' Rounds a continuous inter-infection time (in days) to the nearest whole
#' day, with a floor of one day. The antibody-kinetics simulation in
#' `simresp.tinf()` already operates on a daily grid, but the number of
#' `while()`-loop iterations (and hence the number of random draws consumed)
#' otherwise depends on the platform-specific floating-point result of
#' `log()`. Quantizing to whole days keeps random-number consumption
#' identical across operating systems, so simulated data and its snapshots
#' are reproducible on macOS, Windows, and Linux.
#'
#' The floor of one day prevents a zero-length step, which would otherwise
#' stall the `while()` loop in `simresp.tinf()`.
#'
#' @param t_next a positive [numeric] scalar inter-infection time, in days
#' @returns a whole-number-valued [numeric] scalar, at least 1
#' @noRd
quantize_t_next <- function(t_next) {
max(1, round(t_next))
}
27 changes: 21 additions & 6 deletions R/simresp.tinf.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ simresp.tinf <- function(# nolint: object_name_linter
mcsize <- dim(predpar)[3]
nmc <- n_mcmc_samples

day2yr <- 365.25
days_per_year <- 365.25

if (n_mcmc_samples == 0) {
nmc <- sample.int(n = mcsize, size = 1)
Expand All @@ -59,8 +59,19 @@ simresp.tinf <- function(# nolint: object_name_linter
t_inf <- c()

t_next <- -log(runif(1, 0, 1)) / lambda # time to first infection...

age <- if_else(!is.na(age_fixed), age_fixed, t_next / day2yr)
# Quantize inter-infection times to whole days. The simulation already
# operates on a daily grid (`seq(0, t_next, by = 1)`, and ages are sampled
# over integer days), but the `while()` loop boundary and the per-episode
# grid lengths otherwise depend on the platform-specific floating-point
# result of `log()`. Those ULP-level differences flip the number of loop
# iterations on some operating systems, which changes how many random
# draws are consumed and desynchronizes the (otherwise platform-independent)
# L'Ecuyer-CMRG stream -- making snapshot output irreproducible across
# macOS/Windows/Linux. Rounding to whole days keeps RNG consumption
# identical across platforms. See `quantize_t_next()`.
t_next <- quantize_t_next(t_next)

age <- if_else(!is.na(age_fixed), age_fixed, t_next / days_per_year)

mcpar <- ldpar(
age = age,
Expand Down Expand Up @@ -116,7 +127,7 @@ simresp.tinf <- function(# nolint: object_name_linter

if (!renew_params) {
par_now <- ldpar(
if (!is.na(age_fixed)) age_fixed else t0 / day2yr,
if (!is.na(age_fixed)) age_fixed else t0 / days_per_year,
antigen_isos,
nmc,
predpar = predpar, ...
Expand All @@ -129,6 +140,10 @@ simresp.tinf <- function(# nolint: object_name_linter
# note: the renew_params == TRUE case is handled many lines below

t_next <- -log(runif(1, 0, 1)) / lambda
# Quantize to whole days for cross-platform reproducibility (see the
# comment on the first-infection draw above). `t_end` and `t0` are whole
# days, so the boundary clamp below stays integer-valued too.
t_next <- quantize_t_next(t_next)
if (t0 <= t_end && t0 + t_next > t_end) {
t_next <- t_end - t0
}
Expand All @@ -150,7 +165,7 @@ simresp.tinf <- function(# nolint: object_name_linter
b <- rbind(b, b_now)
y_mat <- rbind(y_mat, y_now)

y_end <- y_mat %>% tail(1)
y_end <- y_mat |> tail(1)

if (renew_params) {
if (n_mcmc_samples == 0) {
Expand All @@ -163,7 +178,7 @@ simresp.tinf <- function(# nolint: object_name_linter
age <- if_else(
!is.na(age_fixed),
age_fixed,
(t0 + t_next) / day2yr
(t0 + t_next) / days_per_year
)

par_now <- ldpar(
Expand Down
2 changes: 1 addition & 1 deletion R/strat_ests_barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ strat_ests_barplot <- function(
alpha = 0.7,
CIs = FALSE, # nolint: object_name_linter
title = NULL,
xlab = "Seroconversion rate per 1000 person-years",
xlab = "Seroincidence rate per 1000 person-years",
ylab = yvar,
fill_lab = NULL,
color_palette = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/strat_ests_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ strat_ests_scatterplot <- function(
col = .data[[color_var]]
) +
ggplot2::xlab(xvar) +
ggplot2::ylab("Estimated incidence rate") +
ggplot2::ylab("Estimated seroincidence rate") +
ggplot2::theme_linedraw() +
ggplot2::theme(
panel.grid.minor.x = ggplot2::element_blank(),
Expand Down
1 change: 0 additions & 1 deletion inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Seroepidemiology
Seroincidence
Serological
Shigella
Springer
TCVs
TW
Trombicula
Expand Down
Binary file removed man/figures/340149_1_En_16_Fig6_HTML.webp
Binary file not shown.
Binary file removed man/figures/41579_2024_1126_Fig1_HTML.png
Binary file not shown.
Binary file removed man/figures/burden-typhoid-vaccines.png
Binary file not shown.
2 changes: 1 addition & 1 deletion man/strat_ests_barplot.Rd

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading