simsurv: Simulate Survival Data

Description Usage Arguments Details Value See Also Examples

Description

Generate a sample of n survival times from a distribution specified by type, and parameters specified p.

Usage

1
simsurv(n, type = "g", p = c(2.433083e-05, 0.005, 3e-11, 0.0015))

Arguments

n

Number of observations to simulate.

type

One of "e" (Exponential), "w" (Weibull), "g" (Gompertz), "gm" (Gompertz-Makeham), "l" (Logistic), "lm" (Logistic-Makeham)

p

A numeric vector of length 4 specifying the model parameters. Some models ignore some parameters: "e" only uses the first parameter, "w" and "g" use the first two, "gm" uses the first three, "l" uses the first, second, and fourth, and "lm" uses all four. The model parameters are in the same order as they would appear in survwrapper output.

Details

If a parameter that is used by a model is set to zero, the type argument is changed to that of a simpler model that does not use that parameter. "l" and "lm" use the Survomatic functions rlgst and rlogmake, respectively. "g" and "gm" use the eha functions rgompertz and rmakeham, respectively. "e" and "w" use the stats functions rexp and rweibull functions, respectively. Validation is not enforced, but values outside [0,1] will probably give nonsensical results or errors.

Value

A numeric vector of length n.

See Also

rlgst, rlogmake, rgompertz, rmakeham, rexp, rweibull

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## The following two are from the same Gompertz distribution because the
## zero parameter values cause the type to get changed from lm to g
s0 <- simsurv(1e4, type = "g", p=c(2e-5,5e-3,0,0))
s1 <- simsurv(1e4, type = "lm", p=c(2e-5,5e-3,0,0))
plot(survfit(Surv(s0)~1),col='red',conf.int=FALSE)
lines(survfit(Surv(s1)~1),col='blue',lty=2)
## ...but this one really is from a Logistic-Makeham distribution:
s2 <- simsurv(1e4, type = "lm", p=c(2e-5,5e-3,1e-4,0.4))
lines(survfit(Surv(s2)~1),col='green')
legend('topright',bty='n',col=c('red','blue','green'),lty=c(1,2,1),legend=c('s0','s1','s2'))

bokov/powertrip documentation built on May 12, 2019, 11:33 p.m.