Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: serocalculator
Title: Estimating Infection Rates from Serological Data
Version: 1.3.0.9050
Version: 1.3.0.9051
Authors@R: c(
person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"),
comment = "Author of the method and original code."),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Added new functions `analyze_sims()` and `autoplot.sim_results()` (#444)
* Rename `estimate_scr()` to `est_seroincidence_by()` (#439)
* Rename `estimate_scr()` to `est_seroincidence()` (#432)
* Rename argument `curve_params` to `sr_params` (#424)
* Rename argument `curve_params` to `sr_params` for estimation functions (#424)
* added documentation for `count_strata()` (#431)
* Rename `as_curve_params()` to `as_sr_params()` (#421)
* Rename `load_curve_params()` to `load_sr_params()` (#421)
Expand Down
2 changes: 1 addition & 1 deletion R/autoplot.seroincidence.by.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' est2 <- est_seroincidence_by(
#' strata = c("catchment"),
#' pop_data = xs_data,
#' curve_params = curve,
#' sr_params = curve,
#' curve_strata_varnames= NULL,
#' noise_strata_varnames = NULL,
#' noise_params = noise,
Expand Down
2 changes: 1 addition & 1 deletion R/autoplot.summary.seroincidence.by.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' est2 <- est_seroincidence_by(
#' strata = c("catchment", "ageCat"),
#' pop_data = xs_data,
#' curve_params = curve,
#' sr_params = curve,
#' noise_params = noise,
#' curve_strata_varnames= NULL,
#' noise_strata_varnames = NULL,
Expand Down
12 changes: 6 additions & 6 deletions R/est_seroincidence_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#' @inheritParams est_seroincidence
#' @inheritParams log_likelihood
#' @inheritDotParams est_seroincidence -sr_params
#' @inheritDotParams est_seroincidence
#' @inheritDotParams stats::nlm -f -p -hessian -print.level -steptol
#'
#' @return
Expand Down Expand Up @@ -60,7 +60,7 @@
#' est2 <- est_seroincidence_by(
#' strata = "catchment",
#' pop_data = xs_data,
#' curve_params = curve,
#' sr_params = curve,
#' noise_params = noise,
#' antigen_isos = c("HlyE_IgG", "HlyE_IgA"),
#' # num_cores = 8 # Allow for parallel processing to decrease run time
Expand All @@ -71,7 +71,7 @@
#'
est_seroincidence_by <- function(
pop_data,
curve_params,
sr_params,
noise_params,
strata,
curve_strata_varnames = strata,
Expand Down Expand Up @@ -109,7 +109,7 @@ est_seroincidence_by <- function(
to_return <-
est_seroincidence(
pop_data = pop_data,
sr_params = curve_params,
sr_params = sr_params,
noise_params = noise_params,
lambda_start = lambda_start,
antigen_isos = antigen_isos,
Expand All @@ -125,14 +125,14 @@ est_seroincidence_by <- function(
.errorCheck(
data = pop_data,
antigen_isos = antigen_isos,
curve_params = curve_params
curve_params = sr_params
)

# Split data per stratum
stratum_data_list <- stratify_data(
antigen_isos = antigen_isos,
data = pop_data |> filter(.data$antigen_iso %in% antigen_isos),
curve_params = curve_params |> filter(.data$antigen_iso %in% antigen_isos),
curve_params = sr_params |> filter(.data$antigen_iso %in% antigen_isos),
noise_params = noise_params |> filter(.data$antigen_iso %in% antigen_isos),
strata_varnames = strata,
curve_strata_varnames = curve_strata_varnames,
Expand Down
2 changes: 1 addition & 1 deletion R/print.seroincidence.by.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' est2 <- est_seroincidence_by(
#' strata = c("catchment"),
#' pop_data = xs_data,
#' curve_params = curve,
#' sr_params = curve,
#' noise_params = noise,
#' antigen_isos = c("HlyE_IgG", "HlyE_IgA"),
#' # num_cores = 8 # Allow for parallel processing to decrease run time
Expand Down
2 changes: 1 addition & 1 deletion R/print.summary.seroincidence.by.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' est2 <- est_seroincidence_by(
#' strata = c("catchment"),
#' pop_data = xs_data,
#' curve_params = curve,
#' sr_params = curve,
#' noise_params = noise,
#' antigen_isos = c("HlyE_IgG", "HlyE_IgA"),
#' # num_cores = 8 # Allow for parallel processing to decrease run time
Expand Down
2 changes: 1 addition & 1 deletion R/summary.seroincidence.by.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' est2 <- est_seroincidence_by(
#' strata = c("catchment"),
#' pop_data = xs_data,
#' curve_params = curve,
#' sr_params = curve,
#' noise_params = noise,
#' antigen_isos = c("HlyE_IgG", "HlyE_IgA"),
#' # num_cores = 8 # Allow for parallel processing to decrease run time
Expand Down
2 changes: 1 addition & 1 deletion data-raw/sees_typhoid_ests_strat.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ noise <- "https://osf.io/download//hqy4v/" |> readr::read_rds()
sees_typhoid_ests_strat <- est_seroincidence_by(
strata = c("ageCat", "Country"),
pop_data = xs_data,
curve_params = curve,
sr_params = curve,
curve_strata_varnames = NULL,
noise_params = noise,
noise_strata_varnames = "Country",
Expand Down
69 changes: 34 additions & 35 deletions inst/examples/exm-analyze_sims.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\donttest{

Check warning on line 1 in inst/examples/exm-analyze_sims.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=inst/examples/exm-analyze_sims.R,line=1,col=2,[error] unexpected symbol
dmcmc <- typhoid_curves_nostrat_100

n_cores <- 2
Expand All @@ -13,46 +13,45 @@
antibodies <- c("HlyE_IgA", "HlyE_IgG")
lifespan <- c(0, 10)
dlims = rbind(
"HlyE_IgA" = c(min = 0, max = 0.5),
"HlyE_IgG" = c(min = 0, max = 0.5)
"HlyE_IgA" = c(min = 0, max = 0.5),
"HlyE_IgG" = c(min = 0, max = 0.5)
)
sim_df <- sim_pop_data_multi(
n_cores = n_cores,
lambdas = lambdas,
nclus = nclus,
sample_sizes = nrep,
age_range = lifespan,
antigen_isos = antibodies,
renew_params = FALSE,
add_noise = TRUE,
curve_params = dmcmc,
noise_limits = dlims,
format = "long"
)
sim_df <-
sim_pop_data_multi(
n_cores = n_cores,
lambdas = lambdas,
nclus = nclus,
sample_sizes = nrep,
age_range = lifespan,
antigen_isos = antibodies,
renew_params = FALSE,
add_noise = TRUE,
curve_params = dmcmc,
noise_limits = dlims,
format = "long"
)
cond <- tibble::tibble(
antigen_iso = c("HlyE_IgG", "HlyE_IgA"),
nu = c(0.5, 0.5), # Biologic noise (nu)
eps = c(0, 0), # M noise (eps)
y.low = c(1, 1), # low cutoff (llod)
y.high = c(5e6, 5e6)
antigen_iso = c("HlyE_IgG", "HlyE_IgA"),
nu = c(0.5, 0.5), # Biologic noise (nu)
eps = c(0, 0), # M noise (eps)
y.low = c(1, 1), # low cutoff (llod)
y.high = c(5e6, 5e6)
)
ests <-
est_seroincidence_by(
pop_data = sim_df,
curve_params = dmcmc,
noise_params = cond,
num_cores = n_cores,
strata = c("lambda.sim", "sample_size", "cluster"),
curve_strata_varnames = NULL,
noise_strata_varnames = NULL,
verbose = FALSE,
build_graph = FALSE, # slows down the function substantially
antigen_isos = c("HlyE_IgG", "HlyE_IgA")
)
est_seroincidence_by(
pop_data = sim_df,
sr_params = dmcmc,
noise_params = cond,
num_cores = n_cores,
strata = c("lambda.sim", "sample_size", "cluster"),
curve_strata_varnames = NULL,
noise_strata_varnames = NULL,
verbose = FALSE,
build_graph = FALSE, # slows down the function substantially
antigen_isos = c("HlyE_IgG", "HlyE_IgA")
)

ests |>
summary() |>
analyze_sims()
summary() |>
analyze_sims()

}
102 changes: 51 additions & 51 deletions inst/examples/exm-autoplot.sim_results.R
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
\donttest{

Check warning on line 1 in inst/examples/exm-autoplot.sim_results.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=inst/examples/exm-autoplot.sim_results.R,line=1,col=2,[error] unexpected symbol
dmcmc <- typhoid_curves_nostrat_100
dmcmc <- typhoid_curves_nostrat_100

n_cores <- 2
n_cores <- 2

nclus <- 20
# cross-sectional sample size
nrep <- c(50, 200)
nclus <- 20
# cross-sectional sample size
nrep <- c(50, 200)

# incidence rate in e
lambdas <- c(.05, .8)
lifespan <- c(0, 10)
antibodies <- c("HlyE_IgA", "HlyE_IgG")
dlims <- rbind(
"HlyE_IgA" = c(min = 0, max = 0.5),
"HlyE_IgG" = c(min = 0, max = 0.5)
)
sim_df <-
sim_pop_data_multi(
n_cores = n_cores,
lambdas = lambdas,
nclus = nclus,
sample_sizes = nrep,
age_range = lifespan,
antigen_isos = antibodies,
renew_params = FALSE,
add_noise = TRUE,
curve_params = dmcmc,
noise_limits = dlims,
format = "long"
)
cond <- tibble::tibble(
antigen_iso = c("HlyE_IgG", "HlyE_IgA"),
nu = c(0.5, 0.5), # Biologic noise (nu)
eps = c(0, 0), # M noise (eps)
y.low = c(1, 1), # low cutoff (llod)
y.high = c(5e6, 5e6)
)
ests <-
est_seroincidence_by(
pop_data = sim_df,
curve_params = dmcmc,
noise_params = cond,
num_cores = n_cores,
strata = c("lambda.sim", "sample_size", "cluster"),
curve_strata_varnames = NULL,
noise_strata_varnames = NULL,
verbose = FALSE,
build_graph = FALSE, # slows down the function substantially
antigen_isos = c("HlyE_IgG", "HlyE_IgA")
)
# incidence rate in e
lambdas <- c(.05, .8)
lifespan <- c(0, 10)
antibodies <- c("HlyE_IgA", "HlyE_IgG")
dlims <- rbind(
"HlyE_IgA" = c(min = 0, max = 0.5),
"HlyE_IgG" = c(min = 0, max = 0.5)
)
sim_df <-
sim_pop_data_multi(
n_cores = n_cores,
lambdas = lambdas,
nclus = nclus,
sample_sizes = nrep,
age_range = lifespan,
antigen_isos = antibodies,
renew_params = FALSE,
add_noise = TRUE,
curve_params = dmcmc,
noise_limits = dlims,
format = "long"
)
cond <- tibble::tibble(
antigen_iso = c("HlyE_IgG", "HlyE_IgA"),
nu = c(0.5, 0.5), # Biologic noise (nu)
eps = c(0, 0), # M noise (eps)
y.low = c(1, 1), # low cutoff (llod)
y.high = c(5e6, 5e6)
)
ests <-
est_seroincidence_by(
pop_data = sim_df,
sr_params = dmcmc,
noise_params = cond,
num_cores = n_cores,
strata = c("lambda.sim", "sample_size", "cluster"),
curve_strata_varnames = NULL,
noise_strata_varnames = NULL,
verbose = FALSE,
build_graph = FALSE, # slows down the function substantially
antigen_isos = c("HlyE_IgG", "HlyE_IgA")
)

ests |>
summary() |>
analyze_sims() |>
autoplot()
ests |>
summary() |>
analyze_sims() |>
autoplot()

}
2 changes: 1 addition & 1 deletion inst/examples/exm-strat_ests_barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ noise <-
est2 <- est_seroincidence_by(
strata = c("catchment", "ageCat"),
pop_data = xs_data,
curve_params = curve,
sr_params = curve,
noise_params = noise,
curve_strata_varnames = NULL,
noise_strata_varnames = NULL,
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/exm-strat_ests_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ noise <-
est2 <- est_seroincidence_by(
strata = c("catchment", "ageCat"),
pop_data = xs_data,
curve_params = curve,
sr_params = curve,
noise_params = noise,
curve_strata_varnames = NULL,
noise_strata_varnames = NULL,
Expand Down
Loading
Loading