定期生命保険
Ethan は、以下の図のように保障期間が限定された場合に、生命保険の EPV がどのように変化するかを調べたいと思っています。
彼はまず、1999年のベルギー女性の死亡表 life_table(事前読み込み済み)を使用し、利率 \(i = 2\%\) で20歳の終身生命保険の EPV を計算します。
前の演習で作成した whole_life_insurance() 関数をもとに、Cynthia が定期生命保険の関数を作成するのを手伝いましょう。
この演習はコースの一部です
R による生命保険商品の評価
演習の手順
- 定期生命保険の EPV を計算する関数
temporary_life_insurance()を定義してください。この関数は、共通の引数age、i、life_tableに加え、保障期間の年数を表す引数nを受け取ります。 - 新しく定義した
temporary_life_insurance()関数を使い、利率2%の条件で (20) の生命保険の EPV が保障期間を45年に限定した場合にどのように変化するかを計算しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# EPV of a whole life insurance for (20) at interest rate 2% using life_table
whole_life_insurance(20, 0.02, life_table)
# Function to compute the EPV of a temporary life insurance
temporary_life_insurance <- function(age, n, i, life_table) {
qx <- life_table$qx
px <- 1 - qx
kpx <- c(1, cumprod(px[(___):(___)]))
kqx <- kpx * qx[(___):(___)]
discount_factors <- (1 + i) ^ - (1:length(kqx))
___(___ * ___)
}
# EPV of a temporary life insurance for (20) over a period of 45 years at interest rate 2% using life_table
temporary_life_insurance(___, ___, ___, ___)