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.

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

`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 |

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

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).

`em.func`

, `cov.func`

, `greyzone.func`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
## 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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.