R Under development (unstable) (2024-02-14 r85901 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(cpr) > > xvec <- runif(n = 500, min = 0, max = 6) > bmat1 <- bsplines(x = xvec, iknots = c(1, 1.5, 2.3, 4, 4.5), bknots = c(0, 6)) > theta1 <- c(1, 0, 3.5, 4.2, 3.7, -0.5, -0.7, 2, 1.5) > cp1 <- cp(bmat1, theta1) > > x <- c(0.2, 0.8, 1.3, 1.73, 2.15, 3.14, 4.22, 4.88, 5.3, 5.9) > > stopifnot( + isTRUE( + all.equal( + cp_value(cp1, x = x) + , + c(0.4, 3.26666666666667, 3.92608695652174, 4.135, 3.925, 1.432, -0.600540540540541, -0.510999999999999, 1.19, 1.6) + ) + ) + ) > > > bmat2 <- bsplines(x = xvec, bknots = c(0, 6)) > theta2 <- c(1, 3.4, -2, 1.7) > cp2 <- cp(bmat2, theta2) > > stopifnot( + isTRUE( + all.equal( + cp_diff(cp1, cp2) + , + c(0, 1.4, -1.5, -1.28, -1.92, -0.42, 0.241666666666666, -1.225, 0.2) + ) + ) + ) > > ################################################################################ > # End of File # > ################################################################################ > > proc.time() user system elapsed 0.32 0.03 0.35