View source: R/simulate_from_glm_dgm.R
| simulate_from_glm_dgm | R Documentation |
Generates a simulated clinical trial dataset by sampling from the
super-population in a "glm_dgm" object. Assigns treatment
and generates outcomes from the individual-level potential outcomes
stored in the DGM.
simulate_from_glm_dgm(
dgm,
n = NULL,
rand_ratio = 1,
seed = NULL,
draw_treatment = TRUE,
replace = TRUE,
baseline = c("resample", "fixed")
)
dgm |
An object of class |
n |
Integer. Sample size. If |
rand_ratio |
Numeric. Treatment:control randomisation ratio.
Default |
seed |
Integer. Random seed. Default |
draw_treatment |
Logical. If |
replace |
Logical sampling scheme for drawing the |
baseline |
\"resample\" (default; draw the trial panel from the super-population) or \"fixed\" (use dgm$df_source – the observed panel, every patient exactly once, observed order; requires a DGM built by a version that stores df_source; n must be NULL or nrow(df_source)). |
A data frame with columns:
idInteger subject identifier.
y_simSimulated outcome.
treat_simTreatment indicator (0/1).
flag_harmTrue subgroup membership indicator.
Plus all covariate columns from the super-population.
For binary outcomes, y_sim is a 0/1 Bernoulli draw from
the potential outcome probabilities (p0 or p1).
There is no event_sim column – for ForestSearch, set
event.name = "y_sim".
generate_glm_dgm,
run_simulation_analysis
## Not run:
dgm <- generate_glm_dgm(...)
df <- simulate_from_glm_dgm(dgm, n = 500, seed = 42)
table(df$y_sim, df$treat_sim)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.