Learn R Programming

{serocalculator}

Antibody levels measured in a cross–sectional population sample can be translated into an estimate of the frequency with which seroconversions (infections) occur in the sampled population. In other words, the presence of many high antibody titers indicates that many individuals likely experienced infection recently and the burden of disease is high in the population, while low titers indicate a low frequency of infections in the sampled population and therefore a lower burden of disease.

The {serocalculator} package was designed to use the longitudinal response characteristics using a set of modeled parameters characterizing the longitudinal response of the selected serum antibodies. More details on the underlying methods can be found in Getting Started.

Installing R

The {serocalculator} package is designed to be used in R, which is a free, open-source software environment for statistical computing and graphics. The end user of this package must have access to a working installation of the R software. We recommend installing base R and a Graphical User Interface (GUI) for R such as RStudio.

If you need to download and install R and/or RStudio, we recommend following the tutorial below from Hands On Programming in R by Garrett Grolemund:

Installing R and RStudio: https://rstudio-education.github.io/hopr/starting.html

Installing the {serocalculator} Package

The {serocalculator} package must be installed in R before first use.

# Install package
install.packages("serocalculator")

Installing the Development Version

To install the latest development version, you must install the {devtools} R package and then download {serocalculator} from GitHub. Enter the code below into the R console to install both packages.

# Install the devtools package and the development version of serocalculator
install.packages("devtools")
devtools::install_github(
  repo = "ucd-serg/serocalculator", 
  build_manual = TRUE)

A Note for Windows Users

Before installing the development version of {serocalculator}, Windows users will need to install Rtools, which contains a collection of tools for building and employing R packages that are still in development. This can be done either:

  1. during the devtools package installation, or

  2. independently, if devtools is already installed.

During devtools installation

When prompted to install additional build tools, select “Yes”, and Rtools will be installed.

Note: After installing Rtools, you may need to restart RStudio before continuing to install serocalculator.

Independently:
  1. Download Rtools from https://cran.r-project.org/bin/windows/Rtools/

  2. Run the installer

    • During the Rtools installation you may see a window asking you to “Select Additional Tasks”.
    • Do not select the box for “Edit the system PATH”. devtools and RStudio should put Rtools on the PATH automatically when it is needed.
    • Do select the box for “Save version information to registry”. It should be selected by default.

Learning to use {serocalculator}

Successful installation can be confirmed by loading the package into your R workspace and exploring help files and manuals distributed with the package:

# Load package "seroincidence".
library(serocalculator)

# Show R help for the package.
?serocalculator

Additionally, most package details can be found when executing the following commands:

# Show description.
packageDescription("serocalculator")

# Show citation.
citation("serocalculator")

The full documentation for the current CRAN release version of {serocalculator} can be accessed at https://ucd-serg.github.io/serocalculator/, and the the documentation for the main in-development version can be accessed at https://ucd-serg.github.io/serocalculator/dev/.

Getting Help

If you have questions about using this software package, please use the Q&A forum.

If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub.

Another great resource is The Epidemiologist R Handbook, which includes an introductory page on asking for help with R packages via GitHub: https://epirhandbook.com/en/new_pages/help.html

Contributing to this project

We welcome contributions to this project - anything from typo corrections to new features. Please see our Contributor guide for more information.

QR code

This QR code is a direct link to the latest-release version of the package website:

#> Warning: package 'qrcode' was built under R version 4.4.2

Copy Link

Version

Install

install.packages('serocalculator')

Monthly Downloads

7,122

Version

1.4.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Kristina Lai

Last Published

December 11th, 2025

Functions in serocalculator (1.4.0)

example_noise_params_sees

Small example of noise parameters for typhoid
est.incidence

Estimate Seroincidence
get_biomarker_names_var

Get biomarker variable name
get_biomarker_names

Extract biomarker names column
example_noise_params_pk

Small example of noise parameters for typhoid
baseline

Substitute baseline values
ldpar

extract a row from longitudinal parameter set
get_values

Get antibody measurement values
load_sr_params

Load longitudinal seroresponse parameter samples
load_pop_data

Load a cross-sectional antibody survey data set
sim.cs.multi

Simulate multiple data sets
graph_loglik

Graph log-likelihood of data
expect_snapshot_data

f_dev

Calculate negative log-likelihood (deviance) for one antigen:isotype pair and several values of incidence
get_values_var

Extract antibody measurement values
sees_pop_data_pk_100

Small example cross-sectional data set
mk_baseline

generate random sample from baseline distribution
llik

Calculate log-likelihood
graph.curve.params

Graph estimated antibody decay curves
log_likelihood

Calculate log-likelihood
serocalculator_example

Get path to an example file
load_noise_params

Load noise parameters
check_pop_data

Check the formatting of a cross-sectional antibody survey dataset.
plot_curve_params_one_ab

Graph an antibody decay curve model
set_id_var

Specify person ID column
simcs.tinf

collect cross-sectional data
load_curve_params

Load antibody decay curve parameter samples
serocalculator-package

serocalculator: Estimating Infection Rates from Serological Data
sim.cs

Simulate a cross-sectional serosurvey with noise
print.seroincidence

Print Method for seroincidence Class
graph_seroresponse_model_1

graph antibody decay curves by antigen isotype
sim_pop_data

Simulate a cross-sectional serosurvey with noise
summary.seroincidence.by

Summary Method for "seroincidence.by" Objects
strata

Extract Strata metadata from an object
sees_typhoid_ests_strat

Example "seroincidence.by" object
simresp.tinf

simulate antibody kinetics of y over a time interval
strat_ests_barplot

Barplot method for summary.seroincidence.by objects
strat_ests_scatterplot

Scatterplot method for summary.seroincidence.by objects
ids

Get person IDs
print.seroincidence.by

Print Method for seroincidence.by Object
ids_varname

Get person ID variable name
sees_pop_data_pk_100_old_names

Small example cross-sectional data set
sim_pop_data_multi

Simulate multiple data sets
typhoid_curves_nostrat_100

Small example of antibody response curve parameters for typhoid
strata.default

Extract the Strata attribute from an object, if present
print.summary.seroincidence.by

Print Method for Seroincidence Summary Object
reexports

Objects exported from other packages
summary.seroincidence

Summarizing fitted seroincidence models
summary.pop_data

Summarize cross-sectional antibody survey data
warn_missing_strata

Warn about missing stratifying variables in a dataset
stratify_data

Split data by stratum
sees_pop_data_100

Small example cross-sectional data set
[.seroincidence.by

Extract or replace parts of a seroincidence.by object
as_curve_params

Load antibody decay curve parameter
analyze_sims

Analyze simulation results
as_noise_params

Load noise parameters
as_sr_params

Load longitudinal seroresponse parameters
autoplot.curve_params

Graph antibody decay curves by antigen isotype
as_pop_data

Load a cross-sectional antibody survey data set
autoplot.pop_data

Plot distribution of antibodies
autoplot.seroincidence

Plot the log-likelihood curve for the incidence rate estimate
autoplot.seroincidence.by

Plot seroincidence.by log-likelihoods
autoplot.summary.seroincidence.by

Plot method for summary.seroincidence.by objects
autoplot.sim_results

Plot simulation results autoplot() method for sim_results objects
ab

kinetics of the antibody (ab) response (power function decay)
count_strata

Count observations by stratum
df.to.array

Convert a data.frame (or tibble) into a multidimensional array
df_to_array

Convert a data.frame (or tibble) into a multidimensional array
.nll

Calculate negative log-likelihood
est.incidence.by

Estimate Seroincidence
get_biomarker_levels

Extract biomarker levels
est_seroincidence

Find the maximum likelihood estimate of the incidence rate parameter
fdev

Calculate negative log-likelihood (deviance)
f_dev0

Calculate negative log-likelihood (deviance) for one antigen:isotype pair and one incidence rate
est_seroincidence_by

Estimate Seroincidence