rsurv: Simulation of survival data

Description Usage Arguments Value See Also Examples

View source: R/rsurv.R

Description

Given a set of cuts and hazard values, generates a survival data sample from a piecewise-constant hazard model

Usage

1
rsurv(n, cuts = NULL, alpha)

Arguments

n

the sample size.

cuts

the sequence of cuts. Default to NULL which corresponds to the exponential model.

alpha

the value of the hazard function between each cut. Should be of length equal to length(cuts)+1.

Value

A time vector of size n drawn from a piecewise constant hazard model with hazard equal to alpha between cuts.

See Also

Other pchsurv functions: arpchsurv, bootpchsurv, mlepchsurv, pchsurv

Examples

1
2
3
4
5
6
7
n=400
cuts=c(20,40,50,70)
alpha=c(0,0.05,0.1,0.2,0.4)/10
time=rsurv(n,cuts,alpha) #generate true data from the pch model
censoring=runif(n,min=70,max=90)
time=pmin(time,censoring) #observed times
delta=time<censoring #gives 62% of observed data on average

obouaziz/pchsurv documentation built on Sept. 7, 2020, 11:03 a.m.