sim.cs {serocalculator} | R Documentation |
Simulate a cross-sectional serosurvey with noise
Description
Makes a cross-sectional data set (age, y(t) set) and adds noise, if desired.
Usage
sim.cs(
lambda = 0.1,
n.smpl = 100,
age.rng = c(0, 20),
age.fx = NA,
antigen_isos,
n.mc = 0,
renew.params = FALSE,
add.noise = FALSE,
curve_params,
noise_limits,
format = "wide",
verbose = FALSE,
...
)
Arguments
lambda |
a |
n.smpl |
number of samples to simulate |
age.rng |
age range of sampled individuals, in years |
age.fx |
specify the curve parameters to use by age (does nothing at present?) |
antigen_isos |
Character vector with one or more antibody names. Values must match |
n.mc |
how many MCMC samples to use:
|
renew.params |
whether to generate a new parameter set for each infection
|
add.noise |
a |
curve_params |
a
|
noise_limits |
biologic noise distribution parameters |
format |
a
|
verbose |
logical: if TRUE, print verbose log information to console |
... |
additional arguments passed to |
Value
a tibble::tbl_df containing simulated cross-sectional serosurvey data, with columns:
-
age
: age (in days) one column for each element in the
antigen_iso
input argument
Examples
# Load curve parameters
dmcmc <- load_curve_params("https://osf.io/download/rtw5k")
# Specify the antibody-isotype responses to include in analyses
antibodies <- c("HlyE_IgA", "HlyE_IgG")
# Set seed to reproduce results
set.seed(54321)
# Simulated incidence rate per person-year
lambda <- 0.2;
# Range covered in simulations
lifespan <- c(0, 10);
# Cross-sectional sample size
nrep <- 100
# Biologic noise distribution
dlims <- rbind(
"HlyE_IgA" = c(min = 0, max = 0.5),
"HlyE_IgG" = c(min = 0, max = 0.5))
# Generate cross-sectional data
csdata <- sim.cs(
curve_params = dmcmc,
lambda = lambda,
n.smpl = nrep,
age.rng = lifespan,
antigen_isos = antibodies,
n.mc = 0,
renew.params = TRUE,
add.noise = TRUE,
noise_limits = dlims,
format = "long"
)