Vamos a trabajar en la información de las NIF D-3 Recordemos que se tienen los siguientes puntos que estimar:

Generalizando el ejemplo de ayer:

Ahora hagamos esto para cualquier persona de nuestra empresa.

setwd("C:/Users/23043/Dropbox/UDLAP/Cursos/2022 Primavera/Pensiones y SS/Presentaciones")
data<-read.csv("D3.csv")

Aprovechemos y leamos el archivo de decrementos:

MDM<-read.csv("MDM.csv")
MDF<-read.csv("MDF.csv")

library(lifecontingencies)
## Package:  lifecontingencies
## Authors:  Giorgio Alfredo Spedicato [aut, cre]
##     (<https://orcid.org/0000-0002-0315-8888>),
##   Christophe Dutang [ctb] (<https://orcid.org/0000-0001-6732-1501>),
##   Reinhold Kainhofer [ctb] (<https://orcid.org/0000-0002-7895-1311>),
##   Kevin J Owens [ctb],
##   Ernesto Schirmacher [ctb],
##   Gian Paolo Clemente [ctb] (<https://orcid.org/0000-0001-6795-4595>),
##   Ivan Williams [ctb]
## Version:  1.3.7
## Date:     2021-03-21 22:00:02 UTC
## BugReport: https://github.com/spedygiorgio/lifecontingencies/issues
LTM<-probs2lifetable(MDM$Death,radix=1,type="qx","Males")
LTF<-probs2lifetable(MDF$Death,radix=1,type="qx","Females")

Ahora, empecemos con los beneficios. De acuerdo a las características, el salario se proyecta a edad 64 como:

data$S64<-data$Salary*(1.04^(64-data$Age))

Now, since this is a retirement benefit, we have to associate it with a life annuity:

arm<-axn(LTM,x=65,k=12,i=0.035,payment="advance")
arf<-axn(LTF,x=65,k=12,i=0.035,payment="advance")

Now, the accumulated benefit atage x would be:

\[ AL_X= \frac{x-y}{r-y} B_r {_{r-y}}p_x^{\tau} v^{r-x} \ddot{a}_r \]

Now, we can estimate the expected retirememtn benefit Br as

\[ B_r= 0.02 \times s_{64} \times (r-y) \]

data$Br<-0.02*data$S64*(65-data$Entry)

And now, we need the probability of not leaving by any cause and the present value for that.

Asuming that what we have in the table are independent probabilities…

\[ p_x^{\tau} = p_x^m \cdot p_x^{ces}\cdot p_x^r \cdot p_x^t \]

We can estimate this probability of stayin in the population. We determined that the probability of termination is 0.001

MDF$term<-0.001
MDF$tau<-(1-MDF$Death)*(1-MDF$Ces)*(1-MDF$Ret)*(1-MDF$term)

MDM$term<-0.001
MDM$tau<-(1-MDM$Death)*(1-MDM$Ces)*(1-MDM$Ret)*(1-MDM$term)

And now, we can create a new “life table” for this overall probability of staying in the population:

LTTM<-probs2lifetable(MDM$tau,radix=1,type="px")
LTTF<-probs2lifetable(MDF$tau,radix=1,type="px")

And now, we can estimate the present value assuming an interest rate of 5%.

data$bpe<-ifelse(data$Gender=="M",
                 data$Br*pxt(LTTM,x=data$Age,t=65-data$Age)*
                   (1.05^(-65-data$Age))*arm*(
                     (data$Age-data$Entry)/(65-data$Entry)),
                 data$Br*pxt(LTTF,x=data$Age,t=65-data$Age)*
                   (1.05^(-65-data$Age))*arf*(
                     (data$Age-data$Entry)/(65-data$Entry)))

Now, for the termination of work relation. We have to estimate the present value of all the possible payments. According to our method, if the employment is terminated before retirement age, the person will receive 50% of the accumulated benefit. This is

\[ =0.5 \frac{x-y}{r-y} B_r {_{r-y}}p_x^{\tau} v^{r-x} \ddot{a}_r \]

One important assumption is that years of employment remain constant and we only have to estimate the probability pf paying. Then, this become a life insurance for the benefit of:

\[ = \bigg(0.5 \frac{x-y}{r-y} B_r {_{r-y}}p_x^{\tau} v^{r-x} \ddot{a}_r \bigg) A_{x:n} \]

LTTerM<-probs2lifetable(MDM$term,radix=1,type="qx")
LTTerF<-probs2lifetable(MDF$term,radix=1,type="qx")

Now, we estimate the benefit:

data$ter1<-0.5*data$bpe*ifelse(data$Gender=="M",Axn(LTTerM,x=data$Age,
                                n=65-data$Age,i=0.05),
                                Axn(LTTerF,x=data$Age,n=65-data$Age,
                                    i=0.05))
data$ter2<-(3*data$Salary+20*(data$Salary/30)*(data$Age-data$Entry)+
  12*(data$Salary/30)*(data$Age-data$Entry))*ifelse(data$Gender=="M",
                    Axn(LTTerM,x=data$Age,n=65-data$Age,i=0.05),
                    Axn(LTTerF,x=data$Age,n=65-data$Age,i=0.05))

And finally, we have the life insurance benefit:

data$lins<-data$bpe*ifelse(data$Gender=="M",Axn(LTM,x=data$Age,
                                                n=65-data$Age,
                   i=0.05),Axn(LTF,x=data$Age,n=65-data$Age,i=0.05))

And finally, we have the OBD:

data$OBD<-data$bpe+data$lins+data$ter1+data$ter2

Now, we estimate the total:

OBD<-sum(data$OBD)
OBD
## [1] 1373999