randcensor: Generate Independent Random Censored Lifetime

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

Implements a function to draw censored random samples, with a desired censoring rate, when the event times are any continuous lifetime distribution supported by R. The one-parameter Lindley, uniform and exponential are the distributions that can be used as the censoring distributions.

Usage

1
2
randcensor(n, pcens = 0.1, timedistr = "lindley", censordistr = "lindley",
  ...)

Arguments

n

number o generated observations.

pcens

desired censoring rate.

timedistr

a character string 'name' naming a lifetime distribution for which the corresponding density function dname, the corresponding distribution function pname and the corresponding random function qname are defined. The one-parameter Lindley distribution is taken as default.

censordistr

a character string 'name' naming the censoring distribution. 'lindley' (default) for the one-parameter Lindley distribution, 'exp' for the exponential distribution and 'unif' for the uniform distribution.

...

parameters that define the event time distribution (timedistr). Must be provided in the same way as it is in built in R functions.

Value

randcensor returns a list with the timedistr distribution, the censordistr distribution, the calculated parameter of the censordist distribution and n observations which is either the lifetime (delta = 1) or a censored lifetime (delta = 0).

Invalid arguments will return an error message.

Note

Finds the parameter of the censoring distribution using integrate and uniroot.

Author(s)

Josmar Mazucheli jmazucheli@gmail.com

References

Klein, J. P., Moeschberger, M. L., (2003). Survival Analysis: Techniques for Censored and Truncated Data, 2nd Edition. Springer-Verlag, New York.

Lawless, J. F., (2003). Statistical models and methods for lifetime data, 2nd Edition. Wiley Series in Probability and Statistics. John Wiley & Sons, Hoboken, NJ.

Meeker, W. Q., Escobar, L. A., (1998). Statistical Methods for Reliability Data. John Wiley and Sons, New York.

See Also

Distributions, fitdistcens, integrate, Lindley, uniroot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
x <- randcensor(n = 100, pcens = 0.2, timedistr = 'lindley', censordistr = 'lindley',
 theta = 1.5)
table(x$data['delta']) / 100

x <- randcensor(n = 100, pcens = 0.2, timedistr = 'wlindley', censordistr = 'lindley',
 theta = 1.5, alpha = 0.5)
table(x$data['delta']) / 100

x <- randcensor(n = 100, pcens = 0.2, timedistr = 'weibull', censordistr = 'lindley',
 shape = 0.5, scale = 1.5)
table(x$data['delta']) / 100

x <- randcensor(n = 100, pcens = 0.2, timedistr = 'lnorm', censordistr = 'unif',
 meanlog = 1, sdlog = 1)
table(x$data['delta']) / 100


Search within the LindleyR package
Search all R packages, documentation and source code

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

Please suggest features or report bugs with the GitHub issue tracker.

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