Last updated on 2026-04-25 13:50:31 CEST.
| Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
|---|---|---|---|---|---|---|
| r-devel-linux-x86_64-debian-clang | 0.8.0 | 87.73 | 393.20 | 480.93 | OK | |
| r-devel-linux-x86_64-debian-gcc | 0.8.0 | 70.23 | 283.43 | 353.66 | OK | |
| r-devel-linux-x86_64-fedora-clang | 0.8.0 | 121.00 | 604.68 | 725.68 | OK | |
| r-devel-linux-x86_64-fedora-gcc | 0.8.0 | 184.00 | 603.26 | 787.26 | OK | |
| r-patched-linux-x86_64 | 0.8.0 | 92.57 | 376.10 | 468.67 | OK | |
| r-release-linux-x86_64 | 0.8.0 | 89.75 | 366.12 | 455.87 | OK | |
| r-release-macos-arm64 | 0.8.0 | 19.00 | 91.00 | 110.00 | OK | |
| r-release-macos-x86_64 | 0.8.0 | 64.00 | 357.00 | 421.00 | ERROR | |
| r-release-windows-x86_64 | 0.8.0 | 111.00 | 421.00 | 532.00 | OK | |
| r-oldrel-macos-arm64 | 0.8.0 | OK | ||||
| r-oldrel-macos-x86_64 | 0.8.0 | 60.00 | 433.00 | 493.00 | OK | |
| r-oldrel-windows-x86_64 | 0.8.0 | 100.00 | 391.00 | 491.00 | OK |
Version: 0.8.0
Check: examples
Result: ERROR
Running examples in ‘mcmcsae-Ex.R’ failed
The error most likely occurred in:
> ### Name: brt
> ### Title: Create a model component object for a BART (Bayesian Additive
> ### Regression Trees) component in the linear predictor
> ### Aliases: brt
>
> ### ** Examples
>
> # generate data, based on an example in Friedman (1991)
> gendat <- function(n=150L, p=10L, sigma=1) {
+ x <- matrix(runif(n * p), n, p)
+ mu <- 10*sin(pi*x[, 1] * x[, 2]) + 20*(x[, 3] - 0.5)^2 + 10*x[, 4] + 5*x[, 5]
+ y <- mu + sigma * rnorm(n)
+ data.frame(x=x, mu=mu, y=y)
+ }
>
> train <- gendat()
> test <- gendat(n=25)
>
> # keep trees for later prediction based on new data
> sampler <- create_sampler(
+ y ~ brt(~ . - y, name="bart", keepTrees=TRUE),
+ family = f_gaussian(var.prior=pr_invchisq(df=3, scale=var(train$y))),
+ data = train
+ )
Error in (function (formula, X = NULL, n.trees = 75L, name = "", debug = FALSE, :
package dbarts required for a model including Bayesian Additive Regression Trees
Calls: create_sampler -> do.call -> <Anonymous>
Execution halted
Flavor: r-release-macos-x86_64
Version: 0.8.0
Check: tests
Result: ERROR
Running ‘testthat.R’ [127s/183s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
>
> test_check("mcmcsae")
Loading required package: mcmcsae
Saving _problems/test_bart-21.R
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 915 ]
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test_bart.R:17:3'): BART component 'brt' works ──────────────────────
Error in `(function (formula, X = NULL, n.trees = 75L, name = "", debug = FALSE, keepTrees = FALSE, e, in.block, ...) { type <- "brt" if (name == "") stop("missing model component name") if (!requireNamespace("dbarts", quietly = TRUE)) stop("package dbarts required for a model including Bayesian Additive Regression Trees") if (e[["modeled.Q"]] && e[["Q0.type"]] == "symm") stop("BART component not compatible with non-diagonal residual variance matrix") if (is.null(X)) { X <- model_matrix(formula, e[["data"]], contrasts.arg = "contr.none", sparse = FALSE) } else { if (is.null(dimnames(X)[[2L]])) colnames(X) <- seq_len(ncol(X)) } X <- economizeMatrix(X, sparse = FALSE, strip.names = FALSE, check = TRUE) q <- ncol(X) in.block <- FALSE control <- dbarts::dbartsControl(n.chains = 1L, updateState = FALSE, n.trees = n.trees) name_sampler <- paste0(name, "_sampler_") lp <- function(p) copy_vector(p[[name]]) lp_update <- function(x, plus = TRUE, p) v_update(x, plus, p[[name]]) draws_linpred <- function(obj, units = NULL, chains = NULL, draws = NULL, matrix = FALSE) { if (is.null(obj[[name]])) stop("no fitted values for 'brt' component; please re-run MCMCsim with 'store.all=TRUE'") if (matrix) out <- as.matrix.dc(get_from(obj[[name]], vars = units, chains = chains, draws = draws)) else { out <- list() for (ch in seq_along(chains)) out[[ch]] <- get_from(obj[[name]], vars = units, chains = chains[ch], draws = draws)[[1L]] } out } create_BART_sampler <- function() { if (e[["Q0.type"]] == "diag") { dbarts::dbarts(formula = X, data = e$y_eff(), weights = e$Q0@x, sigma = if (e[["sigma.fixed"]]) 1 else NA_real_, control = control, ...) } else { dbarts::dbarts(formula = X, data = e$y_eff(), sigma = if (e[["sigma.fixed"]]) 1 else NA_real_, control = control, ...) } } start <- function(p) { if (is.null(p[[name_sampler]])) { p[[name_sampler]] <- create_BART_sampler() } p[[name]] <- p[[name_sampler]]$run(0L, 1L, FALSE)$train[, 1L] p } if (e$family[["family"]] == "multinomial") { edat <- new.env(parent = environment(formula)) environment(formula) <- edat } if (keepTrees) { name_trees <- paste0(name, "_", "trees_") store.default <- name_trees } else { store.default <- NULL } make_predict <- function(newdata = NULL, Xnew = NULL, verbose = TRUE) { if (is.null(newdata) && is.null(Xnew)) { linpred <- function(p) copy_vector(p[[name]]) linpred_update <- function(x, plus = TRUE, p) v_update(x, plus, p[[name]]) } else { if (is.null(newdata)) { if (missing(Xnew)) stop("one of 'newdata' and 'Xnew' should be supplied") } else { if (!keepTrees) stop("out-of-sample prediction requires setting keepTrees=TRUE in brt() model specification") nnew <- nrow(newdata) if (e$family[["family"]] == "multinomial") { Xnew <- NULL for (k in seq_len(e[["Km1"]])) { edat$cat_ <- factor(rep.int(e$cats[k], nnew), levels = e$cats[-length(e$cats)]) Xnew <- rbind(Xnew, model_matrix(formula, data = newdata, contrasts.arg = "contr.none", sparse = FALSE)) } edat$cat_ <- NULL } else { Xnew <- model_matrix(formula, newdata, contrasts.arg = "contr.none", sparse = FALSE) } } if (is.null(dimnames(Xnew)[[2L]])) { if (ncol(Xnew) != q) stop("wrong number ", ncol(Xnew), " predictor column(s) for model term '", name, "' versus ", q, " originally") } else { Xnew <- Xnew[, dimnames(X)[[2L]], drop = FALSE] } Xnew <- economizeMatrix(Xnew, sparse = FALSE, strip.names = TRUE, check = TRUE) rm(newdata, verbose) nnew <- nrow(Xnew) tree_predict <- function(p) { getPredictionsForTreeRecursive <- function(tree, indices) { if (tree$var[1L] == -1L) { predictions[indices] <<- predictions[indices] + tree$value[1L] return(1L) } goesLeft <- Xnew[indices, tree$var[1L]] <= tree$value[1L] headOfLeftBranch <- tree[-1L, ] n_nodes.left <- getPredictionsForTreeRecursive(headOfLeftBranch, indices[goesLeft]) headOfRightBranch <- tree[seq.int(2L + n_nodes.left, dim(tree)[1L]), ] n_nodes.right <- getPredictionsForTreeRecursive(headOfRightBranch, indices[!goesLeft]) return(1L + n_nodes.left + n_nodes.right) } trees <- p[[name_trees]] predictions <- numeric(nnew) for (t in seq_len(n.trees)) getPredictionsForTreeRecursive(trees[trees$tree == t, ], seq_len(nnew)) predictions } linpred <- function(p) tree_predict(p) linpred_update <- function(x, plus = TRUE, p) v_update(x, plus, tree_predict(p)) } environment() } rprior <- function(p) { if (is.null(p[[name_sampler]])) { p[[name_sampler]] <- create_BART_sampler() } p[[name_sampler]]$sampleTreesFromPrior() p[[name_sampler]]$sampleNodeParametersFromPrior() p[[name]] <- p[[name_sampler]]$predict(X) if (keepTrees) { p[[name_trees]] <- p[[name_sampler]]$getTrees()[, -2L] } p } if (!e[["prior.only"]]) { draw <- if (debug) function(p) { browser() } else function(p) { } if (!e[["single.block"]]) { if (e[["e.is.res"]]) draw <- add(draw, bquote(p$e_ <- p[["e_"]] + p[[.(name)]])) else draw <- add(draw, bquote(p$e_ <- p[["e_"]] - p[[.(name)]])) draw <- add(draw, bquote(p[[.(name_sampler)]]$setResponse(p[["e_"]]))) } if (e[["modeled.Q"]]) draw <- add(draw, bquote(p[[.(name_sampler)]]$setWeights(p[["Q_"]]))) draw <- add(add(draw, bquote(p[[.(name_sampler)]]$setSigma(.(if (e$sigma.fixed) 1 else quote(p[["sigma_"]]))))), bquote(p[[.(name)]] <- p[[.(name_sampler)]]$run(0L, 1L)$train[, 1L])) if (keepTrees) { draw <- add(draw, bquote(p[[.(name_trees)]] <- p[[.(name_sampler)]]$getTrees()[, -2L])) if (e[["single.block"]]) { min.y <- min(e$y_eff()) range.y <- max(e$y_eff()) - min.y } else { draw <- add(draw, quote(min.y <- min(p[["e_"]]))) draw <- add(draw, quote(range.y <- max(p[["e_"]]) - min.y)) } draw <- add(draw, bquote(p[[.(name_trees)]]$value[p[[.(name_trees)]]$var == -1L] <- min.y/n.trees + range.y * (p[[.(name_trees)]]$value[p[[.(name_trees)]]$var == -1L] + 0.5/n.trees))) } if (e[["single.block"]]) { if (e[["e.is.res"]]) draw <- add(draw, bquote(p$e_ <- e$y_eff() - p[[.(name)]])) else draw <- add(draw, bquote(p$e_ <- p[[.(name)]])) } else { if (e[["e.is.res"]]) draw <- add(draw, bquote(p$e_ <- p[["e_"]] - p[[.(name)]])) else draw <- add(draw, bquote(p$e_ <- p[["e_"]] + p[[.(name)]])) } draw <- add(draw, quote(p)) } environment() })(~0 + x, n.trees = n.tr, debug = FALSE, keepTrees = TRUE, name = "bart", e = <environment>, in.block = FALSE)`: package dbarts required for a model including Bayesian Additive Regression Trees
Backtrace:
▆
1. ├─mcmcsae::create_sampler(...) at test_bart.R:17:3
2. │ └─base::do.call(...)
3. └─mcmcsae (local) `<fn>`(...)
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 915 ]
Error:
! Test failures.
Execution halted
Flavor: r-release-macos-x86_64