ref_simulate
Usage
ref_simulate( n = 400, kind = c("gaussian", "shash", "longitudinal"), sites = 4, site_shift = 0, site_log_scale = 0, scale = c("constant", "age"), skew = 0.6, tail = 0.85, visits = 3, tau_b = sqrt(0.5), tau_g = sqrt(0.35), sigma_e = sqrt(0.15), ell = 5, lag = NULL, seed = NULL)Synthetic data with known generative structure for examples and law
tests. Every kind returns age, sex, site, an outcome y, and
three correlated Gaussian markers marker_01..marker_03. The true
generative parameters are stored in attr(x, "truth").
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
n |
Number of rows (for "longitudinal", approximate). |
kind |
Generator name. |
sites |
Number of sites. |
site_shift |
Location shift per site in outcome units, recycled to sites. |
site_log_scale |
Log-scale shift per site, recycled to sites. |
scale |
"constant" or "age"-dependent outcome scale. |
skew, tail |
SHASH skew and tail ("shash" only). |
visits |
Mean visits per subject ("longitudinal" only). |
tau_b, tau_g, sigma_e |
Standard deviations of the stable, dynamic, and measurement components ( "longitudinal" only). They arerescaled to sum to unit variance. |
ell |
Matern-3/2 length-scale in time units ("longitudinal"only). |
lag |
Optional fixed lag ("longitudinal" only): every subjectthen has exactly two visits this far apart, the design under which the Matern length-scale is not identified. |
seed |
Optional seed; the global RNG state is restored afterwards. |
Details
Section titled “Details”"gaussian":yis Gaussian with location $\mu(age, sex)$ and either a constant or an age-dependent scale."shash":yis sinh-arcsinh with the same location and scale and constant skew and tail."longitudinal": subjects have 2 tovisits + 1visits with irregular lags (or exactly two visits a fixedlagapart whenlagis given). The normal score ofyfollows a stable subject component plus a Matern-3/2 process in time plus measurement noise, $z_i(t) = \tau_b b_i + \tau_g g_i(t) + \sigma_e e_{it}$, with $\tau_b^2 + \tau_g^2 + \sigma_e^2 = 1$ so that marginal scores are standard normal. Addsparticipant_idandvisitcolumns.
A data frame with a truth attribute listing the generative
parameters. For "longitudinal", truth$correlation(lag) gives the
implied correlation of normal scores at a given lag.
Examples
Section titled “Examples”ref <- ref_simulate(200, seed = 1)attr(ref, "truth")$sigmafunction(age, scale) { if (identical(scale, "age")) 1.2 + 0.02 * pmax(age - 40, 0) else rep(1.3, length(age))}<bytecode: 0x56419d082228><environment: namespace:referent>long <- ref_simulate(300, kind = "longitudinal", seed = 2)attr(long, "truth")$correlation(2)[1] 0.7963404