#install.packages("lifecontingencies")
library(lifecontingencies)
## Package: lifecontingencies
## Authors: Giorgio Alfredo Spedicato [cre,aut], Reinhold Kainhofer [ctb], Kevin J.
## Owens [ctb], Christophe Dutang [ctb], Ernesto Schirmacher[ctb], Gian Paolo Clemente [ctb]
## Version: 1.3.2
## Date: 2017-12-09
## BugReport: http://github.com/spedygiorgio/lifecontingencies/issues
x: the age, from 0 to w uno o más columnas para diferentes causas de decrementos
valdezDf<-data.frame(
x=c(50:54),
lx=c(4832555,4821937,4810206,4797185,4782737),
hearth=c(5168, 5363, 5618, 5929, 6277),
accidents=c(1157, 1206, 1443, 1679,2152),
other=c(4293,5162,5960,6840,7631))
valdezDf
## x lx hearth accidents other
## 1 50 4832555 5168 1157 4293
## 2 51 4821937 5363 1206 5162
## 3 52 4810206 5618 1443 5960
## 4 53 4797185 5929 1679 6840
## 5 54 4782737 6277 2152 7631
Multiple Decrement Table (mdt)
getDecrements –> devuelve los decrementos (por medio de los nombres dentro de la tabla diferente de x y lx).
valdezMdt<-new("mdt",name="ValdezExample",table=valdezDf)
## Added fictional decrement below last x and completed x and lx until zero....
## Completed the table at top, all decrements on first cause
str(valdezMdt)
## Formal class 'mdt' [package "lifecontingencies"] with 2 slots
## ..@ name : chr "ValdezExample"
## ..@ table:'data.frame': 56 obs. of 5 variables:
## .. ..$ x : num [1:56] 0 1 2 3 4 5 6 7 8 9 ...
## .. ..$ lx : num [1:56] 7987614 7907738 7828661 7750374 7672870 ...
## .. ..$ hearth : num [1:56] 79876 79077 78287 77504 76729 ...
## .. ..$ accidents: num [1:56] 0 0 0 0 0 0 0 0 0 0 ...
## .. ..$ other : num [1:56] 0 0 0 0 0 0 0 0 0 0 ...
getDecrements(valdezMdt)
## [1] "hearth" "accidents" "other"
getOmega(valdezMdt)
## [1] 55
Resumen
summary(valdezMdt)
## This is Multiple Decrements Table: ValdezExample
## Omega age is: 55
## Stored decrements are: hearth accidents other
Exportando la tabla de mortalidad múltiple como data frame o una lista
valdezDf<-as(valdezMdt,"data.frame")
valdezMarkovChainList<-as(valdezMdt,"markovchainList")
Número de Decrementos
# Número de decrementos de hombres de 51 años
dxt(valdezMdt,x=51)
## [1] 11731
# Número de decrementos por causa= otra de hombres de 51 años
dxt(valdezMdt,x=51,decrement="other")
## [1] 5162
# Número de decrementos por causa= otra de hombres entre la edad de 51 a 53
dxt(valdezMdt,x=51,t=2, decrement="other")
## [1] 11122
Probabilidades
pxt(valdezMdt,x=50,t=3)
## [1] 0.9926809
Aplicación Actuarial c
qxt(valdezMdt,x=53,t=2,decrement=1)
## [1] 0.002544409
rmdt(n = 2,object = valdezMdt,x = 50,t = 2)
## 1 2
## 50 "alive" "alive"
## 51 "alive" "alive"
## 52 "alive" "alive"
qxt.prime.fromMdt(object = valdezMdt,x=53, decrement="accidents")
## [1] 0.0003504636
qxt.fromQxprime(qx.prime = 0.01,other.qx.prime = c(0.03,0.06))
## [1] 0.009556
#qxt.fromQxprime: Obtain decrement from single decrements
qxt.prime.fromMdt(object=valdezMdt,x=53,decrement="other")
## [1] 0.001426969
qxt.fromQxprime(qx.prime = 0.01,other.qx.prime = c(0.03,0.06))
## [1] 0.009556