Learn R Programming

survMisc (version 0.4.2)

genDfSurv: Generate data frame for survival analysis

Description

Generates a data frame with a binary outcome (events), times and optional predictor variables. An optional coxph model is fitted to the data. Model is fitted with survival::coxph()

Usage

genDfSurv(f = 0, b = 2, c = 1, n = 100, pb = 0.5, nf = 3,
    rc = 0.8, pe = 0.5, t0 = 1, tmax = 100,
    asFactor = FALSE, model = TRUE, timelim = 5)

Arguments

b
binomial predictors, the number of predictors which are binary, i.e. limited to 0 or 1
f
factors, the number of predictors which are factors
c
continuous predictors, the number of predictors which are continuous
n
number of observations in the data frame
nf
the no. of levels in a factor
pb
probability for binomnial predictors the probability of binomial predictors being =1. E.g. if pb=0.3, 30% will be 1s, 70% will be 0s
rc
ratio for continuous variables the ratio of levels of continuous variables to the total number of observations n e.g. if rc=0.8 and n=100, it will be in the range 1-80
pe
probability of event the probability of events (typically death/failure) occurring, i.e. are =1. E.g. if pe=0.5, 50% will be 1s, 50% will be 0s
t0
Lowest (starting) time
tmax
Highest (final) time
asFactor
if TRUE, predictors given as factors will be converted to factors in the data frame before the model is fit
timelim
function will timeout after timelim secs
model
If TRUE will return fitted model

Value

  • A list with the following values:
  • dfdata frame with predictors (labelled $x1,x2, ..., xn$) and outcome (y), with n rows (observations)
  • modelif model = TRUE model fit with survival::coxph()

Examples

Run this code
set.seed(1)
genDfSurv()
genDfSurv(b=0, c=2, n=100, pe=0.7)
genDfSurv(b=1, c=0, n=1000)
genDfSurv(f=1, nf=4, b=1, c=0, asFactor=TRUE)

Run the code above in your browser using DataLab