Learn R Programming

BuyseTest (version 2.1.3)

Simulation function: Simulation of data for the BuyseTest

Description

Simulate binary, continuous or time to event data, possibly with strata. Outcomes are simulated independently of each other and independently of the strata variable.

Usage

simBuyseTest(
  n.T,
  n.C = NULL,
  argsBin = list(),
  argsCont = list(),
  argsTTE = list(),
  n.strata = NULL,
  names.strata = NULL,
  format = "data.table",
  latent = FALSE
)

Arguments

n.T

[integer, >0] number of patients in the treatment arm

n.C

[integer, >0] number of patients in the control arm

argsBin

[list] arguments to be passed to simBuyseTest_bin. They specify the distribution parameters of the binary endpoints.

argsCont

[list] arguments to be passed to simBuyseTest_continuous. They specify the distribution parameters of the continuous endpoints.

argsTTE

[list] arguments to be passed to simBuyseTest_TTE. They specify the distribution parameters of the time to event endpoints.

n.strata

[integer, >0] number of strata. NULL indicates no strata.

names.strata

[character vector] name of the strata variables. Must have same length as n.strata.

format

[character] the format of the output. Can be "data.table", "data.frame" or "matrix".

latent

[logical] If TRUE also export the latent variables (e.g. censoring times or event times).

Details

This function is built upon the lvm and sim functions from the lava package.

Arguments in the list argsBin:

  • p.T probability of event of each endpoint (binary endpoint, treatment group).

  • p.C same as p.T but for the control group.

  • name names of the binary variables.

Arguments in the list argsCont:

  • mu.T expected value of each endpoint (continuous endpoint, treatment group).

  • mu.C same as mu.C but for the control group.

  • sigma.T standard deviation of the values of each endpoint (continuous endpoint, treatment group).

  • sigma.C same as sigma.T but for the control group.

  • name names of the continuous variables.

Arguments in the list argsTTE:

  • CR should competing risks be simulated?

  • rates.T hazard corresponding to each endpoint (time to event endpoint, treatment group).

  • rates.C same as rates.T but for the control group.

  • rates.CR same as rates.T but for the competing event (same in both groups).

  • rates.Censoring.T Censoring same as rates.T but for the censoring.

  • rates.Censoring.C Censoring same as rates.C but for the censoring.

  • name names of the time to event variables.

  • nameCensoring names of the event type indicators.

Examples

Run this code
# NOT RUN {
library(data.table)

n <- 1e2

#### default option ####
simBuyseTest(n)

## with a strata variable having 5 levels
simBuyseTest(n, n.strata = 5)
## with a strata variable named grade
simBuyseTest(n, n.strata = 5, names.strata = "grade")
## several strata variables
simBuyseTest(1e3, n.strata = c(2,4), names.strata = c("Gender","AgeCategory"))

#### only binary endpoints ####
args <- list(p.T = c(3:5/10))
simBuyseTest(n, argsBin = args, argsCont = NULL, argsTTE = NULL)

#### only continuous endpoints ####
args <- list(mu.T = c(3:5/10), sigma.T = rep(1,3))
simBuyseTest(n, argsBin = NULL, argsCont = args, argsTTE = NULL)

#### only TTE endpoints ####
args <- list(rates.T = c(3:5/10), rates.Censoring.T = rep(1,3))
simBuyseTest(n, argsBin = NULL, argsCont = NULL, argsTTE = args)
        

# }

Run the code above in your browser using DataLab