survdata: Simulate Exponential Survival Data

View source: R/survdata.R

survdataR Documentation

Simulate Exponential Survival Data

Description

Creates a data frame of survival data based on exponential distributions and Bernoulli censoring for a 2 arm trial.

Usage

survdata <- function(n, lambda1, lambda2, censor = 0, piecewise = FALSE, diverge_time = NULL, erate = NULL, eperiod = NULL, end_study = NULL)

Arguments

n0

The sample size in the control arm.

n1

The sample size in the treatment arm.

lambda1

The rate of the exponential distribution in the first arm.

lambda2

The rate of the exponential distribution in the second arm if piecewise = FALSE, or the rates of the piecewise exponential distribution of the second arm before diverge_time if piecewise = TRUE.

censor

The probability a sample time will be deemed a censored observation. censor needs to be between 0 and 1.

piecewise

Determines if the second trial arm follows a piecewise exponential distribution.

diverge_time

Determines the point in time in which the piecewise exponential curve changes rates.

erate

Vector of enrollment rates following piecewise exponential distribution.

eperiod

Vector of length +1 to erate which determines the times at which the enrollment period begins (0), when the erates change, and when the enrollment period ends.

end_study

Creates a point at which all the simulated times are censored after.

Value

dataframe with observed times, calendar times, enrollment times, censoring indicators (0 for censoring, 1 for events), and trial arm.

Author(s)

Mitchell Paukner


pauknemj/survWM2 documentation built on March 21, 2023, 5:29 a.m.