| est.incidence.by {serocalculator} | R Documentation |
Estimate Seroincidence
Description
Function to estimate seroincidences based on cross-section serology data and longitudinal response model.
Usage
est.incidence.by(
pop_data,
curve_params,
noise_params,
strata,
curve_strata_varnames = strata,
noise_strata_varnames = strata,
antigen_isos = pop_data %>% pull("antigen_iso") %>% unique(),
lambda_start = 0.1,
build_graph = FALSE,
num_cores = 1L,
verbose = FALSE,
print_graph = FALSE,
...
)
Arguments
pop_data |
|
curve_params |
a
|
noise_params |
a
|
strata |
Character vector of stratum-defining variables. Values must be variable names in |
curve_strata_varnames |
A subset of |
noise_strata_varnames |
A subset of |
antigen_isos |
Character vector with one or more antibody names. Values must match |
lambda_start |
starting guess for incidence rate, in years/event. |
build_graph |
whether to graph the log-likelihood function across a range of incidence rates (lambda values) |
num_cores |
Number of processor cores to use for calculations when computing by strata. If set to more than 1 and package parallel is available, then the computations are executed in parallel. Default = 1L. |
verbose |
logical: if TRUE, print verbose log information to console |
print_graph |
whether to display the log-likelihood curve graph in the course of running |
... |
Arguments passed on to
|
Details
If strata is left empty, a warning will be produced, recommending that you use est.incidence() for unstratified analyses, and then the data will be passed to est.incidence(). If for some reason you want to use est.incidence.by() with no strata instead of calling est.incidence(), you may use NA, NULL, or "" as the strata argument to avoid that warning.
Value
if
stratahas meaningful inputs: An object of class"seroincidence.by"; i.e., a list of"seroincidence"objects fromest.incidence(), one for each stratum, with some meta-data attributes.if
stratais missing,NULL,NA, or"": An object of class"seroincidence".
Examples
library(dplyr)
xs_data <- load_pop_data("https://osf.io/download//n6cp3/") %>%
clean_pop_data()
curve <- load_curve_params("https://osf.io/download/rtw5k/") %>%
filter(antigen_iso %in% c("HlyE_IgA", "HlyE_IgG")) %>%
slice(1:100, .by = antigen_iso) # Reduce dataset for the purposes of this example
noise <- load_noise_params("https://osf.io/download//hqy4v/")
est2 <- est.incidence.by(
strata = c("catchment"),
pop_data = xs_data %>% filter(Country == "Pakistan"),
curve_params = curve,
noise_params = noise %>% filter(Country == "Pakistan"),
antigen_isos = c("HlyE_IgG", "HlyE_IgA"),
#num_cores = 8 # Allow for parallel processing to decrease run time
)
summary(est2)