
> source("setup.R")
Loading required package: parallel
Loading required package: stabs


	%%%% DON'T EDIT THIS FILE

\setkeys{Gin}{width = 0.95\textwidth}
> bf_lm <- lm(DEXfat ~ hipcirc + kneebreadth + anthro3a, 
+     data = bodyfat)

> coef(bf_lm)
(Intercept)     hipcirc kneebreadth    anthro3a 
  -75.23478     0.51153     1.90199     8.90964 

> bf_glm <- glmboost(DEXfat ~ ., data = bodyfat, center = TRUE)

> coef(bf_glm)
 (Intercept)          age    waistcirc      hipcirc 
  -98.816608     0.013602     0.189716     0.351626 
elbowbreadth  kneebreadth     anthro3a     anthro3b 
   -0.384140     1.736589     3.326860     3.656524 
    anthro3c 
    0.595363 
attr(,"offset")
[1] 30.783

> load(system.file("cache/bodyfat_benchmarks.rda", package = "mboost"))

> aic <- AIC(bf_glm)

> pdf("figures/bodyfat_glmboost-bodyfat-oob-plot.pdf", 
+     version = "1.4", width = 6, height = 10)

> par(mai = par("mai") * c(1, 1, 0.5, 1))

> mopt <- grid[which.min(colMeans(boob))]

> layout(matrix(1:2, nrow = 2))

> perfplot(boob, grid, ylab = "Out-of-bootstrap squared error", 
+     xlab = "Number of boosting iterations", alpha = 0.05)

> abline(h = mean(boobrest), lty = 2)

> lines(c(which.min(colMeans(boob)), which.min(colMeans(boob))), 
+     c(0, min(colMeans(boob))), lty = 2)

> points(which.min(colMeans(boob)), min(colMeans(boob)))

> plot(aic, ylim = c(3, 5.5))

> dev.off()
null device 
          1 

> mstop(aic <- AIC(bf_glm))
[1] 45

> coef(bf_glm[mstop(aic)])
(Intercept)         age   waistcirc     hipcirc kneebreadth 
-97.8458288   0.0023271   0.1893046   0.3488781   1.5217686 
   anthro3a    anthro3b    anthro3c 
  3.3268603   3.6051548   0.5043133 
attr(,"offset")
[1] 30.783

> cf <- coef(bf_glm[mopt])

> nsel <- length(cf)

> source("setup.R")


	%%%% DON'T EDIT THIS FILE

\setkeys{Gin}{width = 0.95\textwidth}
> bf_gam <- gamboost(DEXfat ~ ., data = bodyfat, baselearner = "bss")
Warning in gamboost(DEXfat ~ ., data = bodyfat, baselearner = "bss") :
  bss and bns are deprecated, bbs is used instead

> mstop(aic <- AIC(bf_gam))
[1] 51

> bf_gam <- bf_gam[mstop(aic)]

> layout(matrix(1:4, ncol = 2))

> plot(bf_gam, which = c("hipcirc", "kneebreadth", "waistcirc", 
+     "anthro3b"))

> source("setup.R")


	%%%% DON'T EDIT THIS FILE

\setkeys{Gin}{width = 0.95\textwidth}
> library("splines")

> indep <- names(bodyfat)[names(bodyfat) != "DEXfat"]

> bsfm <- as.formula(paste("DEXfat ~ ", paste("bs(", 
+     indep, ")", collapse = " + ", sep = ""), sep = ""))

> bsfm
DEXfat ~ bs(age) + bs(waistcirc) + bs(hipcirc) + bs(elbowbreadth) + 
    bs(kneebreadth) + bs(anthro3a) + bs(anthro3b) + bs(anthro3c) + 
    bs(anthro4)

> ctrl <- boost_control(mstop = 5000)

> bf_bs <- glmboost(bsfm, data = bodyfat, control = ctrl)

> mstop(aic <- AIC(bf_bs))
[1] 136

> layout(matrix(1:4, ncol = 2, byrow = TRUE))

> par(mai = par("mai") * c(1, 1, 0.5, 1))

> cf <- coef(bf_bs[mstop(aic)])

> varorder <- c("hipcirc", "waistcirc", "kneebreadth", 
+     "anthro3b")

> fpartial <- sapply(varorder, function(v) {
+     rowSums(predict(bf_bs, which = v))
+ })

> out <- sapply(varorder, function(i) {
+     x <- bodyfat[, i]
+     plot(sort(x), fpartial[order(x), i], main = "", type = "b", 
+         xlab = i, .... [TRUNCATED] 

> source("setup.R")


	%%%% DON'T EDIT THIS FILE

\setkeys{Gin}{width = 0.95\textwidth}
> data("Westbc", package = "TH.data")

> westbc <- Westbc

> exprs <- function(x) x$assay

> pData <- function(x) x$pheno

> p <- nrow(exprs(westbc))

> n <- ncol(exprs(westbc))

> ytab <- table(pData(westbc)$nodal.y)

> x <- t(exprs(westbc))

> y <- pData(westbc)$nodal.y

> yfit <- as.numeric(y) - 1

> rho <- function(y, f, w = 1) {
+     p <- pmax(pmin(1 - 1e-05, f), 1e-05)
+     -y * log(p) - (1 - y) * log(1 - p)
+ }

> ngradient <- function(y, f, w = 1) y - f

> offset <- function(y, w) weighted.mean(y, w)

> L2fm <- Family(ngradient = ngradient, loss = rho, 
+     offset = offset)

> time <- system.time(west_glm <- glmboost(x, yfit, 
+     family = L2fm, center = TRUE, control = boost_control(mstop = 200)))[1]
Warning in glmboost.matrix(x, yfit, family = L2fm, center = TRUE, control = boost_control(mstop = 200)) :
  model with centered covariates does not contain intercept

> x <- t(exprs(westbc) - rowMeans(exprs(westbc)))

> aic <- AIC(west_glm, method = "classical")
Warning in hatvalues.gamboost(model) :
  AIC might not be reasonable for family user-specified

> mstop(aic)
[1] 100

> cf <- coef(west_glm[mstop(aic)], which = 1:ncol(x))

> ps <- length(cf[abs(cf) > 0])

> sdx <- sqrt(rowSums((t(x) - colMeans(x))^2)/(nrow(x) - 
+     1))

> layout(matrix(1:2, ncol = 2))

> cf <- cf * sdx

> plot(sort(cf[abs(cf) > 0]), ylab = "Standardized coefficients")

> abline(h = 0, lty = 2)

> plot(aic, ylim = c(25, 40))

> source("setup.R")


	%%%% DON'T EDIT THIS FILE

\setkeys{Gin}{width = 0.95\textwidth}
> n <- sum(complete.cases(wpbc))

> p <- ncol(wpbc) - 2

> cc <- complete.cases(wpbc)

> wpbc2 <- wpbc[cc, colnames(wpbc) != "time"]

> wpbc_step <- step(glm(status ~ ., data = wpbc2, family = binomial()), 
+     trace = 0)

> logLik(wpbc_step)
'log Lik.' -80.13 (df=16)

> AIC(wpbc_step)
[1] 192.26

> ctrl <- boost_control(mstop = 500)

> wpbc_glm <- glmboost(status ~ ., data = wpbc2, family = Binomial(), 
+     center = TRUE, control = ctrl)

> aic <- AIC(wpbc_glm, "classical")

> aic
[1] 198.44
Optimal number of boosting iterations: 260 
Degrees of freedom (for mstop = 260): 7.0319 

> wpbc_glm <- wpbc_glm[mstop(aic)]

> coef(wpbc_glm)[abs(coef(wpbc_glm)) > 0]

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


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

     (Intercept)     mean_texture    mean_symmetry 
      2.3013e-01      -2.4215e-02      -3.3878e+00 
 mean_fractaldim       SE_texture     SE_perimeter 
     -2.0321e+01      -2.6603e-02       4.0908e-02 
  SE_compactness     SE_concavity SE_concavepoints 
      7.0280e+00      -4.6303e+00      -1.5737e+01 
     SE_symmetry     worst_radius  worst_perimeter 
      2.8601e+00       1.7777e-02       1.2639e-03 
      worst_area worst_smoothness            tsize 
      1.5854e-04       8.8372e+00       3.1014e-02 
          pnodes 
      2.5981e-02 

> wpbc_gam <- gamboost(status ~ ., data = wpbc2, family = Binomial(), 
+     baselearner = "bss")
Warning in gamboost(status ~ ., data = wpbc2, family = Binomial(), baselearner = "bss") :
  bss and bns are deprecated, bbs is used instead

> mopt <- mstop(aic <- AIC(wpbc_gam, "classical"))

> aic
[1] 196.16
Optimal number of boosting iterations: 86 
Degrees of freedom (for mstop = 86): 11.348 

> wpbc_gam <- wpbc_gam[mopt]

> fpartial <- predict(wpbc_gam, which = 1:length(variable.names(wpbc_gam)))

> layout(matrix(1:4, nrow = 2, byrow = TRUE))

> par(mai = par("mai") * c(1, 1, 0.5, 1))

> plot(wpbc_gam, which = rev(order(colMeans(abs(fpartial))))[1:4])

> source("setup.R")


	%%%% DON'T EDIT THIS FILE

\setkeys{Gin}{width = 0.95\textwidth}
> library("survival")

> censored <- wpbc$status == "R"

> iw <- IPCweights(Surv(wpbc$time, censored))

> wpbc3 <- wpbc[, names(wpbc) != "status"]

> ctrl <- boost_control(mstop = 500)

> wpbc_surv <- glmboost(log(time) ~ ., data = wpbc3, 
+     weights = iw, center = TRUE, control = ctrl)

> mstop(aic <- AIC(wpbc_surv))
[1] 106

> wpbc_surv <- wpbc_surv[mstop(aic)]

> names(coef(wpbc_surv)[abs(coef(wpbc_surv)) > 0])
 [1] "(Intercept)"         "mean_radius"        
 [3] "mean_texture"        "mean_smoothness"    
 [5] "mean_symmetry"       "SE_texture"         
 [7] "SE_smoothness"       "SE_concavepoints"   
 [9] "SE_symmetry"         "worst_concavepoints"
[11] "pnodes"             

> plot(log(wpbc3$time), predict(wpbc_surv, newdata = wpbc3), 
+     cex = iw, ylim = c(0, 5), xlim = c(0, 5), xlab = "Time to recurrence (log-scale)", .... [TRUNCATED] 

> abline(a = 0, b = 1, lty = 2, lwd = 0.5)

> thisdir <- getwd()

> bibfile <- system.file("REFERENCES.bib", package = "mboost")

> if (file.copy(bibfile, to = thisdir, overwrite = TRUE)) {
+     bibfile <- "REFERENCES.bib"
+ } else {
+     bibfile <- file.path("..", "inst", "REF ..." ... [TRUNCATED] 

 *** Run successfully completed ***
> proc.time()
   user  system elapsed 
  4.310   0.123   4.440 
