延期寿险
现在,Cynthia 要求 Ethan 亲自修改代码,计算给定恒定利率 \(i\) 下 \((x)\) 的延期寿险的 EPV。下图展示了延期期为 \(u\) 年时的时间轴。
若被保险人在前 \(u\) 年内身故,则不支付身故给付。从时间点 \(u\) 起,在被保险人身故所在年的年末支付 1 欧元的身故给付。
已为您提供 whole_life_insurance() 函数,以及在利率 $i = 2\%$、使用 1999 年女性 life_table 情况下,20 岁终身寿险的 EPV 作为起点。
本练习是课程的一部分
用 R 评估人寿保险产品
练习说明
- 编写
deferred_life_insurance()函数,用于在给定age、延期期u、利率i和life table的条件下,计算延期寿险的 EPV。 - 调用
deferred_life_insurance()函数,计算延期期为 45 年的寿险 EPV。使用年龄 20、利率 2% 以及预加载的 1999 年女性life_table。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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 deferred whole life insurance
deferred_life_insurance <- function(age, u, i, life_table) {
qx <- life_table$qx; px <- 1 - qx
kpx <- c(1, cumprod(px[(age + 1):(length(px) - 1)]))
kqx <- kpx * qx[(age + 1):length(qx)]
discount_factors <- (1 + i) ^ - (1:length(kqx))
benefits <- c(rep(___, ___), rep(___, length(kpx) - u))
sum(___ * discount_factors * kqx)
}
# EPV of a deferred life insurance for (20) deferred over 45 years at interest rate 2% using life_table
deferred_life_insurance(___, ___, ___, ___)