rsurv: Simulation of survival data following a PCH model

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 (PCH) 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 PCH model with hazard equal to alpha between cuts.

See Also

mleIC, pchcumhaz.

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=stats::runif(n,min=70,max=90)
time=pmin(time,censoring) #observed times
delta=time<censoring #gives 62% of observed data on average

obouaziz/FastPseudo documentation built on Dec. 22, 2021, 4:12 a.m.