Learn R Programming

lifecontingencies (version 1.1.10)

rLife: Function to generate random future lifetimes

Description

This function returns random samples from the time until death (future lifetime) of a subject aged x. Either the continuous or the curtate time until death can be returned.

Usage

rLife(n, object, x = 0, k=1, type = "Tx")

Arguments

n
Number of variates to generate.
object
An object of class lifetable.
x
The attained age of subject x. Default value is 0.
k
Number of periods within the year when it is possible death to happen. Default value is 1.
type
Either "Tx" for continuous future lifetime or "Kx" for curtate future lifetime

Value

  • A numeric vector of n elements.

Warning

The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.

Details

Following relation holds for the future life time: $T_x=K_x+0.5$.

References

Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.

See Also

lifetable, exn

Examples

Run this code
##get 20000 random future lifetimes for the Soa life table at birth
data(soa08Act)
lifes=rLife(n=20000,object=soa08Act, x=0, type="Tx")
##check if the expected life at birth derived from the life table
##is statistically equal to the expected value of the sample
#
t.test(x=lifes, mu=exn(soa08Act, x=0, type="continuous"))

Run the code above in your browser using DataLab