Package 'simcovariates'

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

Help Index


Functions to define individual covariate properties

Description

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.

Usage

continuous(mean, sd)

binary(prob)

categorical(levels, probs = NULL)

Details

Constructors for Covariate Definitions


Generate simulated datasets of IPD covariates and outcome for a trial

Description

Generate simulated datasets of IPD covariates and outcome for a trial

Usage

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")
)

Arguments

cor_matrix

Applies to all latent covariates

family

Value

Data frame of simulated IPD


Generate simulated datasets of IPD covariates and outcome for a trial

Description

Generate simulated datasets of IPD covariates and outcome for a trial

Usage

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")
)

Arguments

N

Total number of patients

b_trt

b coefficient for active treatment vs. common comparator

meanX

Mean vector of each normally-distributed covariate X

sdX

Standard deviation vector of each covariate X

b_X

b coefficients for each prognostic variable X

meanX_EM

Mean vector of each normally-distributed EM covariate X

sdX_EM

Standard deviation vector of each EM covariate X

b_EM

b coefficients effect modifiers

prob_X_bin

Probability for each binary distributed covariate X

b_X_bin

b coefficients for each prognostic variable X

prob_EM_bin

Probability for each binary distributed EM covariate X

b_EM_bin

b coefficients effect modifiers

b_0

Intercept coefficient

corX

Covariate correlation coefficient of X

allocation

Allocation to active treatment as proportion of total; 0 to 1

sigma

Standard deviation of outcome; optional

family

Family object

Value

Data frame of X, trt and y

Examples

## 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)