Exercise

Temporary vs lifelong

Finally, can you assist Cynthia in writing a function for a temporary life annuity due in which the payments are restricted in time? The first payment takes place at time \(0\) and the last at time \(n-1\).

Both life_table and the R function life_annuity_due are still available in your workspace.

Instructions

100 XP
  • Define the function temporary_life_annuity_due() starting from the life_annuity_due() code such that the EPV is computed for a temporary life annuity due. The function now has an extra argument n which indicates the number of payments. Both kpx and discount_factors should hence have a total length of n.
  • Use temporary_life_annuity_due() to calculate the EPV of a 10-year life annuity due for (20) at rate 2% using the 1999 period life table for females.