终身寿险
为了帮助正在准备精算考试的朋友 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、利率i和life_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()