sim_SCR_data: Data Simulation Function

View source: R/sim_SCR_data.R

sim_SCR_dataR Documentation

Data Simulation Function

Description

Data Simulation Function

Usage

sim_SCR_data(
  data_size,
  ncol_gene_mat,
  feat_m,
  feat_d,
  mu_cen,
  cov,
  lam_m = 1/15,
  lam_d = 1/20,
  norm_vcov = c(1, 0.5, 0.5, 1)
)

Arguments

data_size

an integer giving the simulated sample size N

ncol_gene_mat

an integer giving the simulated number of genomic covariates P

feat_m

a function that transforms the genomic features into the signal for the metastasis process. This function should a matrix of dimensions N X P as its only argument.

feat_d

a function that transforms the genomic features into the signal for the death process. This function should a matrix of dimensions N X P as its only argument.

mu_cen

mean of the exponential censoring process

cov

the correlation between the genomic covariates

lam_m

baseline hazard constant for metastasis process. Default is 1/15.

lam_d

baseline hazard constant for death process. Default is 1/20.

norm_vcov

vector of length 4 of correlation between errors between the two processes on the normal scale before being complementary-log-log-transformed. Default is c(1,.5,.5,1).

Value

a data.frame with columns:

  • XR: time to recurrence / death / censoring

  • XD: time to death / censoring

  • DeltaR: Indicator of censoring (0), recurrence (1), or death (2) for this earliest time XR

  • DeltaD: Indicator of censoring (0) or death (1)

  • XPFS: time to recurrence / death / censoring (=XR)

  • DeltaPFS: Indicator of censoring (0) or recurrence or death, whichever came first (1)

  • Z_1,...,Z_P: genomic variables

Examples

feat_m_fun <- function(X){
 sin(X[,1]+X[,2]^2)-1
}
feat_d_fun <-  function(X){
 (X[,4]-X[,5])^2/8
}
mydata <- sim_SCR_data(data_size = 400, ncol_gene_mat = 20, feat_m = feat_m_fun,
                      feat_d = feat_d_fun, mu_cen = 30, cov=0.5)
head(mydata)
## how many experience both events
mean(mydata[,"DeltaR"]==1 & mydata[,"DeltaD"]==1)
## how many only recur
mean(mydata[,"DeltaR"]==1 & mydata[,"DeltaD"]==0)
## how many only die
mean(mydata[,"DeltaR"]==2 & mydata[,"DeltaD"]==1)
## how many are censored
mean(mydata[,"DeltaR"]==0 & mydata[,"DeltaD"]==0)



kernscr documentation built on April 17, 2023, 5:09 p.m.