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 > > data("soa08Act") > > #test accuraccy > aXn <- Vectorize(lifecontingencies:::axnold, "x") > axN <- Vectorize(lifecontingencies:::axnold, "n") > axnM <- Vectorize(lifecontingencies:::axnold, "m") > > axnvect <- axn > > #high-age > x <- 85:90 > cbind(x=x, axnvect(soa08Act, x=x, pay="advance"), aXn(soa08Act, x=x, pay="advance")) x [1,] 85 4.698033 4.698033 [2,] 86 4.474210 4.474210 [3,] 87 4.257102 4.257102 [4,] 88 4.047003 4.047003 [5,] 89 3.844167 3.844167 [6,] 90 3.648810 3.648810 > > #non-integer age > x <- 30:35+1/2 > cbind(x=x, axnvect(soa08Act, x=x, pay="advance"), aXn(soa08Act, x=x, pay="advance")) x [1,] 30.5 15.81390 15.81390 [2,] 31.5 15.72741 15.72741 [3,] 32.5 15.63689 15.63689 [4,] 33.5 15.54222 15.54222 [5,] 34.5 15.44325 15.44325 [6,] 35.5 15.33985 15.33985 > > > #strange arguments > x <- 85:90 > cbind(x=x, axnvect(soa08Act, x=x, n=c(0,10), m=c(0,1, 2), pay="advance")) x [1,] 85 0.000000 [2,] 86 3.379334 [3,] 87 0.000000 [4,] 88 3.960328 [5,] 89 0.000000 [6,] 90 1.871526 > > > checkvalx <- function(payment) + all(axnvect(soa08Act, x=1:100, payment=payment) == aXn(soa08Act, x=1:100, payment=payment)) > checkvaln <- function(payment) + all(axnvect(soa08Act, x=33, n=10:50, payment=payment) == axN(soa08Act, x=33, n=10:50, payment=payment)) > checkvalm <- function(payment) + all(axnvect(soa08Act, x=33, m=0:50, payment=payment) == axnM(soa08Act, x=33, m=0:50, payment=payment)) > > c(checkvalx("due"), checkvalx("arrears"), checkvalx("immediate"), checkvalx("advance")) [1] TRUE TRUE TRUE TRUE > c(checkvaln("due"), checkvaln("arrears"), checkvaln("immediate"), checkvaln("advance")) [1] TRUE TRUE TRUE TRUE > c(checkvalm("due"), checkvalm("arrears"), checkvalm("immediate"), checkvalm("advance")) [1] TRUE TRUE TRUE TRUE > > nrep <- 10 > T1 <- system.time(replicate(nrep, axnvect(soa08Act, x=1:100, pay="advance") )) > T2 <- system.time(replicate(nrep, aXn(soa08Act, x=1:100, pay="advance") )) > > T3 <- system.time(replicate(nrep, axnvect(soa08Act, x=33, n=1:50, pay="advance") )) > T4 <- system.time(replicate(nrep, axN(soa08Act, x=33, n=1:50, pay="advance") )) > > alltime <- rbind(T1, T2, T3, T4)[, 1:3] > #library(xtable);xtable(alltime, digits=3) > > > proc.time() user system elapsed 11.89 0.29 12.17