死亡人數
Cynthia 的教授現在要她探索生命表中的死亡人數。年齡為 \(x\) 的死亡人數標記為 $d_x$。你能把不同年齡 \(x\) 的死亡人數 \(d_x\) 視覺化嗎?
此外,Cynthia 得知,\(d_x\) 是在一組 \(\ell_x\) 名倖存者中,預期會在年齡 \(x\) 去世的人數。你會為每個年齡 \(x\) 的死亡人數產生二項式樣本,並將模擬結果與登記的 \(d_x\) 比較。
物件 life_table 已預先載入到你的 R 工作空間,另外也已提取出欄位 age、qx、lx 和 dx。
本練習屬於課程
以 R 估值人壽保險商品
練習說明
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the number of deaths dx by age
plot(___, ___,
type = "h",
pch = 20,
xlab = "Age x",
ylab = expression("d"[x]),
main = "Number of deaths (Belgium, females, 1999)")
# Simulate the number of deaths using a binomial distribution
sims <- ___(n = ___, size = ___, prob = ___)
# Plot the simulated number of deaths on top of the previous graph
points(___, ___,
pch = 4,
col = "red")