Learn R Programming

greyzoneSurv (version 1.0)

genSurvData: Simulate Survival Outcome Given Marker Values

Description

This function simulates survival outcome with a fixed censoring rate based on a Weibull distribution given input values such as study recruitment period, patient marker values, their true risk groupings (1=high risk and 0=low risk), and true regression coefficients.

Usage

genSurvData(n, recruitment.yrs=2, baseline.hazard=365.25*5, shape=1, censoring.rate=0, beta.continuous, beta.binary=0, x, xhigh, ran.seed)

Arguments

n
Sample size
recruitment.yrs
Patient recruitment period in years (default=2)
baseline.hazard
Baseline hazard, which is the mean survival time (in days) when covariates=0 (default=365.25*5 days)
shape
The shape parameter for the Weibull distribution (it is exponential when shape=1)
censoring.rate
Censoring rate
beta.continuous
A true regression coefficient that links the continuous marker values to the survival outcome
beta.binary
A true regression coefficient that links the high risk group to the survival outcome
x
A nx1 vector for the marker values
xhigh
A nx1 vector of 1s and 0s indicating patient true risk identities (1=high risk and 0=low risk)
ran.seed
Seed number for random number generation

Value

It returns a list with two components: the simulated survival data in days and the final censoring rate (which should be the same as the input censoring rate).

Details

The function can be used to generate survival data if you do not have any to try the grey-zone model.

See Also

em.func, cov.func, greyzone.func

Examples

Run this code
## Generate package data called "mydata"
## Simulate high/low risk groupings, continuous marker values for each group, and survival data 
## so that the higher maker values correspond to shorter survival. 
n=300
censoring.rate=0.3
rate.lrisk=0.7   #rate of low risk
n.lrisk=n*rate.lrisk
n.hrisk=n-n.lrisk
mu=3  
beta.continuous=0.5
beta.binary=0.5
ran.seed=1000
set.seed(ran.seed)
x0=rnorm(n.lrisk, 0, 1)   #low risk patients have marker values distributed as Normal(0,1)
set.seed(ran.seed)
x1=rnorm(n.hrisk, mu, 1)   #high risk patients have maker values distributed as Normal(mu,1)
score=c(x0, x1)
score.high=c(rep(0, n.lrisk), rep(1, n.hrisk))
mydata=genSurvData(n=n, censoring.rate=censoring.rate,
                beta.continuous=beta.continuous, beta.binary=beta.binary, 
                x=score, xhigh=score.high, ran.seed=ran.seed)$data
dim(mydata)
head(mydata)

Run the code above in your browser using DataLab