R Under development (unstable) (2024-02-23 r85978 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(lifecontingencies) Package: lifecontingencies Authors: Giorgio Alfredo Spedicato [aut, cre] (), Christophe Dutang [ctb] (), Reinhold Kainhofer [ctb] (), Kevin J Owens [ctb], Ernesto Schirmacher [ctb], Gian Paolo Clemente [ctb] (), Ivan Williams [ctb] Version: 1.3.12 Date: BugReport: https://github.com/spedygiorgio/lifecontingencies/issues > > pXt <- Vectorize(lifecontingencies:::pxtold, "x") > > > # class = "lifetable" > valdezDf<-data.frame( + x=0:4, + lx=c(4832555,4821937,4810206,4797185,4782737) + ) > valdezltb<-new("lifetable",name="ValdezExample", + x=valdezDf$x, lx=valdezDf$lx) > > pxt(valdezltb,x=0:2,t=3) [1] 0.9926809 0.9918705 0.0000000 > pXt(valdezltb,x=0:2,t=3) [1] 0.9926809 0.9918705 0.0000000 > > # class = "actuarialtable" > valdezDf<-data.frame( + x=0:4, + lx=c(4832555,4821937,4810206,4797185,4782737) + ) > valdezact<-new("actuarialtable",name="ValdezExample", + x=valdezDf$x, lx=valdezDf$lx, interest=2/100) > > pxt(valdezact,x=0:2,t=3) [1] 0.9926809 0.9918705 0.0000000 > pXt(valdezact,x=0:2,t=3) [1] 0.9926809 0.9918705 0.0000000 > > # class = "mdt" > valdezDf<-data.frame( + x=c(50:54), + lx=c(4832555,4821937,4810206,4797185,4782737), + heart=c(5168, 5363, 5618, 5929, 6277), + accidents=c(1157, 1206, 1443, 1679,2152), + other=c(4293,5162,5960,6840,7631) + ) > 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 ... .. ..$ heart : 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 ... > > cbind(pxt(valdezMdt,x=50:51,t=3), pXt(valdezMdt,x=50:51,t=3)) [,1] [,2] [1,] 0.9926809 0.9926809 [2,] 0.9918705 0.9918705 > > c(dxt(valdezMdt,x=51,t=2,decrement = "other"),11122) [1] 11122 11122 > c(round( pxt(valdezMdt,x=50,t=3),5),0.99268) [1] 0.99268 0.99268 > c(round( qxt(valdezMdt,x=50,t=3, decrement = "heart"),5),0.00334) [1] 0.00334 0.00334 > > proc.time() user system elapsed 1.35 0.23 1.57