Skip to contents

This function generates random number vectors of correlated survival and ordinal outcomes. Gaussian or Clayton copula is used to specify the correlation structure. Marginal distributions are based on a exponential distribution. The order outcome is generated by discretizing one of the correlated random numbers based on the quantile.

Usage

generate_rv(
  target_tau,
  num_samples,
  censoring_rate,
  copula_type = c("Gaussian", "Clayton"),
  x_levels = 5,
  hr = 1
)

Arguments

target_tau

the target value of the Kendall's \(\tau\)

num_samples

the number of simulation samples

censoring_rate

the censoring rate

copula_type

copula type (default = "Gaussian")

  • Gaussian: Gaussian copula

  • Clayton: Clayton copula

x_levels

the number of category for the ordinal outcome (default = 5)

hr

the hazard ratio for survival time (default = 1.0)

Value

  • y: the survival time or censoring time outcome vector

  • event: the event indicator outcome vector

  • x: the ordinal (or continuous) outcome vector

  • t: the true survival time vector (for simulation)

  • c: the true censoring time vector (for simulation)

  • x0: x before discretization (for simulation)

Examples

library(surrosurvo)
set.seed(1234)
data <- generate_rv(0.7, 500, 0.3)
surrosurvo(data$y, data$event, data$x)
#>   method       tau         se       lcl       ucl
#> 1 taumo1 0.6556501 0.02496919 0.6067114 0.7045888
#> 2 taumo2 0.6563674 0.01726476 0.6225291 0.6902057
#> 3   tauo 0.5042325 0.01834774 0.4682716 0.5401934
#> 4 tauso1 0.7356190 0.02801531 0.6807100 0.7905280
#> 5 tauso2 0.7350181 0.02611867 0.6838264 0.7862097

# 5-level ordinal variable with Clayton copula
data <- generate_rv(0.7, 500, 0.1, copula_type = "Clayton", x_levels = 5)
surrosurvo(data$y, data$event, data$x)
#>   method       tau         se       lcl       ucl
#> 1 taumo1 0.6375091 0.01774413 0.6027312 0.6722869
#> 2 taumo2 0.6376534 0.01599582 0.6063021 0.6690046
#> 3   tauo 0.5999920 0.01633828 0.5679696 0.6320144
#> 4 tauso1 0.7152653 0.01990908 0.6762443 0.7542864
#> 5 tauso2 0.7214756 0.01831078 0.6855871 0.7573641