Last updated on 2026-10-22 23:56:48 CEST.
| Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
|---|---|---|---|---|---|---|
| r-devel-linux-x86_64-debian-clang | 2.9-14 | 14.34 | 521.00 | 535.34 | NOTE | |
| r-devel-linux-x86_64-debian-gcc | 2.9-14 | 11.15 | 348.33 | 359.48 | NOTE | |
| r-devel-linux-x86_64-fedora-clang | 2.9-14 | 11.00 | 337.02 | 348.02 | ERROR | |
| r-devel-linux-x86_64-fedora-gcc | 2.9-14 | 11.00 | 349.35 | 360.35 | ERROR | |
| r-devel-windows-x86_64 | 2.9-14 | 20.00 | 415.00 | 435.00 | NOTE | --no-vignettes |
| r-patched-linux-x86_64 | 2.9-14 | 16.57 | 499.64 | 516.21 | OK | |
| r-release-linux-x86_64 | 2.9-14 | 15.23 | 498.15 | 513.38 | OK | |
| r-release-macos-arm64 | 2.9-14 | 6.00 | 151.00 | 157.00 | OK | |
| r-release-macos-x86_64 | 2.9-14 | 13.00 | 552.00 | 565.00 | OK | |
| r-release-windows-x86_64 | 2.9-14 | 20.00 | 380.00 | 400.00 | OK | --no-vignettes |
| r-oldrel-macos-arm64 | 2.9-14 | 4.00 | 120.00 | 124.00 | OK | |
| r-oldrel-macos-x86_64 | 2.9-14 | 13.00 | 589.00 | 602.00 | OK | |
| r-oldrel-windows-x86_64 | 2.9-14 | 27.00 | 390.00 | 417.00 | OK | --no-vignettes |
Version: 2.9-14
Check: tests
Result: NOTE
Running ‘birds_Biometrics.R’ [14s/18s]
Comparing ‘birds_Biometrics.Rout’ to ‘birds_Biometrics.Rout.save’ ... OK
Running ‘bugfixes.R’ [70s/83s]
Comparing ‘bugfixes.Rout’ to ‘bugfixes.Rout.save’ ...
891c891,907
< There were 14 warnings (use warnings() to see them)
---
> Warning messages:
> 1: In bols(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 2: In bbs(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 3: In bols(z1, df = 4, contrasts.arg = "contr.dummy") :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 4: In bbs(x1, x2, df = 6) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 5: In brad(x1, x2, knots = 20) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 6: In fields::cover.design(R = unique(x), nd = knots) :
> Number of nearst neighbors (nn) reduced to the actual number of candidates
> 7: In bmono(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 8: In buser(x1, K = 1, lambda = 0) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
950,952d965
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
959,961d971
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
Running ‘regtest-baselearner.R’ [32s/38s]
Comparing ‘regtest-baselearner.Rout’ to ‘regtest-baselearner.Rout.save’ ...
41,42c41,42
< Warning messages:
< 1: In bols(xn) :
---
> Warning message:
> In bols(xn) :
44d43
< 2: object length is not a multiple of subscript length
55d53
< 3: object length is not a multiple of subscript length
96,97c94,95
< Warning messages:
< 1: In bols(xn, xf) :
---
> Warning message:
> In bols(xn, xf) :
99d96
< 2: object length is not a multiple of subscript length
111d107
< 3: object length is not a multiple of subscript length
122d117
< 3: object length is not a multiple of subscript length
129,130c124,125
< Warning messages:
< 1: In bols(one, xn, lambda = 2, intercept = FALSE) :
---
> Warning message:
> In bols(one, xn, lambda = 2, intercept = FALSE) :
132d126
< 2: object length is not a multiple of subscript length
292,293c286,287
< Warning messages:
< 1: In bbs(x, df = ncol(X)) :
---
> Warning message:
> In bbs(x, df = ncol(X)) :
295d288
< 2: object length is not a multiple of subscript length
297,298c290,291
< Warning messages:
< 1: In bols(X, df = ncol(X)) :
---
> Warning message:
> In bols(X, df = ncol(X)) :
300d292
< 2: object length is not a multiple of subscript length
Running ‘regtest-blackboost.R’ [76s/98s]
Comparing ‘regtest-blackboost.Rout’ to ‘regtest-blackboost.Rout.save’ ... OK
Running ‘regtest-family.R’ [21s/25s]
Comparing ‘regtest-family.Rout’ to ‘regtest-family.Rout.save’ ... OK
Running ‘regtest-gamboost.R’ [10s/13s]
Comparing ‘regtest-gamboost.Rout’ to ‘regtest-gamboost.Rout.save’ ...
757,758d756
< Warning message:
< object length is not a multiple of subscript length
763,764d760
< Warning message:
< object length is not a multiple of subscript length
Running ‘regtest-glmboost.R’ [12s/15s]
Comparing ‘regtest-glmboost.Rout’ to ‘regtest-glmboost.Rout.save’ ... OK
Running ‘regtest-hatmatrix.R’ [2s/3s]
Comparing ‘regtest-hatmatrix.Rout’ to ‘regtest-hatmatrix.Rout.save’ ... OK
Running ‘regtest-varimp.R’ [4s/4s]
Comparing ‘regtest-varimp.Rout’ to ‘regtest-varimp.Rout.save’ ... OK
Flavor: r-devel-linux-x86_64-debian-clang
Version: 2.9-14
Check: tests
Result: NOTE
Running ‘birds_Biometrics.R’ [11s/13s]
Comparing ‘birds_Biometrics.Rout’ to ‘birds_Biometrics.Rout.save’ ... OK
Running ‘bugfixes.R’ [42s/48s]
Comparing ‘bugfixes.Rout’ to ‘bugfixes.Rout.save’ ...
891c891,907
< There were 14 warnings (use warnings() to see them)
---
> Warning messages:
> 1: In bols(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 2: In bbs(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 3: In bols(z1, df = 4, contrasts.arg = "contr.dummy") :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 4: In bbs(x1, x2, df = 6) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 5: In brad(x1, x2, knots = 20) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 6: In fields::cover.design(R = unique(x), nd = knots) :
> Number of nearst neighbors (nn) reduced to the actual number of candidates
> 7: In bmono(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 8: In buser(x1, K = 1, lambda = 0) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
950,952d965
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
959,961d971
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
Running ‘regtest-baselearner.R’ [29s/34s]
Comparing ‘regtest-baselearner.Rout’ to ‘regtest-baselearner.Rout.save’ ...
41,42c41,42
< Warning messages:
< 1: In bols(xn) :
---
> Warning message:
> In bols(xn) :
44d43
< 2: object length is not a multiple of subscript length
55d53
< 3: object length is not a multiple of subscript length
96,97c94,95
< Warning messages:
< 1: In bols(xn, xf) :
---
> Warning message:
> In bols(xn, xf) :
99d96
< 2: object length is not a multiple of subscript length
111d107
< 3: object length is not a multiple of subscript length
122d117
< 3: object length is not a multiple of subscript length
129,130c124,125
< Warning messages:
< 1: In bols(one, xn, lambda = 2, intercept = FALSE) :
---
> Warning message:
> In bols(one, xn, lambda = 2, intercept = FALSE) :
132d126
< 2: object length is not a multiple of subscript length
292,293c286,287
< Warning messages:
< 1: In bbs(x, df = ncol(X)) :
---
> Warning message:
> In bbs(x, df = ncol(X)) :
295d288
< 2: object length is not a multiple of subscript length
297,298c290,291
< Warning messages:
< 1: In bols(X, df = ncol(X)) :
---
> Warning message:
> In bols(X, df = ncol(X)) :
300d292
< 2: object length is not a multiple of subscript length
Running ‘regtest-blackboost.R’ [42s/47s]
Comparing ‘regtest-blackboost.Rout’ to ‘regtest-blackboost.Rout.save’ ... OK
Running ‘regtest-family.R’ [15s/19s]
Comparing ‘regtest-family.Rout’ to ‘regtest-family.Rout.save’ ... OK
Running ‘regtest-gamboost.R’ [6s/7s]
Comparing ‘regtest-gamboost.Rout’ to ‘regtest-gamboost.Rout.save’ ...
757,758d756
< Warning message:
< object length is not a multiple of subscript length
763,764d760
< Warning message:
< object length is not a multiple of subscript length
Running ‘regtest-glmboost.R’ [8s/10s]
Comparing ‘regtest-glmboost.Rout’ to ‘regtest-glmboost.Rout.save’ ... OK
Running ‘regtest-hatmatrix.R’ [2s/2s]
Comparing ‘regtest-hatmatrix.Rout’ to ‘regtest-hatmatrix.Rout.save’ ... OK
Running ‘regtest-varimp.R’ [3s/3s]
Comparing ‘regtest-varimp.Rout’ to ‘regtest-varimp.Rout.save’ ... OK
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 2.9-14
Check: tests
Result: ERROR
Running ‘birds_Biometrics.R’ [10s/13s]
Comparing ‘birds_Biometrics.Rout’ to ‘birds_Biometrics.Rout.save’ ... OK
Running ‘bugfixes.R’ [51s/66s]
Comparing ‘bugfixes.Rout’ to ‘bugfixes.Rout.save’ ...
891c891,907
< There were 14 warnings (use warnings() to see them)
---
> Warning messages:
> 1: In bols(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 2: In bbs(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 3: In bols(z1, df = 4, contrasts.arg = "contr.dummy") :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 4: In bbs(x1, x2, df = 6) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 5: In brad(x1, x2, knots = 20) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 6: In fields::cover.design(R = unique(x), nd = knots) :
> Number of nearst neighbors (nn) reduced to the actual number of candidates
> 7: In bmono(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 8: In buser(x1, K = 1, lambda = 0) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
950,952d965
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
959,961d971
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
Running ‘regtest-baselearner.R’ [25s/25s]
Comparing ‘regtest-baselearner.Rout’ to ‘regtest-baselearner.Rout.save’ ...
41,42c41,42
< Warning messages:
< 1: In bols(xn) :
---
> Warning message:
> In bols(xn) :
44d43
< 2: object length is not a multiple of subscript length
55d53
< 3: object length is not a multiple of subscript length
96,97c94,95
< Warning messages:
< 1: In bols(xn, xf) :
---
> Warning message:
> In bols(xn, xf) :
99d96
< 2: object length is not a multiple of subscript length
111d107
< 3: object length is not a multiple of subscript length
122d117
< 3: object length is not a multiple of subscript length
129,130c124,125
< Warning messages:
< 1: In bols(one, xn, lambda = 2, intercept = FALSE) :
---
> Warning message:
> In bols(one, xn, lambda = 2, intercept = FALSE) :
132d126
< 2: object length is not a multiple of subscript length
292,293c286,287
< Warning messages:
< 1: In bbs(x, df = ncol(X)) :
---
> Warning message:
> In bbs(x, df = ncol(X)) :
295d288
< 2: object length is not a multiple of subscript length
297,298c290,291
< Warning messages:
< 1: In bols(X, df = ncol(X)) :
---
> Warning message:
> In bols(X, df = ncol(X)) :
300d292
< 2: object length is not a multiple of subscript length
Running ‘regtest-blackboost.R’ [47s/47s]
Comparing ‘regtest-blackboost.Rout’ to ‘regtest-blackboost.Rout.save’ ... OK
Running ‘regtest-family.R’ [12s/12s]
Comparing ‘regtest-family.Rout’ to ‘regtest-family.Rout.save’ ... OK
Running ‘regtest-gamboost.R’
Comparing ‘regtest-gamboost.Rout’ to ‘regtest-gamboost.Rout.save’ ...
757,758d756
< Warning message:
< object length is not a multiple of subscript length
763,764d760
< Warning message:
< object length is not a multiple of subscript length
Running ‘regtest-glmboost.R’
Running ‘regtest-hatmatrix.R’
Comparing ‘regtest-hatmatrix.Rout’ to ‘regtest-hatmatrix.Rout.save’ ... OK
Running ‘regtest-varimp.R’
Comparing ‘regtest-varimp.Rout’ to ‘regtest-varimp.Rout.save’ ... OK
Running the tests in ‘tests/regtest-glmboost.R’ failed.
Complete output:
>
> options(digits = 3)
>
> .all.equal <- function(...) isTRUE(all.equal(..., check.environment = FALSE))
> library("mboost")
Loading required package: parallel
Loading required package: stabs
>
> set.seed(290875)
>
> dgp <- function(n = 100, beta = rep(0, 10), sd = 1) {
+ p <- length(beta) - 1
+ x <- cbind(1, matrix(runif(n * p), ncol = p))
+ lp <- x %*% beta
+ y <- lp + rnorm(n, sd = sd)
+ ls <- data.frame(y = y, x[,-1])
+ attr(ls, "lp") <- lp
+ ls
+ }
>
> ### well-defined problem
> mydf <- dgp(beta = c(1, 2.5, rep(0, 2)))
>
> ### for easy comparison with lm
> fm <- Gaussian()
> fm@offset <- function(y, w) 0
>
> mydf.gb <- glmboost(y ~ ., data = mydf, family = fm,
+ control = boost_control(mstop = 1000, nu = 1))
> mydf.lm <- lm(y ~ ., data = mydf)
>
> ### compare coefficients
> print(max(abs(coef(mydf.gb) - coef(mydf.lm))) < 1e-10)
[1] TRUE
>
> ### a little bit more difficult
> mydf <- dgp(beta = c(1, 2.5, rep(0, 38)))
>
> mydf.gb <- glmboost(y ~ ., data = mydf, family = fm,
+ control = boost_control(mstop = 1000, nu = 1))
> aic <- AIC(mydf.gb, method = "corrected")
> ht <- hatvalues(mydf.gb)
> print(mstop(aic) == 12)
[1] TRUE
> plot(aic, ylim = c(0,3))
> mydf.lm <- lm(y ~ ., data = mydf)
>
> ## use AIC with active set as df
> aic2 <- AIC(mydf.gb, method = "corrected", df = "actset")
> print(mstop(aic2)== 9)
[1] TRUE
> print(attr(aic2, "df")[9] == 9)
[1] TRUE
>
> ## use gMDL
> aic3 <- AIC(mydf.gb, method = "gMDL")
> print(mstop(aic3) == 4)
[1] TRUE
>
> ### compare coefficients
> which(abs(coef(mydf.lm, which = "")) < abs(coef(mydf.gb[mstop(aic)], which = "")))
(Intercept) X1 X10 X14 X37
1 2 11 15 38
>
> #### check boosting hat matrix and subsetting / predict
> print(isTRUE(.all.equal(drop(attr(ht, "hatmatrix") %*% mydf$y),
+ as.vector(predict(mydf.gb[1000])))))
[1] TRUE
> ht25 <- hatvalues(mydf.gb[25])
> print(isTRUE(.all.equal(drop(attr(ht25, "hatmatrix") %*% mydf$y),
+ as.vector(predict(mydf.gb[25])))))
[1] TRUE
> print(isTRUE(.all.equal(drop(attr(ht25, "hatmatrix") %*% mydf$y),
+ as.vector(fitted(mydf.gb[25])))))
[1] TRUE
>
> ### a simple two-dimensional example from `glmboost.Rd'
> data("cars")
> cars.gb <- glmboost(dist ~ speed, data = cars, family = fm, center = FALSE,
+ control = boost_control(mstop = 1000, nu = 1))
> cars.gb
Generalized Linear Models Fitted via Gradient Boosting
Call:
glmboost.formula(formula = dist ~ speed, data = cars, family = fm, center = FALSE, control = boost_control(mstop = 1000, nu = 1))
Squared Error (Regression)
Loss function: (y - f)^2
Number of boosting iterations: mstop = 1000
Step size: 1
Offset: 0
Coefficients:
(Intercept) speed
-17.58 3.93
attr(,"offset")
[1] 0
> plot(cars.gb)
>
> ### coefficients should coincide
> cf <- coef(cars.gb)
> attr(cf, "offset") <- NULL
> print(.all.equal(cf, coef(lm(dist ~ speed, data = cars))))
[1] TRUE
>
> ### check aggregate = "none"
> print(.all.equal(cumsum(c(coef(cars.gb, aggregate = "none", off2int = TRUE)$speed)),
+ c(coef(cars.gb, aggregate = "cumsum", off2int = TRUE)$speed)))
[1] TRUE
Warning message:
In coef.glmboost(cars.gb, aggregate = "none", off2int = TRUE) :
'off2int = TRUE' ignored for 'aggregate = "none"'
>
> ### extract model terms
> print(.all.equal(extract(cars.gb, what = "design"),
+ matrix(c(rep(1, 50), cars$speed)),
+ check.attributes = FALSE))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "design", which = "(Intercept)"),
+ rep(1, 50), check.attributes = FALSE))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "coefficients"), coef(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "residuals"), resid(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "variable.names"), variable.names(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "offset"), 0))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "nuisance"), nuisance(cars.gb)))
[1] TRUE
> print(is.na(extract(cars.gb, what = "nuisance")))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "weights"), model.weights(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "control"), boost_control(mstop = 1000, nu = 1)))
[1] TRUE
>
> ### logistic regression
> mydf <- data.frame(x = runif(100), z = rnorm(100),
+ y = factor(c(rep(0, 30), rep(1, 70))))
> bmod <- glmboost(y ~ x + z, data = mydf, family = Binomial(), center = FALSE,
+ control = boost_control(mstop = 1000, nu = 1))
> gmod <- glm(y ~ x + z, data = mydf, family = binomial())
> llg <- logLik(gmod)
> attributes(llg) <- NULL
> print(.all.equal(logLik(bmod), llg))
[1] TRUE
> print(max(abs(predict(gmod, type = "link")/2 - fitted(bmod))) <
+ sqrt(.Machine$double.eps))
[1] TRUE
> cfb <- coef(bmod, off2int = TRUE) * 2
NOTE: Coefficients from a Binomial model are half the size of coefficients
from a model fitted via glm(... , family = 'binomial').
See Warning section in ?coef.mboost
> print(.all.equal(cfb, coef(gmod)))
[1] TRUE
> aic <- AIC(bmod, "classical")
> print(abs(AIC(gmod) - attr(aic, "AIC")[mstop(bmod)]) < 1e-5)
[1] TRUE
>
> ### weighted least squares problem
>
> x <- runif(100)
> df <- data.frame(y = 2 + 3 * x + rnorm(length(x)),
+ x = x, z = runif(length(x)),
+ w = runif(length(x)) * 10)
>
> ### linear model, classical fit
> lmmod <- lm(y ~ x + z, data = df, weights = w)
>
> ### linear model, boosting fit
> lmb <- glmboost(y ~ x + z, data = df, weights = df$w, center = FALSE,
+ control = boost_control(mstop = 5000, nu = 1))
>
> ### compare fitted values
> print(max(abs(fitted(lmmod) -fitted(lmb))) < sqrt(.Machine$double.eps))
[1] TRUE
>
> ### compare hat matrices
> print(max(abs(hatvalues(lmmod) - hatvalues(lmb))) < sqrt(.Machine$double.eps))
[1] TRUE
>
> ### compare boosting hat matrix with fitted values
> print(max(abs(attr(hatvalues(lmb), "hatmatrix") %*% (df$y - lmb$offset) + lmb$offset -
+ fitted(lmb))) < sqrt(.Machine$double.eps))
[1] TRUE
>
> ### Cox model (check for CoxPH family)
> if (require("survival")) {
+
+ test <- data.frame(time = c(1, 2, 5, 2, 1, 7, 3, 4, 8, 8),
+ event = c(1, 1, 1, 1, 1, 1, 1, 0, 0, 0),
+ x = c(1, 0, 0, 1, 0, 1, 1, 1, 0, 0))
+
+ print(.all.equal(coef(cx <- coxph(Surv(time, event) ~ x, data = test, method = "breslow")),
+ coef(gl <- glmboost(Surv(time, event) ~ x, data = test,
+ family = CoxPH(), center = FALSE,
+ control = boost_control(mstop = 2000, nu = 1)), which = 1:2)[2]))
+
+ print(.all.equal(cx$loglik[2], logLik(gl)))
+
+ indx <- c(1, 1, 1, 2:10)
+ w <- tabulate(indx)
+
+ print(.all.equal(coef(cx <- coxph(Surv(time, event) ~ x, data = test, weights = w,
+ method = "breslow")),
+ coef(gl <- glmboost(Surv(time, event) ~ x, data = test, weights = w,
+ family = CoxPH(), center = FALSE,
+ control = boost_control(mstop = 200, nu = 1)), which = 1:2)[2]))
+
+ print(.all.equal(cx$loglik[2], logLik(gl)))
+
+ indx <- c(1, 1, 1, 3:10)
+ w <- tabulate(indx)
+
+ print(.all.equal(coef(cx <- coxph(Surv(time, event) ~ x, data = test[indx,],
+ method = "breslow")),
+ coef(gl <- glmboost(Surv(time, event) ~ x, data = test, weights = w,
+ family = CoxPH(), center = FALSE,
+ control = boost_control(mstop = 1000)), which = 1:2)[2], tolerance = .Machine$double.eps ^ 0.125))
+
+ print(.all.equal(cx$loglik[2], logLik(gl)))
+ }
Loading required package: survival
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
>
>
> ## Cox model with predictions obtained from survFit function
>
> fm <- Surv(futime,fustat) ~ age + resid.ds + rx + ecog.ps - 1
> ## no need to drop the intercept here:
> fmSurv <- Surv(futime,fustat) ~ age + resid.ds + rx + ecog.ps
> fit <- coxph(fmSurv, data = ovarian)
> fit2 <- glmboost(fm, data = ovarian, family = CoxPH(),
+ control=boost_control(mstop = 1000), center = TRUE)
Warning message:
In glmboost.formula(fm, data = ovarian, family = CoxPH(), control = boost_control(mstop = 1000), :
model with centered covariates does not contain intercept
> fit3 <- glmboost(fm, data = ovarian, family = CoxPH(),
+ control=boost_control(mstop = 1000), center = FALSE)
>
> A1 <- survfit(fit, censor = FALSE)
Error in a$specials[[i]] : subscript out of bounds
Calls: survfit ... survfit.coxph -> model.matrix.coxph -> delete.response -> off
Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang
Version: 2.9-14
Check: tests
Result: ERROR
Running ‘birds_Biometrics.R’ [10s/21s]
Comparing ‘birds_Biometrics.Rout’ to ‘birds_Biometrics.Rout.save’ ... OK
Running ‘bugfixes.R’ [47s/101s]
Comparing ‘bugfixes.Rout’ to ‘bugfixes.Rout.save’ ...
891c891,907
< There were 14 warnings (use warnings() to see them)
---
> Warning messages:
> 1: In bols(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 2: In bbs(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 3: In bols(z1, df = 4, contrasts.arg = "contr.dummy") :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 4: In bbs(x1, x2, df = 6) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 5: In brad(x1, x2, knots = 20) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 6: In fields::cover.design(R = unique(x), nd = knots) :
> Number of nearst neighbors (nn) reduced to the actual number of candidates
> 7: In bmono(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 8: In buser(x1, K = 1, lambda = 0) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
950,952d965
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
959,961d971
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
Running ‘regtest-baselearner.R’ [26s/59s]
Comparing ‘regtest-baselearner.Rout’ to ‘regtest-baselearner.Rout.save’ ...
41,42c41,42
< Warning messages:
< 1: In bols(xn) :
---
> Warning message:
> In bols(xn) :
44d43
< 2: object length is not a multiple of subscript length
55d53
< 3: object length is not a multiple of subscript length
96,97c94,95
< Warning messages:
< 1: In bols(xn, xf) :
---
> Warning message:
> In bols(xn, xf) :
99d96
< 2: object length is not a multiple of subscript length
111d107
< 3: object length is not a multiple of subscript length
122d117
< 3: object length is not a multiple of subscript length
129,130c124,125
< Warning messages:
< 1: In bols(one, xn, lambda = 2, intercept = FALSE) :
---
> Warning message:
> In bols(one, xn, lambda = 2, intercept = FALSE) :
132d126
< 2: object length is not a multiple of subscript length
292,293c286,287
< Warning messages:
< 1: In bbs(x, df = ncol(X)) :
---
> Warning message:
> In bbs(x, df = ncol(X)) :
295d288
< 2: object length is not a multiple of subscript length
297,298c290,291
< Warning messages:
< 1: In bols(X, df = ncol(X)) :
---
> Warning message:
> In bols(X, df = ncol(X)) :
300d292
< 2: object length is not a multiple of subscript length
Running ‘regtest-blackboost.R’ [49s/95s]
Comparing ‘regtest-blackboost.Rout’ to ‘regtest-blackboost.Rout.save’ ... OK
Running ‘regtest-family.R’ [13s/24s]
Comparing ‘regtest-family.Rout’ to ‘regtest-family.Rout.save’ ... OK
Running ‘regtest-gamboost.R’ [6s/12s]
Comparing ‘regtest-gamboost.Rout’ to ‘regtest-gamboost.Rout.save’ ...
757,758d756
< Warning message:
< object length is not a multiple of subscript length
763,764d760
< Warning message:
< object length is not a multiple of subscript length
Running ‘regtest-glmboost.R’
Running ‘regtest-hatmatrix.R’
Comparing ‘regtest-hatmatrix.Rout’ to ‘regtest-hatmatrix.Rout.save’ ... OK
Running ‘regtest-varimp.R’
Comparing ‘regtest-varimp.Rout’ to ‘regtest-varimp.Rout.save’ ... OK
Running the tests in ‘tests/regtest-glmboost.R’ failed.
Complete output:
>
> options(digits = 3)
>
> .all.equal <- function(...) isTRUE(all.equal(..., check.environment = FALSE))
> library("mboost")
Loading required package: parallel
Loading required package: stabs
>
> set.seed(290875)
>
> dgp <- function(n = 100, beta = rep(0, 10), sd = 1) {
+ p <- length(beta) - 1
+ x <- cbind(1, matrix(runif(n * p), ncol = p))
+ lp <- x %*% beta
+ y <- lp + rnorm(n, sd = sd)
+ ls <- data.frame(y = y, x[,-1])
+ attr(ls, "lp") <- lp
+ ls
+ }
>
> ### well-defined problem
> mydf <- dgp(beta = c(1, 2.5, rep(0, 2)))
>
> ### for easy comparison with lm
> fm <- Gaussian()
> fm@offset <- function(y, w) 0
>
> mydf.gb <- glmboost(y ~ ., data = mydf, family = fm,
+ control = boost_control(mstop = 1000, nu = 1))
> mydf.lm <- lm(y ~ ., data = mydf)
>
> ### compare coefficients
> print(max(abs(coef(mydf.gb) - coef(mydf.lm))) < 1e-10)
[1] TRUE
>
> ### a little bit more difficult
> mydf <- dgp(beta = c(1, 2.5, rep(0, 38)))
>
> mydf.gb <- glmboost(y ~ ., data = mydf, family = fm,
+ control = boost_control(mstop = 1000, nu = 1))
> aic <- AIC(mydf.gb, method = "corrected")
> ht <- hatvalues(mydf.gb)
> print(mstop(aic) == 12)
[1] TRUE
> plot(aic, ylim = c(0,3))
> mydf.lm <- lm(y ~ ., data = mydf)
>
> ## use AIC with active set as df
> aic2 <- AIC(mydf.gb, method = "corrected", df = "actset")
> print(mstop(aic2)== 9)
[1] TRUE
> print(attr(aic2, "df")[9] == 9)
[1] TRUE
>
> ## use gMDL
> aic3 <- AIC(mydf.gb, method = "gMDL")
> print(mstop(aic3) == 4)
[1] TRUE
>
> ### compare coefficients
> which(abs(coef(mydf.lm, which = "")) < abs(coef(mydf.gb[mstop(aic)], which = "")))
(Intercept) X1 X10 X14 X37
1 2 11 15 38
>
> #### check boosting hat matrix and subsetting / predict
> print(isTRUE(.all.equal(drop(attr(ht, "hatmatrix") %*% mydf$y),
+ as.vector(predict(mydf.gb[1000])))))
[1] TRUE
> ht25 <- hatvalues(mydf.gb[25])
> print(isTRUE(.all.equal(drop(attr(ht25, "hatmatrix") %*% mydf$y),
+ as.vector(predict(mydf.gb[25])))))
[1] TRUE
> print(isTRUE(.all.equal(drop(attr(ht25, "hatmatrix") %*% mydf$y),
+ as.vector(fitted(mydf.gb[25])))))
[1] TRUE
>
> ### a simple two-dimensional example from `glmboost.Rd'
> data("cars")
> cars.gb <- glmboost(dist ~ speed, data = cars, family = fm, center = FALSE,
+ control = boost_control(mstop = 1000, nu = 1))
> cars.gb
Generalized Linear Models Fitted via Gradient Boosting
Call:
glmboost.formula(formula = dist ~ speed, data = cars, family = fm, center = FALSE, control = boost_control(mstop = 1000, nu = 1))
Squared Error (Regression)
Loss function: (y - f)^2
Number of boosting iterations: mstop = 1000
Step size: 1
Offset: 0
Coefficients:
(Intercept) speed
-17.58 3.93
attr(,"offset")
[1] 0
> plot(cars.gb)
>
> ### coefficients should coincide
> cf <- coef(cars.gb)
> attr(cf, "offset") <- NULL
> print(.all.equal(cf, coef(lm(dist ~ speed, data = cars))))
[1] TRUE
>
> ### check aggregate = "none"
> print(.all.equal(cumsum(c(coef(cars.gb, aggregate = "none", off2int = TRUE)$speed)),
+ c(coef(cars.gb, aggregate = "cumsum", off2int = TRUE)$speed)))
[1] TRUE
Warning message:
In coef.glmboost(cars.gb, aggregate = "none", off2int = TRUE) :
'off2int = TRUE' ignored for 'aggregate = "none"'
>
> ### extract model terms
> print(.all.equal(extract(cars.gb, what = "design"),
+ matrix(c(rep(1, 50), cars$speed)),
+ check.attributes = FALSE))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "design", which = "(Intercept)"),
+ rep(1, 50), check.attributes = FALSE))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "coefficients"), coef(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "residuals"), resid(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "variable.names"), variable.names(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "offset"), 0))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "nuisance"), nuisance(cars.gb)))
[1] TRUE
> print(is.na(extract(cars.gb, what = "nuisance")))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "weights"), model.weights(cars.gb)))
[1] TRUE
> print(.all.equal(extract(cars.gb, what = "control"), boost_control(mstop = 1000, nu = 1)))
[1] TRUE
>
> ### logistic regression
> mydf <- data.frame(x = runif(100), z = rnorm(100),
+ y = factor(c(rep(0, 30), rep(1, 70))))
> bmod <- glmboost(y ~ x + z, data = mydf, family = Binomial(), center = FALSE,
+ control = boost_control(mstop = 1000, nu = 1))
> gmod <- glm(y ~ x + z, data = mydf, family = binomial())
> llg <- logLik(gmod)
> attributes(llg) <- NULL
> print(.all.equal(logLik(bmod), llg))
[1] TRUE
> print(max(abs(predict(gmod, type = "link")/2 - fitted(bmod))) <
+ sqrt(.Machine$double.eps))
[1] TRUE
> cfb <- coef(bmod, off2int = TRUE) * 2
NOTE: Coefficients from a Binomial model are half the size of coefficients
from a model fitted via glm(... , family = 'binomial').
See Warning section in ?coef.mboost
> print(.all.equal(cfb, coef(gmod)))
[1] TRUE
> aic <- AIC(bmod, "classical")
> print(abs(AIC(gmod) - attr(aic, "AIC")[mstop(bmod)]) < 1e-5)
[1] TRUE
>
> ### weighted least squares problem
>
> x <- runif(100)
> df <- data.frame(y = 2 + 3 * x + rnorm(length(x)),
+ x = x, z = runif(length(x)),
+ w = runif(length(x)) * 10)
>
> ### linear model, classical fit
> lmmod <- lm(y ~ x + z, data = df, weights = w)
>
> ### linear model, boosting fit
> lmb <- glmboost(y ~ x + z, data = df, weights = df$w, center = FALSE,
+ control = boost_control(mstop = 5000, nu = 1))
>
> ### compare fitted values
> print(max(abs(fitted(lmmod) -fitted(lmb))) < sqrt(.Machine$double.eps))
[1] TRUE
>
> ### compare hat matrices
> print(max(abs(hatvalues(lmmod) - hatvalues(lmb))) < sqrt(.Machine$double.eps))
[1] TRUE
>
> ### compare boosting hat matrix with fitted values
> print(max(abs(attr(hatvalues(lmb), "hatmatrix") %*% (df$y - lmb$offset) + lmb$offset -
+ fitted(lmb))) < sqrt(.Machine$double.eps))
[1] TRUE
>
> ### Cox model (check for CoxPH family)
> if (require("survival")) {
+
+ test <- data.frame(time = c(1, 2, 5, 2, 1, 7, 3, 4, 8, 8),
+ event = c(1, 1, 1, 1, 1, 1, 1, 0, 0, 0),
+ x = c(1, 0, 0, 1, 0, 1, 1, 1, 0, 0))
+
+ print(.all.equal(coef(cx <- coxph(Surv(time, event) ~ x, data = test, method = "breslow")),
+ coef(gl <- glmboost(Surv(time, event) ~ x, data = test,
+ family = CoxPH(), center = FALSE,
+ control = boost_control(mstop = 2000, nu = 1)), which = 1:2)[2]))
+
+ print(.all.equal(cx$loglik[2], logLik(gl)))
+
+ indx <- c(1, 1, 1, 2:10)
+ w <- tabulate(indx)
+
+ print(.all.equal(coef(cx <- coxph(Surv(time, event) ~ x, data = test, weights = w,
+ method = "breslow")),
+ coef(gl <- glmboost(Surv(time, event) ~ x, data = test, weights = w,
+ family = CoxPH(), center = FALSE,
+ control = boost_control(mstop = 200, nu = 1)), which = 1:2)[2]))
+
+ print(.all.equal(cx$loglik[2], logLik(gl)))
+
+ indx <- c(1, 1, 1, 3:10)
+ w <- tabulate(indx)
+
+ print(.all.equal(coef(cx <- coxph(Surv(time, event) ~ x, data = test[indx,],
+ method = "breslow")),
+ coef(gl <- glmboost(Surv(time, event) ~ x, data = test, weights = w,
+ family = CoxPH(), center = FALSE,
+ control = boost_control(mstop = 1000)), which = 1:2)[2], tolerance = .Machine$double.eps ^ 0.125))
+
+ print(.all.equal(cx$loglik[2], logLik(gl)))
+ }
Loading required package: survival
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
>
>
> ## Cox model with predictions obtained from survFit function
>
> fm <- Surv(futime,fustat) ~ age + resid.ds + rx + ecog.ps - 1
> ## no need to drop the intercept here:
> fmSurv <- Surv(futime,fustat) ~ age + resid.ds + rx + ecog.ps
> fit <- coxph(fmSurv, data = ovarian)
> fit2 <- glmboost(fm, data = ovarian, family = CoxPH(),
+ control=boost_control(mstop = 1000), center = TRUE)
Warning message:
In glmboost.formula(fm, data = ovarian, family = CoxPH(), control = boost_control(mstop = 1000), :
model with centered covariates does not contain intercept
> fit3 <- glmboost(fm, data = ovarian, family = CoxPH(),
+ control=boost_control(mstop = 1000), center = FALSE)
>
> A1 <- survfit(fit, censor = FALSE)
Error in a$specials[[i]] : subscript out of bounds
Calls: survfit ... survfit.coxph -> model.matrix.coxph -> delete.response -> off
Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc
Version: 2.9-14
Flags: --no-vignettes
Check: tests
Result: NOTE
Running 'birds_Biometrics.R' [15s]
Comparing 'birds_Biometrics.Rout' to 'birds_Biometrics.Rout.save' ... OK
Running 'bugfixes.R' [62s]
Comparing 'bugfixes.Rout' to 'bugfixes.Rout.save' ...
891c891,907
< There were 14 warnings (use warnings() to see them)
---
> Warning messages:
> 1: In bols(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 2: In bbs(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 3: In bols(z1, df = 4, contrasts.arg = "contr.dummy") :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 4: In bbs(x1, x2, df = 6) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 5: In brad(x1, x2, knots = 20) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 6: In fields::cover.design(R = unique(x), nd = knots) :
> Number of nearst neighbors (nn) reduced to the actual number of candidates
> 7: In bmono(x1) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
> 8: In buser(x1, K = 1, lambda = 0) :
> base-learner contains missing values; missing values are excluded per base-learner, i.e., base-learners may depend on different numbers of observations.
950,952d965
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
959,961d971
< Warning messages:
< 1: object length is not a multiple of subscript length
< 2: object length is not a multiple of subscript length
Running 'regtest-baselearner.R' [38s]
Comparing 'regtest-baselearner.Rout' to 'regtest-baselearner.Rout.save' ...
41,42c41,42
< Warning messages:
< 1: In bols(xn) :
---
> Warning message:
> In bols(xn) :
44d43
< 2: object length is not a multiple of subscript length
55d53
< 3: object length is not a multiple of subscript length
96,97c94,95
< Warning messages:
< 1: In bols(xn, xf) :
---
> Warning message:
> In bols(xn, xf) :
99d96
< 2: object length is not a multiple of subscript length
111d107
< 3: object length is not a multiple of subscript length
122d117
< 3: object length is not a multiple of subscript length
129,130c124,125
< Warning messages:
< 1: In bols(one, xn, lambda = 2, intercept = FALSE) :
---
> Warning message:
> In bols(one, xn, lambda = 2, intercept = FALSE) :
132d126
< 2: object length is not a multiple of subscript length
292,293c286,287
< Warning messages:
< 1: In bbs(x, df = ncol(X)) :
---
> Warning message:
> In bbs(x, df = ncol(X)) :
295d288
< 2: object length is not a multiple of subscript length
297,298c290,291
< Warning messages:
< 1: In bols(X, df = ncol(X)) :
---
> Warning message:
> In bols(X, df = ncol(X)) :
300d292
< 2: object length is not a multiple of subscript length
Running 'regtest-blackboost.R' [55s]
Comparing 'regtest-blackboost.Rout' to 'regtest-blackboost.Rout.save' ... OK
Running 'regtest-family.R' [18s]
Comparing 'regtest-family.Rout' to 'regtest-family.Rout.save' ... OK
Running 'regtest-gamboost.R' [7s]
Comparing 'regtest-gamboost.Rout' to 'regtest-gamboost.Rout.save' ...
757,758d756
< Warning message:
< object length is not a multiple of subscript length
763,764d760
< Warning message:
< object length is not a multiple of subscript length
Running 'regtest-glmboost.R' [12s]
Comparing 'regtest-glmboost.Rout' to 'regtest-glmboost.Rout.save' ... OK
Running 'regtest-hatmatrix.R' [2s]
Comparing 'regtest-hatmatrix.Rout' to 'regtest-hatmatrix.Rout.save' ... OK
Running 'regtest-varimp.R' [3s]
Comparing 'regtest-varimp.Rout' to 'regtest-varimp.Rout.save' ... OK
Flavor: r-devel-windows-x86_64