R Under development (unstable) (2024-09-28 r87201 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") > > listsoa <- list(soa08Act, soa08Act, soa08Act) > > #test accuraccy > pxyztvect <- pxyzt > pxyzt_matx <- function(x, ...) + sapply(1:NROW(x), function(i) lifecontingencies:::pxyztold(x=x[i,], ...)) > pxyzt_matxt <- function(x, t, ...) + sapply(1:NROW(x), function(i) lifecontingencies:::pxyztold(x=x[i,], t=t[i,1], ...)) > > checkvalx <- function(fractional) + { + x <- cbind(1:120, 11:20, 91:120) + new <- pxyztvect(listsoa, x=x, t=1/4, fractional = fractional) + old <- pxyzt_matx(x, tablesList=listsoa, t=1/4, fractional = fractional) + #print(cbind(new, old)) + sum(abs(new-old)) < 1e-6 + } > > > checkvalx("linear") [1] TRUE > checkvalx("harm") [1] TRUE > checkvalx("exp") [1] TRUE > > checkvalxt <- function(fractional) + { + x <- cbind(1:120, 11:20, 91:120) + t <- cbind(1:20, 1:20, 1:20) + t <- rbind(t,t,t,t,t,t)+1/2 + new <- pxyztvect(listsoa, x=x, t=t, fractional = fractional) + old <- pxyzt_matxt(x, tablesList=listsoa, t=t, fractional = fractional) + #print(cbind(new, old)) + sum(abs(new-old)) < 1e-6 + } > checkvalxt("linear") [1] TRUE > checkvalxt("harm") [1] TRUE > checkvalxt("exp") [1] TRUE > > > x <- cbind(1:120, 11:20, 91:120) > t <- cbind(1:20, 1:20, 1:20) > t <- rbind(t,t,t,t,t,t)+1/2 > > nrep <- 10 > system.time(replicate(nrep, pxyztvect(listsoa, x=x, t=t) )) user system elapsed 0.03 0.00 0.03 > system.time(replicate(nrep, pxyzt_matxt(x, tablesList=listsoa, t=t) )) user system elapsed 1.11 0.00 1.11 > > > listsoa <- list(soa08Act, soa08Act, soa08Act, soa08Act, soa08Act, soa08Act) > x <- cbind(x, x) > t <- cbind(t, t) > > system.time(replicate(nrep, pxyztvect(listsoa, x=x, t=t) )) user system elapsed 0.07 0.00 0.06 > system.time(replicate(nrep, pxyzt_matxt(x, tablesList=listsoa, t=t) )) user system elapsed 2.09 0.00 2.09 > > > proc.time() user system elapsed 5.59 0.21 5.79