Learn R Programming

serosv

serosv is an easy-to-use and efficient tool to estimate infectious diseases parameters (seroprevalence and force of infection) using serological data. The current version is based on the book “Modeling Infectious Disease Parameters Based on Serological and Social Contact Data – A Modern Statistical Perspective” by Hens et al., 2012 Springer.

Installation

You can install the development version of serosv with:

# install.packages("devtools")
devtools::install_github("OUCRU-Modelling/serosv")

Feature overview

Datasets

serosv contains 15 built-in serological datasets as provided by Hens et al., 2012 Springer. Simply call the name to load a dataset, for example:

rubella <- rubella_uk_1986_1987

Methods

The following methods are available to estimate seroprevalence and force of infection.

Parametric approaches:

  • Polynomial models:
    • Muench’s model
    • Griffiths’ model
    • Grenfell and Anderson’s model
  • Nonlinear models:
    • Farrington’s model
    • Weibull model
  • Fractional polynomial models

Nonparametric approaches:

  • Local estimation by polynomials

Semiparametric approaches:

  • Penalized splines:

    • Penalized likelihood framework

    • Generalized Linear Mixed Model framework

Hierarchical Bayesian approaches:

  • Hierarchical Farrington model

  • Hierarchical log-logistic model

Demo

Fitting rubella data from the UK

Load the rubella in UK dataset.

library(serosv)

Find the power for the best second degree fractional polynomial with monotonicity constraint and a logit link function. The power appears to be (-0.9,-0.9).

rubella <- rubella_uk_1986_1987

best_2d_mn <- find_best_fp_powers(
  rubella,
  p=seq(-2,3,0.1), mc = T, degree=2, link="logit"
)

best_2d_mn
#> $p
#> [1] -0.9 -0.9
#> 
#> $deviance
#> [1] 37.57966
#> 
#> $model
#> 
#> Call:  glm(formula = as.formula(formulate(p_cur)), family = binomial(link = link))
#> 
#> Coefficients:
#>               (Intercept)                I(age^-0.9)  I(I(age^-0.9) * log(age))  
#>                     4.342                     -4.696                     -9.845  
#> 
#> Degrees of Freedom: 43 Total (i.e. Null);  41 Residual
#> Null Deviance:       1369 
#> Residual Deviance: 37.58     AIC: 210.1

Finally, fit the second degree fractional polynomial.

fpmd <- fp_model(
  rubella,
  p=c(-0.9, -0.9), link="logit")

plot(fpmd)

Fitting Parvo B19 data from Finland

parvob19 <- parvob19_fi_1997_1998

# for linelisting data, either transform it to aggregated
transform_data(
  parvob19$age, 
  parvob19$seropositive,
  heterogeneity_col = "age") %>% 
  polynomial_model(type = "Muench") %>% 
  plot()

# or fit data as is
parvob19 %>% 
  rename(status = seropositive) %>% 
  polynomial_model(type = "Muench") %>% 
  plot()

Copy Link

Version

Install

install.packages('serosv')

Monthly Downloads

207

Version

1.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Anh Phan Truong Quynh

Last Published

April 9th, 2025

Functions in serosv (1.1.0)

estimate_from_mixture

Estimate seroprevalence and foi by combining mixture model and regression
hierarchical_bayesian_model

Hierarchical Bayesian Model
compute_ci.fp_model

Compute confidence interval for fractional polynomial model
hav_be_2002

Hepatitis A serological data from Belgium in 2002 (line listing)
compute_ci.lp_model

Compute confidence interval for local polynomial model
compute_ci.mixture_model

Compute confidence interval for mixture model
farrington_model

The Farrington (1990) model.
compute_ci.penalized_spline_model

Compute confidence interval for penalized_spline_model
find_best_fp_powers

Returns the powers of the GLM fitted model which has the lowest deviance score.
compute_ci.weibull_model

Compute confidence interval for Weibull model
pava

Monotonize seroprevalence
lp_model

A local polynomial model.
plot.hierarchical_bayesian_model

plot() overloading for hierarchical_bayesian_model
penalized_spline_model

Penalized Spline model
plot.fp_model

plot() overloading for fractional polynomial model
parvob19_fi_1997_1998

Parvo B19 serological data from Finland from 1997-1998 (line listing)
parvob19_ew_1996

Parvo B19 serological data from England and Wales in 1996 (line listing)
fp_model

A fractional polynomial model.
plot.mixture_model

plot() overloading for mixture model
plot.lp_model

plot() overloading for local polynomial model
hav_bg_1964

Hepatitis A serological data from Bulgaria in 1964 (aggregated)
sir_static_model

SIR static model (age-heterogeneous, endemic equilibrium)
serosv-package

serosv: model infectious disease parameters
rubella_uk_1986_1987

Rubella serological data from the UK in 1986 and 1987 (aggregated)
sir_subpops_model

SIR Model with Interacting Subpopulations
plot.estimate_from_mixture

plot() overloading for result of estimate_from_mixture
hav_be_1993_1994

Hepatitis A serological data from Belgium in 1993 and 1994 (aggregated)
sir_basic_model

Basic SIR model
set_plot_style

Helper to adjust styling of a plot
plot.farrington_model

plot() overloading for Farrington model
plot.weibull_model

plot() overloading for Weibull model
mumps_uk_1986_1987

Mumps serological data from the UK in 1986 and 1987 (aggregated)
parvob19_pl_1995_2004

Parvo B19 serological data from Poland from 1995-2004 (line listing)
parvob19_it_2003_2004

Parvo B19 serological data from Italy from 2003-2004 (line listing)
parvob19_be_2001_2003

Parvo B19 serological data from Belgium from 2001-2003 (line listing)
plot_gcv

Plotting GCV values with respect to different nn-s and h-s parameters.
vzv_be_2001_2003

VZV serological data from Belgium from 2001-2003 (line listing)
plot.mseir_model

plot() overloading for MSEIR model
vzv_be_1999_2000

VZV serological data from Belgium (Flanders) from 1999-2000 (aggregated)
plot.penalized_spline_model

plot() overloading for penalized spline
correct_prevalence

Estimate the true sero prevalence using Bayesian estimation
hbv_ru_1999

Hepatitis B serological data from Russia in 1999 (aggregated)
vzv_parvo_be

VZV and Parvovirus B19 serological data in Belgium (line listing)
hcv_be_2006

Hepatitis C serological data from Belgium in 2006 (line listing)
polynomial_model

Polynomial models
weibull_model

The Weibull model.
rubella_mumps_uk

Rubella - Mumps data from the UK (aggregated)
mixture_model

Fit a mixture model to classify serostatus
mseir_model

MSEIR model
plot.polynomial_model

plot() overloading for polynomial model
plot.sir_subpops_model

plot() overloading for SIR sub populations model
plot.sir_static_model

plot() overloading for SIR static model
plot.sir_basic_model

plot() overloading for SIR model
tb_nl_1966_1973

Tuberculosis serological data from the Netherlands 1966-1973 (aggregated)
transform_data

Generate a dataframe with `t`, `pos` and `tot` columns from `t` and `seropositive` vectors.
compare_models

Compare models
compute_ci

Compute confidence interval
est_foi

Estimate force of infection