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) > > x <- seq(1e-5, 5.99999, length.out = 100) > bmat <- bsplines(x, iknots = c(1, 1.5, 2.3, 4, 4.5), bknots = c(0, 6)) > theta <- matrix(c(1, 0, 3.5, 4.2, 3.7, -0.5, -0.7, 2, 1.5), ncol = 1) > cp0 <- cp(bmat, theta) > cp1 <- insert_a_knot(x = cp0, xi_prime = 3) > > stopifnot(inherits(cp1, "cpr_cp")) > > stopifnot(isTRUE( + all.equal( + cp1$cp + , + structure(list(xi_star = c(0, 0.333333333333333, 0.833333333333333, 1.6, 2.26666666666667, 3.1, 3.83333333333333, 4.83333333333333, 5.5, 6), + theta = c(1, 0, 3.5, 4.2, 3.86666666666667, 1.6, -0.537837837837838, -0.7, 2, 1.5)), + class = "data.frame", + row.names = c(NA, -10L)) + ) + ) + ) > > proc.time() user system elapsed 0.25 0.06 0.29