Simulate longitudinal case data with known cross-biomarker covariance
Source:R/sim_case_data_2a.R
sim_case_data_2a.RdEnd-to-end simulator for validating Model 2a. It draws correlated
subject-level parameters with sim_params_2a(), evaluates the Chapter 1
two-phase curve ab() at a set of visit times for two biomarkers, adds
log-normal measurement noise, and returns a long data.frame in the
serocalculator case-data layout that prep_data() / run_mod_2a()
accept.
Decomposed on purpose: the statistical truth lives in sim_params_2a(), the
curve in ab(), and this function only handles visit times, noise, and
reshaping.
Arguments
- n
integer number of subjects.
- mu_g, mu_a, sigma_g, sigma_a, c_vec
Model 2a truth, passed to
sim_params_2a().- visit_times
numeric vector of sampling times (days) shared by all subjects. Default
c(0, 7, 14, 28, 56, 90, 140, 200).- noise_sd
Residual SD on the log scale. Default
0.2.- biomarkers
Length-2 character biomarker labels. Default
c("HlyE_IgG", "HlyE_IgA").- seed
Optional RNG seed.
Value
A list with data (the long case-data data.frame) and truth
(the sim_params_2a() output, including rho).