R Under development (unstable) (2025-11-17 r89032 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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. > > suppressPackageStartupMessages(library("tbm")) > options(warn = -1L) > library("tram") Loading required package: mvtnorm > library("partykit") Loading required package: grid Attaching package: 'grid' The following object is masked from 'package:variables': unit Loading required package: libcoin Attaching package: 'partykit' The following object is masked from 'package:mboost': varimp > > set.seed(29) > > data("bodyfat", package = "TH.data") > > mf <- as.mlt(Colr(DEXfat ~ 1, data = bodyfat, order = 5)) > logLik(mf) 'log Lik.' -265.4476 (df=6) > > Mstop <- 50 > > fd <- cv(rep(1, NROW(bodyfat)), type = "kfold", B = 2) > > bctrl <- boost_control(nu = .1, trace = FALSE, mstop = Mstop) > > tctrl <- ctree_control(minsplit = 8, minbucket = 5, mincriterion = 0, + maxdepth = 4, splittest = FALSE, + testtype = "Teststatistic") > > bf_t <- ctmboost(model = mf, formula = DEXfat ~ ., data = bodyfat, + method = quote(mboost::blackboost), control = bctrl, + tree_control = tctrl) > logLik(bf_t) 'log Lik.' -209.2997 (df=NULL) > > bf_ctm <- ctmboost(model = mf, formula = DEXfat ~ ., data = bodyfat, + control = bctrl) > logLik(bf_ctm) 'log Lik.' -211.3087 (df=NULL) > table(selected(bf_ctm)) 2 3 5 6 7 8 5 9 5 2 12 17 > > bf_dr <- ctmboost(model = mf, formula = DEXfat ~ ., data = bodyfat, + baselearner = "bols", control = bctrl) > logLik(bf_dr) 'log Lik.' -215.4619 (df=NULL) > table(selected(bf_dr)) 2 3 5 6 7 8 4 5 6 2 21 12 > > bf_st <- stmboost(model = mf, formula = DEXfat ~ ., data = bodyfat, + method = quote(mboost::blackboost), tree_control = tctrl) > round(logLik(bf_st), 0) 'log Lik.' -177 (df=NULL) > > bf_shift <- stmboost(model = mf, formula = DEXfat ~ ., data = bodyfat, + method = quote(mboost::gamboost)) > logLik(bf_shift) 'log Lik.' -189.614 (df=NULL) > table(selected(bf_shift)) 2 3 5 7 8 9 20 35 4 26 10 5 > > bf_lin <- stmboost(model = mf, formula = DEXfat ~ . - 1, data = bodyfat, + method = quote(mboost:::glmboost.formula)) > logLik(bf_lin) 'log Lik.' -191.0065 (df=NULL) > table(selected(bf_lin)) 2 3 5 6 7 8 9 21 33 3 1 26 11 5 > > mf2 <- Lm(DEXfat ~ 1, data = bodyfat) > > bf_lin2 <- ctmboost(model = mf2, formula = DEXfat ~ ., data = bodyfat) > logLik(bf_lin2$model, parm = coef(bf_lin2)) 'log Lik.' -263.1077 (df=NULL) > table(selected(bf_lin2)) 1 2 3 4 5 6 7 8 9 6 9 12 14 11 9 21 12 6 > > ### test against L_2 glmboost > m <- Lm(DEXfat ~ 1, data = bodyfat, fixed = c("DEXfat" = 1)) > bf_1 <- stmboost(model = m, formula = DEXfat ~ 0 + ., data = bodyfat, + control = bctrl, + method = quote(mboost:::glmboost.formula), + mltargs = list(fixed = c("DEXfat" = 1))) > bf_2 <- glmboost(DEXfat ~ ., data = bodyfat, offset = mean(bodyfat$DEXfat), + control = bctrl) > stopifnot(max(abs(mboost:::coef.glmboost(bf_1) - coef(bf_2)[-1])) < + sqrt(.Machine$double.eps)) > r <- risk(bf_1) > stopifnot(r[length(r)] + logLik(bf_1) < sqrt(.Machine$double.eps)) > > stopifnot(max(abs(-nuisance(bf_1) + mboost:::predict.glmboost(bf_1) - predict(bf_2))) < + sqrt(.Machine$double.eps)) > > > proc.time() user system elapsed 9.00 0.37 9.37