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") > > 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.05 0.00 0.05 > system.time(replicate(nrep, pxyzt_matxt(x, tablesList=listsoa, t=t) )) user system elapsed 1.3 0.0 1.3 > > > 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.08 0.00 0.08 > system.time(replicate(nrep, pxyzt_matxt(x, tablesList=listsoa, t=t) )) user system elapsed 2.43 0.00 2.43 > > > proc.time() user system elapsed 6.39 0.14 6.53