Skip to content

Commit

Permalink
removd blims from use specification and imbedded age to years transfo…
Browse files Browse the repository at this point in the history
…rmation. need help taking out day2yr
  • Loading branch information
kaiemjoy committed Nov 20, 2023
1 parent 187140a commit 9930fc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 6 additions & 4 deletions R/sim.cs.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#' - `r`: shape factor of antibody decay

#' @param predpar an [array()] containing MCMC samples from the Bayesian distribution of longitudinal decay curve model parameters. NOTE: most users should leave `predpar` at its default value and provide `curve_params` instead.
#' @param noise_limits noise distribution parameters
#' @param baseline_limits baseline noise distribution parameters
#' @param noise_limits biologic noise distribution parameters
#' @param npar number of longitudinal curve parameters in model
#' @param ... additional arguments passed to `simcs.tinf()`
#' @return a [dplyr::tibble()] containing simulated cross-sectional serosurvey data, with columns:
Expand All @@ -52,15 +51,18 @@ sim.cs <- function(
prep_curve_params_for_array() %>%
df_to_array(dim_var_names = c("antigen_iso", "parameter")),
noise_limits,
baseline_limits,
npar,
...)
{

stopifnot(length(lambda) == 1)

day2yr = 365.25

ablist = 1:length(antigen_isos)

baseline_limits <- noise_limits

ysim <- simcs.tinf(
lambda = lambda,
n.smpl = n.smpl,
Expand All @@ -86,6 +88,6 @@ sim.cs <- function(
}
colnames(ysim) <- c("age", antigen_isos)

return(ysim |> as_tibble())
return(ysim |> as_tibble() %>% mutate(age = round(age/day2yr, 2)))

}
10 changes: 2 additions & 8 deletions vignettes/articles/simulate_xsectionalData.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ ab.nm <- rbind(c("HlyE","IgA"),c("HlyE","IgG"));
# antibodies <- dmcmc$antigen_iso |> droplevels() |> levels()
antibodies = c("HlyE_IgA", "HlyE_IgG")
abs <- c(1,2);
age.fx <- NA; # age used for longitudinal model (fixed for now)
day2yr <- 365.25;
lambda <- 0.2; # incidence (1/yr)
npar <- 5; # y0, y1, t1, alpha, shape
lifespan <- c(0,20); # range covered in simulations
nrep <- 100; # cross-sectional sample size
dlims <- rbind(c(1e-2,5e-1),c(1e-2,5e-1)); # noise distribution
blims <- dlims; # baseline distribution
dlims <- rbind(c(1e-2,5e-1),c(1e-2,5e-1)); # biologic noise distribution
csdata0 <- sim.cs(
curve_params = dmcmc,
Expand All @@ -88,12 +85,10 @@ csdata0 <- sim.cs(
renew.params = TRUE,
add.noise = TRUE,
noise_limits = dlims,
baseline_limits = blims,
npar = npar
)
csdata0[, 1] <- csdata0[, 1] / day2yr
```

Expand Down Expand Up @@ -126,7 +121,6 @@ sim.cl <-
npar = npar
)
csdata[, 1] <- csdata[, 1] / day2yr
csdata1 <- csdata %>%
as.data.frame() %>%
Expand Down Expand Up @@ -157,7 +151,7 @@ csdataL <- as.data.frame(csdata0) %>%
est.incidence(csdataL %>%
rename(y = value,
a = age),
dmcmc, cond, antigen_isos = c("HlyE_IgA"))
dmcmc, cond, antigen_isos = c("HlyE_IgG", "HlyE_IgA"))
```
Expand Down

0 comments on commit 9930fc5

Please sign in to comment.