| Title: | Simulate Covariates from Summary Statistics |
|---|---|
| Description: | Simulate covariates from summary statistics. |
| Authors: | Nathan Green [aut, cre] |
| Maintainer: | Nathan Green <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-15 05:35:14 UTC |
| Source: | https://github.com/n8thangreen/simcovariates |
These functions serve as constructors to create objects that define the
properties of different covariate types (continuous, binary, categorical).
These definition objects are then used within the gen_data function's
covariate_defns argument to specify the characteristics of the simulated covariates.
continuous(mean, sd) binary(prob) categorical(levels, probs = NULL)continuous(mean, sd) binary(prob) categorical(levels, probs = NULL)
Constructors for Covariate Definitions
Generate simulated datasets of IPD covariates and outcome for a trial
gen_data( N, b_0, b_trt, covariate_defns, b_prognostic = NULL, b_effect_modifier = NULL, cor_matrix = NULL, trt_assignment = list(prob_trt1 = 0.5), error_params = list(sd = 1), family = gaussian(link = "identity") )gen_data( N, b_0, b_trt, covariate_defns, b_prognostic = NULL, b_effect_modifier = NULL, cor_matrix = NULL, trt_assignment = list(prob_trt1 = 0.5), error_params = list(sd = 1), family = gaussian(link = "identity") )
cor_matrix |
Applies to all latent covariates |
family |
Data frame of simulated IPD
Generate simulated datasets of IPD covariates and outcome for a trial
gen_data_orig( N, b_trt, meanX = NULL, sdX = NULL, b_X = NULL, meanX_EM = NULL, sdX_EM = NULL, b_EM = NULL, prob_X_bin = NULL, b_X_bin = NULL, prob_EM_bin = NULL, b_EM_bin = NULL, b_0, corX, allocation, sigma = 1, family = binomial("logit") )gen_data_orig( N, b_trt, meanX = NULL, sdX = NULL, b_X = NULL, meanX_EM = NULL, sdX_EM = NULL, b_EM = NULL, prob_X_bin = NULL, b_X_bin = NULL, prob_EM_bin = NULL, b_EM_bin = NULL, b_0, corX, allocation, sigma = 1, family = binomial("logit") )
N |
Total number of patients |
b_trt |
|
meanX |
Mean vector of each normally-distributed covariate |
sdX |
Standard deviation vector of each covariate |
b_X |
|
meanX_EM |
Mean vector of each normally-distributed EM covariate |
sdX_EM |
Standard deviation vector of each EM covariate |
b_EM |
|
prob_X_bin |
Probability for each binary distributed covariate |
b_X_bin |
|
prob_EM_bin |
Probability for each binary distributed EM covariate |
b_EM_bin |
|
b_0 |
Intercept coefficient |
corX |
Covariate correlation coefficient of |
allocation |
Allocation to active treatment as proportion of total; 0 to 1 |
sigma |
Standard deviation of outcome; optional |
family |
Family object |
Data frame of X, trt and y
## Not run: x <- gen_data( N = 100, b_trt = log(0.17), b_X = -log(0.5), b_EM = -log(0.67), b_0 = -0.62, meanX = c(0.6, 0.6), sdX = c(0.4, 0.4), meanX_EM = c(0.6, 0.6), sdX_EM = c(0.4, 0.4), corX = 0.2, allocation = 2/3) head(x) ## End(Not run)## Not run: x <- gen_data( N = 100, b_trt = log(0.17), b_X = -log(0.5), b_EM = -log(0.67), b_0 = -0.62, meanX = c(0.6, 0.6), sdX = c(0.4, 0.4), meanX_EM = c(0.6, 0.6), sdX_EM = c(0.4, 0.4), corX = 0.2, allocation = 2/3) head(x) ## End(Not run)