Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3b2c220
resolve #30 age group and #32 cex issues
quingzz Nov 20, 2025
14d4e70
resolve #31 clarify bayesian method & part of #39
quingzz Nov 20, 2025
8df53b2
resolve #37, add details for SIR, parametric mods
quingzz Nov 24, 2025
93586a4
update local polynomial documentation
quingzz Dec 1, 2025
e7a9e77
update documentation for semi parametric model
quingzz Dec 1, 2025
92861dc
update documentation for hierarchical bayesian mod
quingzz Dec 2, 2025
f38bf22
update document for mixture model for clarity
quingzz Dec 2, 2025
ca7358f
resolve #52 and rerender
quingzz Dec 4, 2025
8523c46
address #36, #40, #41, #48 and part of #46
quingzz Dec 5, 2025
ed41a6b
add predict func, standardize code
quingzz Jan 23, 2026
6f76bbf
update compare_model and doc, partially addr #51
quingzz Jan 23, 2026
ec8ce27
resolve #46 allowing a range of values for k
quingzz Mar 10, 2026
03d198b
resolve #33, part of #49 - built-in fp_search
quingzz Mar 11, 2026
3e02cff
use pmap for cleaner code
quingzz Mar 12, 2026
113bef1
resolve #49 - tuning for lp_mod, rerender doc
quingzz Mar 12, 2026
7e93a4a
resolve #42 and update docs
quingzz Mar 23, 2026
b56a80f
Increment version number to 1.2.0.9000
quingzz Mar 24, 2026
6d7bb33
update doc for to_titer func, rerender
quingzz Mar 24, 2026
40b85a0
clean up docs
quingzz Mar 24, 2026
2dfa20c
remove sir models, resolve #50
quingzz Mar 24, 2026
262ca3f
update model selection metric, rerender
quingzz Mar 24, 2026
2b0bd6a
resolve check err
quingzz Mar 24, 2026
7cd5055
remove redundant example
quingzz Mar 24, 2026
2c92384
make transform_data() more pipe friendly
quingzz Mar 26, 2026
c39042f
debug predict() for age_time_model
quingzz Mar 26, 2026
8dd091d
resolve some warnings in docs, rerender
quingzz Mar 26, 2026
da337c0
resolve a bug in generating metrics func
quingzz Mar 26, 2026
5572831
update doc for custom metric, rerender
quingzz Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: serosv
Type: Package
Title: Model Infectious Disease Parameters from Serosurveys
Version: 1.2.0
Version: 1.2.0.9000
Authors@R: c(
person("Anh", "Phan Truong Quynh", email = "anhptq@oucru.org", role = c("aut", "cre"), comment = c(ORCID = "0009-0000-2129-435X")),
person("Nguyen", "Pham Nguyen The", email = "nguyenpnt@oucru.org", role = c("aut"), comment = c(ORCID = "0000-0002-0356-2776")),
Expand Down Expand Up @@ -40,6 +40,7 @@ Imports:
rstan (>= 2.18.1),
rstantools (>= 2.4.0),
boot,
pROC,
stats4
Suggests:
covr,
Expand All @@ -49,16 +50,13 @@ Suggests:
testthat (>= 3.0.0)
Collate:
'data.R'
'mseir_model.R'
'sir_basic_model.R'
'sir_static_model.R'
'sir_subpops_model.R'
'fractional_polynomial_models.R'
'polynomial_models.R'
'utils.R'
'compare_models.R'
'correct_prevalence.R'
'weibull_model.R'
'farrington_model.R'
'nonparametric.R'
'semiparametric_models.R'
'mixture_model.R'
Expand All @@ -69,6 +67,8 @@ Collate:
'plots.R'
'compute_ci.R'
'age_time_model.R'
'predict.R'
'print.R'
Config/testthat/edition: 3
URL: https://oucru-modelling.github.io/serosv/, https://github.com/OUCRU-Modelling/serosv
VignetteBuilder: knitr
Expand Down
60 changes: 41 additions & 19 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
# Generated by roxygen2: do not edit by hand

S3method(compute_ci,age_time_model)
S3method(compute_ci,default)
S3method(compute_ci,fp_model)
S3method(compute_ci,hierarchical_bayesian_model)
S3method(compute_ci,lp_model)
S3method(compute_ci,mixture_model)
S3method(compute_ci,penalized_spline_model)
S3method(compute_ci,weibull_model)
S3method(plot,age_time_model)
S3method(plot,estimate_from_mixture)
S3method(plot,farrington_model)
S3method(plot,fp_model)
S3method(plot,hierarchical_bayesian_model)
S3method(plot,lp_model)
S3method(plot,mixture_model)
S3method(plot,mseir_model)
S3method(plot,penalized_spline_model)
S3method(plot,polynomial_model)
S3method(plot,sir_basic_model)
S3method(plot,sir_static_model)
S3method(plot,sir_subpops_model)
S3method(plot,weibull_model)
S3method(predict,age_time_model)
S3method(predict,farrington_model)
S3method(predict,fp_model)
S3method(predict,hierarchical_bayesian_model)
S3method(predict,lp_model)
S3method(predict,penalized_spline_model)
S3method(predict,polynomial_model)
S3method(predict,weibull_model)
S3method(print,age_time_model)
S3method(print,estimate_from_mixture)
S3method(print,farrington_model)
S3method(print,fp_model)
S3method(print,hierarchical_bayesian_model)
S3method(print,lp_model)
S3method(print,mixture_model)
S3method(print,penalized_spline_model)
S3method(print,polynomial_model)
S3method(print,weibull_model)
export(add_thresholds)
export(age_time_model)
export(compare_models)
export(compute_ci)
export(compute_ci.age_time_model)
export(compute_ci.fp_model)
export(compute_ci.hierarchical_bayesian_model)
export(compute_ci.lp_model)
export(compute_ci.mixture_model)
export(compute_ci.penalized_spline_model)
export(compute_ci.weibull_model)
export(correct_prevalence)
export(est_foi)
export(estimate_from_mixture)
export(farrington_model)
export(find_best_fp_powers)
export(fp_model)
export(hierarchical_bayesian_model)
export(lp_model)
export(mixture_model)
export(mseir_model)
export(pava)
export(penalized_spline_model)
export(plot_corrected_prev)
Expand All @@ -43,9 +55,6 @@ export(plot_standard_curve)
export(plot_titer_qc)
export(polynomial_model)
export(set_plot_style)
export(sir_basic_model)
export(sir_static_model)
export(sir_subpops_model)
export(standardize_data)
export(to_titer)
export(transform_data)
Expand All @@ -55,15 +64,15 @@ import(assertthat)
import(dplyr)
import(ggplot2)
import(graphics)
import(locfit)
import(methods)
import(pROC)
import(patchwork)
import(purrr)
import(scam)
import(tidyr)
importFrom(RcppParallel,RcppParallelLibs)
importFrom(assertthat,assert_that)
importFrom(boot,inv.logit)
importFrom(deSolve,ode)
importFrom(dplyr,group_by)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
Expand All @@ -87,7 +96,17 @@ importFrom(mixdist,mix)
importFrom(mixdist,mixgroup)
importFrom(mixdist,mixparam)
importFrom(mvtnorm,rmvnorm)
importFrom(purrr,as_mapper)
importFrom(purrr,compact)
importFrom(purrr,imap_dfr)
importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_dbl)
importFrom(purrr,map_dfc)
importFrom(purrr,map_dfr)
importFrom(purrr,pmap)
importFrom(purrr,pmap_dfr)
importFrom(purrr,walk)
importFrom(rstan,sampling)
importFrom(rstan,summary)
importFrom(rstantools,rstan_config)
Expand All @@ -103,6 +122,9 @@ importFrom(stats,predict.glm)
importFrom(stats,prop.test)
importFrom(stats,qnorm)
importFrom(stats,qt)
importFrom(stats4,AIC)
importFrom(stats4,BIC)
importFrom(stats4,logLik)
importFrom(stats4,mle)
importFrom(stringr,str_detect)
useDynLib(serosv, .registration=TRUE)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# serosv (development version)
* clean up documentation

# serosv 1.2.0
* add to_titer() function to convert assay reading to titer
* update the docs
* update article for to_titer() on the website

# serosv 1.1.0
* add correct_prevalence() function to estimate real prevalence from imperfect test
Expand Down
30 changes: 21 additions & 9 deletions R/age_time_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
#'
#' @description Fit age-stratified seroprevalence across multiple time points. Also try to monotonize age (or birth cohort) - specific seroprevalence.
#'
#' @param data - input data, must have`age`, `status`, time, group columns, where group column determines how data is aggregated
#' @param time_col - name of the column for time (default to `date`)
#' @param grouping_col - name of the column for time (default to `group`)
#' @param age_correct - a boolean, if `TRUE`, monotonize age-specific prevalence. Monotonize birth cohort-specific seroprevalence otherwise.
#' @param le - number of bins to generate age grid, used when monotonizing data
#' @param ci - confidence interval for smoothing
#' @param monotonize_method - either "pava" or "scam"
#' @param data input data, must have age, status, time, group columns, where group column determines how data is aggregated
#' @param age_col name of the `age` column (default age_col="age").
#' @param pos_col name of the `pos` column (default pos_col="pos").
#' @param tot_col name of the `tot` column (default tot_col="tot").
#' @param status_col name of the `status` column (default status_col="status").
#' @param time_col name of the column for time (default to "date")
#' @param grouping_col name of the column for time (default to "group")
#' @param age_correct a boolean, if `TRUE`, monotonize age-specific prevalence. Monotonize birth cohort-specific seroprevalence otherwise.
#' @param le number of bins to generate age grid, used when monotonizing data
#' @param ci confidence interval for smoothing
#' @param monotonize_method either "pava" or "scam"
#'
#' @import scam assertthat
#' @importFrom mgcv gam predict.gam betar
#' @importFrom purrr map map_dbl map2
#'
#' @return a list of class time_age_model with 4 items
#' \item{out}{a data.frame with dimension n_group x 9, where columns `info`, `sp`, `foi` store output for non-monotonized
Expand All @@ -20,7 +26,10 @@
#' \item{age_correct}{a boolean indicating whether the data is monotonized across age or cohort}
#' \item{datatype}{whether the input data is aggregated or line-listing data}
#' @export
age_time_model <- function(data, time_col="date", grouping_col="group", age_correct=F, le=512, ci = 0.95, monotonize_method = "pava"){
age_time_model <- function(data,
age_col="age", status_col="status", pos_col="pos", tot_col="tot",
time_col="date", grouping_col="group",
age_correct=F, le=512, ci = 0.95, monotonize_method = "pava"){
# work around to resolve no visible binding note NOTE during check()
x <- label <- family <- fit <- se.fit <- ymin <- ymax <- y <- mean_time <- prevalence <- sim_data <- NULL
age <- ys <- shift_no <- cohort <- col_time <- monotonized_mod <- df <- info <- sp <- monotonized_info <- monotonized_sp <- NULL
Expand Down Expand Up @@ -82,7 +91,8 @@ age_time_model <- function(data, time_col="date", grouping_col="group", age_corr
model <- list()

# --- preprocess data ------
check_input <- check_input(data)
check_input <- check_input(data,
stratum_col=age_col,pos_col=pos_col, tot_col=tot_col, status_col=status_col)
age_range <- range(data$age)
age_grid <- seq(age_range[1], age_range[2], length.out = le)

Expand Down Expand Up @@ -230,8 +240,10 @@ age_time_model <- function(data, time_col="date", grouping_col="group", age_corr
)

model$out <- out
model$monotonize_method <- monotonize_method
model$grouping_col <- grouping_col
model$age_correct <- age_correct
model$ci <- ci


class(model) <- "age_time_model"
Expand Down
Loading
Loading