Running ‘test-bsplineD.R’
  Running ‘test-bsplines.R’
  Running ‘test-btensor.R’
  Running ‘test-build_tensor.R’
  Running ‘test-cn.R’ [13s/36s]
  Running ‘test-cnr.R’ [9s/24s]
  Running ‘test-coef_vcov.R’ [4s/12s]
  Running ‘test-cp.R’ [6s/16s]
  Running ‘test-cp_diff.R’
  Running ‘test-cp_value.R’
  Running ‘test-cpr.R’ [5s/12s]
  Running ‘test-datasets.R’
  Running ‘test-generate_cp_formula_data.R’
  Running ‘test-get_spline.R’ [7s/22s]
  Running ‘test-get_surface.R’
  Running ‘test-iknots_or_df.R’
  Running ‘test-influence_of_iknots.R’ [5s/13s]
  Running ‘test-insert_a_knot.R’
  Running ‘test-knot_expr.R’
  Running ‘test-loglikelihood.R’ [6s/15s]
  Running ‘test-matrix_rank.R’
  Running ‘test-modify-formula-and-data.R’
  Running ‘test-newknots.R’ [4s/13s]
  Running ‘test-order_statistics.R’
  Running ‘test-plot.cpr_bs.R’
  Running ‘test-plot.cpr_cn.R’
  Running ‘test-plot.cpr_cnr.R’
  Running ‘test-plot.cpr_cp.R’
  Running ‘test-plot.cpr_cpr.R’
  Running ‘test-predict.R’ [19s/57s]
  Running ‘test-recover-known-spline.R’ [12s/32s]
  Running ‘test-summary.cpr_cn.R’
  Running ‘test-summary.cpr_cnr.R’ [9s/23s]
  Running ‘test-summary.cpr_cp.R’ [4s/12s]
  Running ‘test-summary.cpr_cpr.R’ [5s/13s]
  Running ‘test-trimmed_quantile.R’
  Running ‘test-update_bsplines.R’ [14s/40s]
  Running ‘test-wiggle.R’
Running the tests in ‘tests/test-cp.R’ failed.
Complete output:
  > library(cpr)
  > require(lme4)
  Loading required package: lme4
  Loading required package: Matrix
  > require(geepack)
  Loading required package: geepack
  > ################################################################################
  > # Verify that cp.cpr_bs and cp.formula both return similar objects
  > e <- new.env()
  > with(e, {
  + 
  +   xvec <- runif(500, 0, 6)
  +   bknots <- c(0, 6)
  +   dat <- data.frame(x = xvec, y = sin((xvec - 2)/pi) + 1.4 * cos(xvec/pi))
  +   acp <- cp(y ~ bsplines(x, df = 8, bknots = bknots), data = dat)
  +   theta <- coef(lm(y ~ bsplines(x, df = 8, bknots = bknots) - 1, data = dat))
  +   bcp <- cp(bsplines(xvec, df =8, bknots = bknots), theta)
  + 
  +   stopifnot(isTRUE(all.equal(names(acp), names(bcp))))
  + 
  +   stopifnot(identical(
  +     names(acp)
  +     ,
  +     c("cp", "xi", "iknots", "bknots", "order", "call", "keep_fit", "fit", "theta", "coefficients", "vcov", "vcov_theta", "loglik", "rss", "rse")
  +   ))
  + 
  + })
  > 
  > ################################################################################
  > # Verify that an error is thrown if bsplines is not used as expected in the
  > # formula
  > e <- new.env()
  > with(e, {
  +   test <- tryCatch(cp(log10(pdg) ~ age + ttm, data = spdg), error = function(e) e)
  +   stopifnot(inherits(test, "error"))
  +   stopifnot(identical(test$message, "bsplines() must appear first, once, and with no effect modifiers, on the right hand side of the formula."))
  + })
  > 
  > e <- new.env()
  > with(e, {
  +   test <- tryCatch(cp(log10(pdg) ~ age + bsplines(ttm), data = spdg), error = function(e) e)
  +   stopifnot(inherits(test, "error"))
  +   stopifnot(identical(test$message, "bsplines() must appear first, once, and with no effect modifiers, on the right hand side of the formula."))
  + })
  > 
  > e <- new.env()
  > with(e, {
  +   test <- tryCatch(cp(log10(pdg) ~ bsplines(ttm)*age, data = spdg), error = function(e) e)
  +   stopifnot(inherits(test, "error"))
  +   stopifnot(identical(test$message, "bsplines() must appear first, once, and with no effect modifiers, on the right hand side of the formula."))
  + })
  > 
  > ################################################################################
  > # Verify that a control polygon can be build from a lm
  > e <- new.env()
  > with(e, {
  +   xvec <- seq(0, 5.9999, length = 500)
  +   bknots <- c(0, 6)
  +   dat <- data.frame(x = xvec, y = sin((xvec - 2)/pi) + 1.4 * cos(xvec/pi))
  +   cp3 <- cp(y ~ bsplines(x, bknots = bknots), data = dat)
  + 
  +   stopifnot(
  +     isTRUE(
  +       all.equal(
  +         cp3$cp
  +         ,
  +         structure(list(xi_star = c(0, 2, 4, 6),
  +                        theta = c(0.797026006387093, 1.36601191348564, 1.19010324873104, 0.482219646221653)),
  +                   class = "data.frame", row.names = c(NA, -4L))
  +       )
  +     )
  +   )
  + 
  +   stopifnot(
  +     isTRUE(
  +       all.equal(
  +         summary(cp3)
  +         ,
  +         structure(list(dfs = 4L, n_iknots = 0L, iknots = structure(list( numeric(0)), class = "AsIs"), loglik = 2218.47902453217, rss = 0.00409829163655395, rse = 0.0028744886068859, wiggle = structure(0.0685628056150533, abs.error = 7.61200054267312e-16, subdivisions = 1L, message = "OK"), fdsc = 1), row.names = c(NA, -1L), class = c("cpr_summary_cpr_cp", "data.frame"))
  +       )
  +     )
  +   )
  + })
  > 
  > ################################################################################
  > # verify that a control ploygon can be build via lmer
  > e <- new.env()
  > with(e, {
  + 
  +   lmer_cp <- cp(log10(pdg) ~ bsplines(day, bknots = c(-1, 1)) + (1 | id)
  +             , data = spdg
  +             , method = lmer)
  + 
  +   stopifnot(
  +     isTRUE(
  +       all.equal(
  +         lmer_cp$cp
  +         ,
  +         structure(list(xi_star = c(-1, -0.333333333333333, 0.333333333333333, 1), theta = c(0.192421846281352, -2.18938687153398, 1.98993907207642, 0.0777684276192437)), class = "data.frame", row.names = c(NA, -4L))
  +       )
  +     )
  +   )
  + 
  +   stopifnot(
  +     isTRUE(
  +       all.equal(
  +         summary(lmer_cp)
  +         ,
  +         structure(list(dfs = 4L, n_iknots = 0L, iknots = structure(list( numeric(0)), class = "AsIs"), loglik = 7909.94604102081, rss = 622.553425369456, rse = 0.159004352365617, wiggle = structure(60.2815339858114, abs.error = 6.69259469907717e-13, subdivisions = 1L, message = "OK"), fdsc = 2), row.names = c(NA, -1L), class = c("cpr_summary_cpr_cp", "data.frame"))
  +       )
  +     )
  +   )
  + 
  + })
  Error in eval(substitute(expr), data, enclos = parent.frame()) : 
    isTRUE(all.equal(lmer_cp$cp, structure(list(xi_star = c(-1, -0.333333333333333,  .... is not TRUE
  Calls: with -> with.default -> eval -> eval -> stopifnot
  In addition: Warning messages:
  1: In optwrap(optimizer, devfun, getStart(start, rho$pp), lower = rho$lower,  :
    convergence code -2 from nloptwrap: NLOPT_INVALID_ARGS: Invalid arguments (e.g. lower bounds are bigger than upper bounds, an unknown algorithm was specified, etcetera).
  2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
    Model failed to converge with max|grad| = 51.9411 (tol = 0.002, component 1)
  Execution halted
Running the tests in ‘tests/test-summary.cpr_cp.R’ failed.
Complete output:
  > library(cpr)
  > require(lme4)
  Loading required package: lme4
  Loading required package: Matrix
  > 
  > ################################################################################
  > 
  > e <- new.env()
  > with(e, {
  + 
  +   xvec <- runif(500, 0, 6)
  +   bknots <- c(0, 6)
  + 
  +   dat <- data.frame(x = xvec, y = sin((xvec - 2)/pi) + 1.4 * cos(xvec/pi))
  +   acp <- cp(y ~ bsplines(x, df = 8, bknots = bknots), data = dat)
  + 
  +   theta <- coef(lm(y ~ bsplines(x, df = 8, bknots = bknots) - 1, data = dat))
  +   bcp <- cp(bsplines(xvec, df =8, bknots = bknots), theta)
  + 
  +   s1 <- summary(acp, wiggle = TRUE)
  +   s2 <- summary(acp, wiggle = TRUE)
  +   s3 <- summary(bcp, wiggle = FALSE)
  +   s4 <- summary(bcp, wiggle = FALSE)
  + 
  +   stopifnot(inherits(s1, "cpr_summary_cpr_cp"))
  +   stopifnot(inherits(s2, "cpr_summary_cpr_cp"))
  +   stopifnot(inherits(s3, "cpr_summary_cpr_cp"))
  +   stopifnot(inherits(s4, "cpr_summary_cpr_cp"))
  + 
  +   stopifnot(inherits(s1, "data.frame"))
  +   stopifnot(inherits(s2, "data.frame"))
  +   stopifnot(inherits(s3, "data.frame"))
  +   stopifnot(inherits(s4, "data.frame"))
  + 
  +   stopifnot(identical(names(s1), c("dfs", "n_iknots", "iknots", "loglik", "rss", "rse", "wiggle", "fdsc")))
  +   stopifnot(identical(names(s2), c("dfs", "n_iknots", "iknots", "loglik", "rss", "rse", "wiggle", "fdsc")))
  +   stopifnot(identical(names(s3), c("dfs", "n_iknots", "iknots", "loglik", "rss", "rse", "wiggle", "fdsc")))
  +   stopifnot(identical(names(s4), c("dfs", "n_iknots", "iknots", "loglik", "rss", "rse", "wiggle", "fdsc")))
  + 
  +   stopifnot(identical(nrow(s1), 1L))
  +   stopifnot(identical(nrow(s2), 1L))
  +   stopifnot(identical(nrow(s3), 1L))
  +   stopifnot(identical(nrow(s4), 1L))
  + 
  +   stopifnot(identical(s1$dfs, 8L))
  +   stopifnot(identical(s2$dfs, 8L))
  +   stopifnot(identical(s3$dfs, 8L))
  +   stopifnot(identical(s4$dfs, 8L))
  + 
  +   stopifnot(identical(s1$n_iknots, 4L))
  +   stopifnot(identical(s2$n_iknots, 4L))
  +   stopifnot(identical(s3$n_iknots, 4L))
  +   stopifnot(identical(s4$n_iknots, 4L))
  + 
  +   stopifnot(is.list(s1$iknots))
  +   stopifnot(is.list(s2$iknots))
  +   stopifnot(is.list(s3$iknots))
  +   stopifnot(is.list(s4$iknots))
  + 
  +   stopifnot(isTRUE(!is.na(s1$loglik)))
  +   stopifnot(isTRUE(!is.na(s2$loglik)))
  +   stopifnot(isTRUE(is.na(s3$loglik)))
  +   stopifnot(isTRUE(is.na(s4$loglik)))
  + 
  +   stopifnot(isTRUE(!is.na(s1$rss)))
  +   stopifnot(isTRUE(!is.na(s2$rss)))
  +   stopifnot(isTRUE(is.na(s3$rss)))
  +   stopifnot(isTRUE(is.na(s4$rss)))
  + 
  +   stopifnot(isTRUE(!is.na(s1$rse)))
  +   stopifnot(isTRUE(!is.na(s2$rse)))
  +   stopifnot(isTRUE(is.na(s3$rse)))
  +   stopifnot(isTRUE(is.na(s4$rse)))
  + 
  +   stopifnot(isTRUE(!is.na(s1$wiggle)))
  +   stopifnot(isTRUE(!is.na(s2$wiggle)))
  +   stopifnot(isTRUE(is.na(s3$wiggle)))
  +   stopifnot(isTRUE(is.na(s4$wiggle)))
  + 
  +   stopifnot(isTRUE(!is.na(s1$fdsc)))
  +   stopifnot(isTRUE(!is.na(s2$fdsc)))
  +   stopifnot(isTRUE(is.na(s3$fdsc)))
  +   stopifnot(isTRUE(is.na(s4$fdsc)))
  + 
  + })
  > ################################################################################
  > # summary of cp built via lmer
  > e <- new.env()
  > with(e, {
  + 
  +   lmer_cp <- cp(log10(pdg) ~ bsplines(day, bknots = c(-1, 1)) + (1 | id)
  +             , data = spdg
  +             , method = lmer)
  + 
  +   stopifnot(
  +     isTRUE(
  +       all.equal(
  +         summary(lmer_cp)
  +         ,
  +         structure(list(dfs = 4L, n_iknots = 0L, iknots = structure(list( numeric(0)), class = "AsIs"), loglik = 7909.94604102081, rss = 622.553425369456, rse = 0.159004352365617, wiggle = structure(60.2815339858114, abs.error = 6.69259469907717e-13, subdivisions = 1L, message = "OK"), fdsc = 2), row.names = c(NA, -1L), class = c("cpr_summary_cpr_cp", "data.frame"))
  +       )
  +     )
  +   )
  + 
  +   lmer_cp <- cp(log10(pdg) ~ bsplines(day, df = 10, bknots = c(-1, 1)) + (1 | id)
  +             , data = spdg
  +             , method = lmer
  +   )
  +   lmer_cpr <- cpr(lmer_cp)
  +   summary(lmer_cpr)
  +   expected_summary <- structure(list(dfs = 4:10, n_iknots = 0:6, iknots = structure(list( numeric(0), -0.188465250965251, c(-0.188465250965251, 0.522392938868911), c(-0.387864823348694, -0.188465250965251, 0.522392938868911), c(-0.591390091390091, -0.387864823348694, -0.188465250965251, 0.522392938868911), c(-0.591390091390091, -0.387864823348694, -0.188465250965251, 0.0576230492196879, 0.522392938868911), c(-0.791871921182266, -0.591390091390091, -0.387864823348694, -0.188465250965251, 0.0576230492196879, 0.522392938868911)), class = "AsIs"), loglik = c(7909.94604102081, 10436.9685349426, 10737.2482721693, 10914.6482850108, 10921.8458243132, 10921.6797222902, 10918.8473988721), rss = c(622.553425369456, 503.060849675992, 490.342743968001, 482.912931876825, 482.468659854174, 482.310898509441, 482.293585986326), rse = c(0.159004352365617, 0.14293539213227, 0.141119884726865, 0.140049503551057, 0.139987909982521, 0.139967863538051, 0.139968194161426), wiggle = structure(c(60.2815339858114, 68.4958125786486, 35.8347712135129, 40.5896605338692, 38.0314913723466, 39.1709974050207, 41.1623689089349), abs.error = 6.69259469907717e-13, subdivisions = 1L, message = "OK"), fdsc = c(2, 2, 2, 2, 2, 2, 2), `Pr(>w_(1))` = c(NA, 0, 0, 0, 0, 4.04076772042572e-12, 0.00208664723131902)), row.names = c(NA, -7L), class = c("cpr_summary_cpr_cpr", "cpr_summary_cpr_cp", "data.frame"), elbow = structure(c(3, 2, 3, 2, 3, 2), dim = 2:3, dimnames = list( c("quadratic", "linear"), c("loglik", "rss", "rse"))))
  +   stopifnot(isTRUE(all.equal(target = expected_summary, current = summary(lmer_cpr))))
  + })
  Error in eval(substitute(expr), data, enclos = parent.frame()) : 
    isTRUE(all.equal(summary(lmer_cp), structure(list(dfs = 4L, n_iknots = 0L,  .... is not TRUE
  Calls: with -> with.default -> eval -> eval -> stopifnot
  In addition: Warning messages:
  1: In optwrap(optimizer, devfun, getStart(start, rho$pp), lower = rho$lower,  :
    convergence code -2 from nloptwrap: NLOPT_INVALID_ARGS: Invalid arguments (e.g. lower bounds are bigger than upper bounds, an unknown algorithm was specified, etcetera).
  2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
    Model failed to converge with max|grad| = 51.9411 (tol = 0.002, component 1)
  Execution halted