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 |
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:
|
b1 |
Vector. The regression coefficient for the covariates, affecting the hazard function. We suggest that the maximum of |
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:
-
data
- A list of data frames, each containing a generated dataset. -
censoringrates
- A numeric vector representing the censoring rate for each dataset. -
mean(censoringrates)
- The mean censoring rate across all datasets.
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))