開始使用免費開始

終身壽險

為了幫助正在準備精算考試的朋友 Ethan,Cynthia 想替他撰寫一些 R 程式碼,用來在給定固定利率 \(i\) 的情況下,計算被保險人為 \((x)\) 的(終身)壽險之 EPV。由於死亡給付固定為 1 EUR,你不需要在計算中另外把給付額納入。

1999 年比利時女性生命表已預先載入為 life_table。已預先定義 plot_by_age()plot_by_interest_rate() 兩個函式,用來示範 EPV 如何隨保單持有人年齡 \(x\) 與利率變化。你可以在 R 主控台輸入函式名稱來檢視其內容。

本練習屬於課程

以 R 估值人壽保險商品

檢視課程

練習說明

  • 完成函式 whole_life_insurance(),依給定的 age、利率 ilife_table,計算終身壽險的 EPV。
  • 執行預先定義的程式碼,繪製在不同年齡範圍(利率 3%)與不同利率範圍(年齡 20 歲)下的終身壽險 EPV。請解讀產生的圖形。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Function to compute the EPV of a whole life insurance
whole_life_insurance <- function(age, i, life_table) {
  qx <- life_table$qx
  px <- ___
  kpx <- c(1, cumprod(px[(___):(length(px) - 1)]))
  kqx <- kpx * qx[(___):length(qx)]
  discount_factors <- (___) ^ - (1:length(kqx))
  sum(discount_factors * kqx)
}

# Plot the EPV of a whole life insurance for a range of ages at interest rate 3% using life_table
plot_by_age()

# Plot the EPV of a whole life insurance for (20) for a range of interest rates using life_table
plot_by_interest_rate()
編輯並執行程式碼