gendat {marcox}R Documentation

Generate Simulated Datasets for Cox Proportional Hazards Model

Description

This function generates multiple datasets for survival analysis based on a Cox proportional hazards model. The baseline hazard function follows either a Weibull or an exponential distribution, depending on the values of lambda. The function ensures that the maximum observed time in both the control and treatment groups is checked for censoring. If the maximum time is not censored, it is forced to be censored to maintain the desired censoring rate.

Usage

gendat(
  type = "bin",
  dimension = 10,
  K = 30,
  n = 2,
  lambda = c(1, 2),
  b1 = c(log(2), -0.1),
  theta = 8,
  censrate = 0.3
)

Arguments

type

Character. If type = 'bin', the covariates are generated as binary variables; if type = 'cont' continuous covariates are generated.

dimension

Integer. The number of datasets to be generated.

K

Integer. The number of clusters (groups) within each dataset.

n

Integer. The number of samples within each cluster.

lambda

Numeric vector. A two-element vector specifying the parameters for the baseline distribution:

  • If lambda = c(a, b), where a > 1, the baseline follows a Weibull distribution.

  • If lambda = c(1, b), the baseline follows an exponential distribution.

b1

Vector. The regression coefficient for the covariates, affecting the hazard function. We suggest that the maximum of b1 should be lower than 2.

theta

Numeric. A parameter controlling the dependency structure between survival times within clusters. Higher values indicate stronger within-cluster correlation.

censrate

Numeric. The target censoring rate for the dataset.

Value

A list containing:

Examples

# Generate binary covariate datasets with 1 datasets, 10 clusters, and 6 samples per cluster
print(gendat(type = 'bin', dimension = 1, K = 6, n = 10, lambda = c(1, 2),
      b1 = c(log(2),-log(2)), theta = 8, censrate = 0.5))

[Package marcox version 1.0.0 Index]