有期生命年金と終身生命年金
最後に、Cynthia が有期生命年金(期始払い)の関数を作成するのを手伝いましょう。この年金では、支払いが期間内に限定されます。最初の支払いは時点 $0$、最後の支払いは時点 \(n-1\) で行われます。
life_table と R 関数 life_annuity_due は、引き続きワークスペースで使用できます。
この演習はコースの一部です
R による生命保険商品の評価
演習の手順
life_annuity_due()のコードをもとに、有期生命年金(期始払い)の EPV を計算する関数temporary_life_annuity_due()を定義しましょう。この関数には、支払い回数を示す引数nが追加されています。kpxとdiscount_factorsの長さはそれぞれnになるようにしてください。temporary_life_annuity_due()を使って、1999 年の女性生命表を用い、利率 2% で (20) に対する 10 年有期生命年金(期始払い)の EPV を計算しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# EPV of a whole life annuity due for (20) at interest rate 2% using life_table
life_annuity_due(20, 0.02, life_table)
# Function to compute the EPV of a temporary life annuity due for a given age, period of n years, interest rate i and life table
temporary_life_annuity_due <- function(age, n, i, life_table) {
px <- 1 - life_table$qx
kpx <- c(1, cumprod(px[(___):(___)]))
discount_factors <- (1 + i) ^ - (0:(___))
___
}
# EPV of a temporary life annuity due for (20) over 10 years at interest rate 2% using life_table
temporary_life_annuity_due(___, ___, ___, ___)