[Mboost-commits] r732 - in pkg/mboostPatch: . inst man tests tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 5 17:51:33 CEST 2013
Author: hofner
Date: 2013-09-05 17:51:32 +0200 (Thu, 05 Sep 2013)
New Revision: 732
Modified:
pkg/mboostPatch/DESCRIPTION
pkg/mboostPatch/inst/CHANGES
pkg/mboostPatch/man/mboost_package.Rd
pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save
pkg/mboostPatch/tests/birds_Biometrics.Rout.save
pkg/mboostPatch/tests/bugfixes.Rout.save
pkg/mboostPatch/tests/regtest-baselearner.Rout.save
pkg/mboostPatch/tests/regtest-blackboost.Rout.save
pkg/mboostPatch/tests/regtest-family.Rout.save
pkg/mboostPatch/tests/regtest-gamboost.Rout.save
pkg/mboostPatch/tests/regtest-glmboost.Rout.save
pkg/mboostPatch/tests/regtest-hatmatrix.Rout.save
Log:
- prepare release candidate for 2.2-3
- updated dates
- updated .Rout.save files
Modified: pkg/mboostPatch/DESCRIPTION
===================================================================
--- pkg/mboostPatch/DESCRIPTION 2013-09-05 14:59:24 UTC (rev 731)
+++ pkg/mboostPatch/DESCRIPTION 2013-09-05 15:51:32 UTC (rev 732)
@@ -1,7 +1,7 @@
Package: mboost
Title: Model-Based Boosting
Version: 2.2-3
-Date: 2013-XX-XX
+Date: 2013-09-05
Authors at R: c(person("Torsten", "Hothorn", role = c("aut", "cre"),
email = "Torsten.Hothorn at R-project.org"),
person("Peter", "Buehlmann", role = "aut"),
Modified: pkg/mboostPatch/inst/CHANGES
===================================================================
--- pkg/mboostPatch/inst/CHANGES 2013-09-05 14:59:24 UTC (rev 731)
+++ pkg/mboostPatch/inst/CHANGES 2013-09-05 15:51:32 UTC (rev 732)
@@ -1,4 +1,4 @@
- CHANGES in `mboost' VERSION 2.2-3 (2013-XX-XX, rYYY)
+ CHANGES in `mboost' VERSION 2.2-3 (2013-09-05, rYYY)
o fixed bugs in survival families:
- offset in all survival families was based on max(survtime) instead
@@ -9,6 +9,8 @@
o speed up checking of manual by changing some computations (e.g. reduce
mstop) or exclude code from checking via \dontrun{}
+ o removed dependency on ipred (replaced with TH.data)
+
o small improvements in manual
Modified: pkg/mboostPatch/man/mboost_package.Rd
===================================================================
--- pkg/mboostPatch/man/mboost_package.Rd 2013-09-05 14:59:24 UTC (rev 731)
+++ pkg/mboostPatch/man/mboost_package.Rd 2013-09-05 15:51:32 UTC (rev 732)
@@ -16,7 +16,7 @@
Package: \tab mboost\cr
Type: \tab Package\cr
Version: \tab 2.2-3\cr
-Date: \tab 2013-XX-XX\cr
+Date: \tab 2013-09-05\cr
License: \tab GPL-2\cr
LazyLoad: \tab yes\cr
LazyData: \tab yes\cr
@@ -58,17 +58,17 @@
\code{options(mboost_dftraceS = TRUE)} (see also B. Hofner et al.,
2011 and \code{\link{bols}}).
- Other important changes inlclude:
- \itemize{
+ Other important changes inlclude:
+ \itemize{
\item We switched from packages \code{multicore} and \code{snow} to
\code{parallel}
-
+
\item We changed the behavior of \code{bols(x, intercept = FALSE)}
when \code{x} is a factor: now the intercept is simply dropped from
the design matrix and the coding can be specified as usually for
factors. Addtionally, a new contrast is introduced:
\code{"contr.dummy"} (see \code{\link{bols}} for details).
-
+
\item We changed the computation of B-spline basis at the
boundaries; B-splines now also use equidistant knots in the
boundaries (per default).
@@ -88,7 +88,7 @@
Starting from this version, we now also automatically center the
variables in \code{\link{glmboost}} (argument \code{center = TRUE}).
- A complete list of changes can be found in the NEWS file.
+ A complete list of changes can be found in the NEWS file.
}
\section{NEWS in 2.0-series}{
Modified: pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save
===================================================================
--- pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save 2013-09-05 14:59:24 UTC (rev 731)
+++ pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save 2013-09-05 15:51:32 UTC (rev 732)
@@ -1,7 +1,6 @@
-R version 2.15.2 (2012-10-26) -- "Trick or Treat"
-Copyright (C) 2012 The R Foundation for Statistical Computing
-ISBN 3-900051-07-0
+R version 3.0.1 (2013-05-16) -- "Good Sport"
+Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -23,12 +22,14 @@
> options(warn = 1)
> library('mboost')
Loading required package: parallel
-This is mboost 2.2-2. See ‘package?mboost’ and the NEWS file
+Loading required package: survival
+Loading required package: splines
+This is mboost 2.2-3. See ‘package?mboost’ and the NEWS file
for a complete list of changes.
Note: The default for the computation of the degrees of freedom has changed.
For details see section ‘Global Options’ of ‘?bols’.
>
-> assign(".oldSearch", search(), pos = 'CheckExEnv')
+> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("FP")
> ### * FP
@@ -205,43 +206,95 @@
>
> ### set up base-learners
> spline1 <- bbs(x1, knots = 20, df = 4)
-> attributes(spline1)
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_vary"
-[6] "get_names" "set_names" "dpp"
-
-$class
-[1] "blg"
-
->
+> extract(spline1, "design")[1:10, 1:10]
+ 1 2 3 4 5 6 7 8 9
+ [1,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.000000000
+ [2,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.000000000
+ [3,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.000000000
+ [4,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.000000000
+ [5,] 0 0 0 0 0.01490533 0.44554054 5.113987e-01 0.028155480 0.000000000
+ [6,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.000000000
+ [7,] 0 0 0 0 0.00000000 0.06481227 6.035695e-01 0.328334430 0.003283771
+ [8,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.000000000 0.000000000
+ [9,] 0 0 0 0 0.00000000 0.00000000 1.551197e-09 0.167720617 0.666662247
+[10,] 0 0 0 0 0.00000000 0.00000000 0.000000e+00 0.009196839 0.401902997
+ 10
+ [1,] 0.0000000
+ [2,] 0.0000000
+ [3,] 0.0000000
+ [4,] 0.0000000
+ [5,] 0.0000000
+ [6,] 0.0000000
+ [7,] 0.0000000
+ [8,] 0.0000000
+ [9,] 0.1656171
+[10,] 0.5493155
+> extract(spline1, "penalty")
+ [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
+ [1,] 1 -2 1 0 0 0 0 0 0 0 0 0 0
+ [2,] -2 5 -4 1 0 0 0 0 0 0 0 0 0
+ [3,] 1 -4 6 -4 1 0 0 0 0 0 0 0 0
+ [4,] 0 1 -4 6 -4 1 0 0 0 0 0 0 0
+ [5,] 0 0 1 -4 6 -4 1 0 0 0 0 0 0
+ [6,] 0 0 0 1 -4 6 -4 1 0 0 0 0 0
+ [7,] 0 0 0 0 1 -4 6 -4 1 0 0 0 0
+ [8,] 0 0 0 0 0 1 -4 6 -4 1 0 0 0
+ [9,] 0 0 0 0 0 0 1 -4 6 -4 1 0 0
+[10,] 0 0 0 0 0 0 0 1 -4 6 -4 1 0
+[11,] 0 0 0 0 0 0 0 0 1 -4 6 -4 1
+[12,] 0 0 0 0 0 0 0 0 0 1 -4 6 -4
+[13,] 0 0 0 0 0 0 0 0 0 0 1 -4 6
+[14,] 0 0 0 0 0 0 0 0 0 0 0 1 -4
+[15,] 0 0 0 0 0 0 0 0 0 0 0 0 1
+[16,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[17,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[18,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[19,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[20,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[21,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[22,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[23,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+[24,] 0 0 0 0 0 0 0 0 0 0 0 0 0
+ [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
+ [1,] 0 0 0 0 0 0 0 0 0 0 0
+ [2,] 0 0 0 0 0 0 0 0 0 0 0
+ [3,] 0 0 0 0 0 0 0 0 0 0 0
+ [4,] 0 0 0 0 0 0 0 0 0 0 0
+ [5,] 0 0 0 0 0 0 0 0 0 0 0
+ [6,] 0 0 0 0 0 0 0 0 0 0 0
+ [7,] 0 0 0 0 0 0 0 0 0 0 0
+ [8,] 0 0 0 0 0 0 0 0 0 0 0
+ [9,] 0 0 0 0 0 0 0 0 0 0 0
+[10,] 0 0 0 0 0 0 0 0 0 0 0
+[11,] 0 0 0 0 0 0 0 0 0 0 0
+[12,] 1 0 0 0 0 0 0 0 0 0 0
+[13,] -4 1 0 0 0 0 0 0 0 0 0
+[14,] 6 -4 1 0 0 0 0 0 0 0 0
+[15,] -4 6 -4 1 0 0 0 0 0 0 0
+[16,] 1 -4 6 -4 1 0 0 0 0 0 0
+[17,] 0 1 -4 6 -4 1 0 0 0 0 0
+[18,] 0 0 1 -4 6 -4 1 0 0 0 0
+[19,] 0 0 0 1 -4 6 -4 1 0 0 0
+[20,] 0 0 0 0 1 -4 6 -4 1 0 0
+[21,] 0 0 0 0 0 1 -4 6 -4 1 0
+[22,] 0 0 0 0 0 0 1 -4 6 -4 1
+[23,] 0 0 0 0 0 0 0 1 -4 5 -2
+[24,] 0 0 0 0 0 0 0 0 1 -2 1
> knots.x2 <- quantile(x2, c(0.25, 0.5, 0.75))
> spline2 <- bbs(x2, knots = knots.x2, df = 5)
-> attributes(spline2)
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_vary"
-[6] "get_names" "set_names" "dpp"
+> ols3 <- bols(x3)
+> extract(ols3)
+ (Intercept) x31
+1 1 0
+3 1 1
+attr(,"assign")
+[1] 0 1
+attr(,"contrasts")
+attr(,"contrasts")$x3
+[1] "contr.treatment"
-$class
-[1] "blg"
-
+> ols4 <- bols(x4)
>
-> attributes(ols3 <- bols(x3))
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_names"
-[6] "get_vary" "set_names" "dpp"
-
-$class
-[1] "blg"
-
-> attributes(ols4 <- bols(x4))
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_names"
-[6] "get_vary" "set_names" "dpp"
-
-$class
-[1] "blg"
-
->
> ### compute base-models
> drop(ols3$dpp(weights)$fit(y)$model) ## same as:
(Intercept) x31
@@ -264,8 +317,8 @@
> mod2 <- mboost(y ~ bbs(x1, knots = 20, df = 4) +
+ bbs(x2, knots = knots.x2, df = 5) +
+ bols(x3) + bols(x4), weights = weights)
-> all.equal(coef(mod1), coef(mod2))
-[1] "names for current but not for target"
+> all.equal(coef(mod1), coef(mod2), check.attributes = FALSE)
+[1] TRUE
>
>
> ### grouped linear effects
@@ -275,25 +328,26 @@
> model <- gamboost(y ~ bols(x1, x2, intercept = FALSE) +
+ bols(x1, intercept = FALSE) +
+ bols(x2, intercept = FALSE),
-+ control = boost_control(mstop = 400))
++ control = boost_control(mstop = 50))
> coef(model, which = 1) # one base-learner for x1 and x2
$`bols(x1, x2, intercept = FALSE)`
x1 x2
- 1.82015195 -0.02260988
+ 1.81077137 -0.02249335
attr(,"offset")
[1] 1.334042
> coef(model, which = 2:3) # two separate base-learners for x1 and x2
$`bols(x1, intercept = FALSE)`
- x1
-7.571584e-08
+x1
+ 0
$`bols(x2, intercept = FALSE)`
- x2
-2.815168e-13
+x2
+ 0
attr(,"offset")
[1] 1.334042
+> # zero because they were (not yet) selected.
>
> ### example for bspatial
> x1 <- runif(250,-pi,pi)
@@ -302,35 +356,101 @@
> y <- sin(x1) * sin(x2) + rnorm(250, sd = 0.4)
>
> spline3 <- bspatial(x1, x2, knots = 12)
-> attributes(spline3)
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_vary"
-[6] "get_names" "set_names" "dpp"
-
-$class
-[1] "blg"
-
+> Xmat <- extract(spline3, "design")
+> ## 12 inner knots + 4 boundary knots = 16 knots per direction
+> ## THUS: 16 * 16 = 256 columns
+> dim(Xmat)
+[1] 250 256
+> extract(spline3, "penalty")[1:10, 1:10]
+10 x 10 sparse Matrix of class "dgTMatrix"
+
+ [1,] 2 -2 1 . . . . . . .
+ [2,] -2 6 -4 1 . . . . . .
+ [3,] 1 -4 7 -4 1 . . . . .
+ [4,] . 1 -4 7 -4 1 . . . .
+ [5,] . . 1 -4 7 -4 1 . . .
+ [6,] . . . 1 -4 7 -4 1 . .
+ [7,] . . . . 1 -4 7 -4 1 .
+ [8,] . . . . . 1 -4 7 -4 1
+ [9,] . . . . . . 1 -4 7 -4
+[10,] . . . . . . . 1 -4 7
>
> ## specify number of knots separately
-> form2 <- y ~ bspatial(x1, x2, knots = list(x1 = 12, x2 = 12))
+> form1 <- y ~ bspatial(x1, x2, knots = list(x1 = 12, x2 = 14))
>
> ## decompose spatial effect into parametric part and
> ## deviation with one df
> form2 <- y ~ bols(x1) + bols(x2) + bols(x1, by = x2, intercept = FALSE) +
+ bspatial(x1, x2, knots = 12, center = TRUE, df = 1)
>
+> ## To speed up testing do not run this automatically.
+> ## Not run:
+> ##D mod1 <- gamboost(form1)
+> ##D plot(mod1)
+> ##D
+> ##D mod2 <- gamboost(form2)
+> ##D x11()
+> ##D ## automated plot function:
+> ##D plot(mod2)
+> ##D ## plot sum of linear and smooth effects:
+> ##D library(lattice)
+> ##D df <- expand.grid(x1 = unique(x1), x2 = unique(x2))
+> ##D df$pred <- predict(mod2, newdata = df)
+> ##D levelplot(pred ~ x1 * x2, data = df)
+> ## End(Not run)
>
+> ## specify radial basis function base-learner for spatial effect
+> ## and use data-adaptive effective range (theta = NULL, see 'args')
+> form3 <- y ~ brad(x1, x2)
+> ## Now use different settings, e.g. 50 knots and theta fixed to 0.4
+> ## (not really a good setting)
+> form4 <- y ~ brad(x1, x2, knots = 50, args = list(theta = 0.4))
+>
+> ## To speed up testing do not run this automatically.
+> ## Not run:
+> ##D mod3 <- gamboost(form3)
+> ##D plot(mod3)
+> ##D dim(extract(mod3, what = "design", which = "brad")[[1]])
+> ##D knots <- attr(extract(mod3, what = "design", which = "brad")[[1]], "knots")
+> ##D
+> ##D mod4 <- gamboost(form4)
+> ##D dim(extract(mod4, what = "design", which = "brad")[[1]])
+> ##D plot(mod4)
+> ## End(Not run)
+>
> ### random intercept
> id <- factor(rep(1:10, each = 5))
> raneff <- brandom(id)
-> attributes(raneff)
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_names"
-[6] "get_vary" "set_names" "dpp"
+> extract(raneff, "design")
+ id1 id2 id3 id4 id5 id6 id7 id8 id9 id10
+1 1 0 0 0 0 0 0 0 0 0
+6 0 1 0 0 0 0 0 0 0 0
+11 0 0 1 0 0 0 0 0 0 0
+16 0 0 0 1 0 0 0 0 0 0
+21 0 0 0 0 1 0 0 0 0 0
+26 0 0 0 0 0 1 0 0 0 0
+31 0 0 0 0 0 0 1 0 0 0
+36 0 0 0 0 0 0 0 1 0 0
+41 0 0 0 0 0 0 0 0 1 0
+46 0 0 0 0 0 0 0 0 0 1
+attr(,"assign")
+ [1] 1 1 1 1 1 1 1 1 1 1
+attr(,"contrasts")
+attr(,"contrasts")$id
+[1] "contr.dummy"
-$class
-[1] "blg"
-
+> extract(raneff, "penalty")
+ [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
+ [1,] 1 0 0 0 0 0 0 0 0 0
+ [2,] 0 1 0 0 0 0 0 0 0 0
+ [3,] 0 0 1 0 0 0 0 0 0 0
+ [4,] 0 0 0 1 0 0 0 0 0 0
+ [5,] 0 0 0 0 1 0 0 0 0 0
+ [6,] 0 0 0 0 0 1 0 0 0 0
+ [7,] 0 0 0 0 0 0 1 0 0 0
+ [8,] 0 0 0 0 0 0 0 1 0 0
+ [9,] 0 0 0 0 0 0 0 0 1 0
+[10,] 0 0 0 0 0 0 0 0 0 1
>
> ## random intercept with non-observed category
> set.seed(1907)
@@ -357,14 +477,121 @@
> ### random slope
> z <- runif(50)
> raneff <- brandom(id, by = z)
-> attributes(raneff)
-$names
-[1] "model.frame" "get_call" "get_data" "get_index" "get_names"
-[6] "get_vary" "set_names" "dpp"
-
-$class
-[1] "blg"
-
+> extract(raneff, "design")
+ id1:z id2:z id3:z id4:z id5:z id6:z id7:z
+1 0.50259942 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+2 0.05583988 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+3 0.69006339 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+4 0.81483211 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+5 0.32146322 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+6 0.00000000 0.06694633 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+7 0.00000000 0.51190172 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+8 0.00000000 0.31822576 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+9 0.00000000 0.33315184 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+10 0.00000000 0.93195969 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+11 0.00000000 0.00000000 0.7186267 0.0000000 0.0000000 0.0000000 0.0000000
+12 0.00000000 0.00000000 0.3441995 0.0000000 0.0000000 0.0000000 0.0000000
+13 0.00000000 0.00000000 0.2515360 0.0000000 0.0000000 0.0000000 0.0000000
+14 0.00000000 0.00000000 0.9205251 0.0000000 0.0000000 0.0000000 0.0000000
+15 0.00000000 0.00000000 0.3082208 0.0000000 0.0000000 0.0000000 0.0000000
+16 0.00000000 0.00000000 0.0000000 0.4106751 0.0000000 0.0000000 0.0000000
+17 0.00000000 0.00000000 0.0000000 0.5614606 0.0000000 0.0000000 0.0000000
+18 0.00000000 0.00000000 0.0000000 0.6550415 0.0000000 0.0000000 0.0000000
+19 0.00000000 0.00000000 0.0000000 0.9282509 0.0000000 0.0000000 0.0000000
+20 0.00000000 0.00000000 0.0000000 0.4750425 0.0000000 0.0000000 0.0000000
+21 0.00000000 0.00000000 0.0000000 0.0000000 0.7181429 0.0000000 0.0000000
+22 0.00000000 0.00000000 0.0000000 0.0000000 0.5509939 0.0000000 0.0000000
+23 0.00000000 0.00000000 0.0000000 0.0000000 0.9027612 0.0000000 0.0000000
+24 0.00000000 0.00000000 0.0000000 0.0000000 0.9100466 0.0000000 0.0000000
+25 0.00000000 0.00000000 0.0000000 0.0000000 0.2095783 0.0000000 0.0000000
+26 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.4098701 0.0000000
+27 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.5335995 0.0000000
+28 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.3361951 0.0000000
+29 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.9611161 0.0000000
+30 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.7673629 0.0000000
+31 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.5994378
+32 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.1352137
+33 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.2643471
+34 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.4921034
+35 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.8945813
+36 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+37 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+38 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+39 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+40 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+41 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+42 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+43 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+44 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+45 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+46 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+47 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+48 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+49 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+50 0.00000000 0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
+ id8:z id9:z id10:z
+1 0.0000000 0.00000000 0.00000000
+2 0.0000000 0.00000000 0.00000000
+3 0.0000000 0.00000000 0.00000000
+4 0.0000000 0.00000000 0.00000000
+5 0.0000000 0.00000000 0.00000000
+6 0.0000000 0.00000000 0.00000000
+7 0.0000000 0.00000000 0.00000000
+8 0.0000000 0.00000000 0.00000000
+9 0.0000000 0.00000000 0.00000000
+10 0.0000000 0.00000000 0.00000000
+11 0.0000000 0.00000000 0.00000000
+12 0.0000000 0.00000000 0.00000000
+13 0.0000000 0.00000000 0.00000000
+14 0.0000000 0.00000000 0.00000000
+15 0.0000000 0.00000000 0.00000000
+16 0.0000000 0.00000000 0.00000000
+17 0.0000000 0.00000000 0.00000000
+18 0.0000000 0.00000000 0.00000000
+19 0.0000000 0.00000000 0.00000000
+20 0.0000000 0.00000000 0.00000000
+21 0.0000000 0.00000000 0.00000000
+22 0.0000000 0.00000000 0.00000000
+23 0.0000000 0.00000000 0.00000000
+24 0.0000000 0.00000000 0.00000000
+25 0.0000000 0.00000000 0.00000000
+26 0.0000000 0.00000000 0.00000000
+27 0.0000000 0.00000000 0.00000000
+28 0.0000000 0.00000000 0.00000000
+29 0.0000000 0.00000000 0.00000000
+30 0.0000000 0.00000000 0.00000000
+31 0.0000000 0.00000000 0.00000000
+32 0.0000000 0.00000000 0.00000000
+33 0.0000000 0.00000000 0.00000000
+34 0.0000000 0.00000000 0.00000000
+35 0.0000000 0.00000000 0.00000000
+36 0.9221916 0.00000000 0.00000000
+37 0.7830943 0.00000000 0.00000000
+38 0.1455074 0.00000000 0.00000000
+39 0.5827876 0.00000000 0.00000000
+40 0.2746886 0.00000000 0.00000000
+41 0.0000000 0.02663745 0.00000000
+42 0.0000000 0.16163030 0.00000000
+43 0.0000000 0.24233143 0.00000000
+44 0.0000000 0.73402096 0.00000000
+45 0.0000000 0.77306128 0.00000000
+46 0.0000000 0.00000000 0.64768759
+47 0.0000000 0.00000000 0.58947778
+48 0.0000000 0.00000000 0.03172592
+49 0.0000000 0.00000000 0.99806980
+50 0.0000000 0.00000000 0.90622781
+> extract(raneff, "penalty")
+ [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
+ [1,] 1 0 0 0 0 0 0 0 0 0
+ [2,] 0 1 0 0 0 0 0 0 0 0
+ [3,] 0 0 1 0 0 0 0 0 0 0
+ [4,] 0 0 0 1 0 0 0 0 0 0
+ [5,] 0 0 0 0 1 0 0 0 0 0
+ [6,] 0 0 0 0 0 1 0 0 0 0
+ [7,] 0 0 0 0 0 0 1 0 0 0
+ [8,] 0 0 0 0 0 0 0 1 0 0
+ [9,] 0 0 0 0 0 0 0 0 1 0
+[10,] 0 0 0 0 0 0 0 0 0 1
>
> ### specify simple interaction model (with main effect)
> n <- 210
@@ -379,32 +606,20 @@
> plot(y ~ x, col = z)
> ## specify main effect and interaction
> mod_glm <- gamboost(y ~ bols(x) + bols(x, by = z),
-+ control = boost_control(mstop = 1000))
++ control = boost_control(mstop = 100))
> nd <- data.frame(x, z)
> nd <- nd[order(x),]
> nd$pred_glm <- predict(mod_glm, newdata = nd)
> for (i in seq(along = levels(z)))
+ with(nd[nd$z == i,], lines(x, pred_glm, col = z))
-> mod_gam <- gamboost(y ~ bbs(x) + bbs(x, by = z),
-+ control = boost_control(mstop = 1000))
-Warning in Xfun(mf, vary, args) :
- ‘df’ equal to rank of null space (unpenalized part of P-spline);
- Consider larger value for ‘df’ or set ‘center != FALSE’.
+> mod_gam <- gamboost(y ~ bbs(x) + bbs(x, by = z, df = 8),
++ control = boost_control(mstop = 100))
> nd$pred_gam <- predict(mod_gam, newdata = nd)
-Warning in Xfun(mf, vary, args) :
- ‘df’ equal to rank of null space (unpenalized part of P-spline);
- Consider larger value for ‘df’ or set ‘center != FALSE’.
> for (i in seq(along = levels(z)))
+ with(nd[nd$z == i,], lines(x, pred_gam, col = z, lty = "dashed"))
> ### convenience function for plotting
> par(mfrow = c(1,3))
> plot(mod_gam)
-Warning in Xfun(mf, vary, args) :
- ‘df’ equal to rank of null space (unpenalized part of P-spline);
- Consider larger value for ‘df’ or set ‘center != FALSE’.
-Warning in Xfun(mf, vary, args) :
- ‘df’ equal to rank of null space (unpenalized part of P-spline);
- Consider larger value for ‘df’ or set ‘center != FALSE’.
>
>
> ### remove intercept from base-learner
@@ -413,67 +628,69 @@
> mod <- gamboost(y ~ bols(int, intercept = FALSE) +
+ bols(x, intercept = FALSE),
+ data = tmpdata,
-+ control = boost_control(mstop = 2500))
++ control = boost_control(mstop = 1000))
Warning in bols(x, intercept = FALSE) :
covariates should be (mean-) centered if ‘intercept = FALSE’
> cf <- unlist(coef(mod))
+> ## add offset
> cf[1] <- cf[1] + mod$offset
-> cf
+> signif(cf, 3)
bols(int, intercept = FALSE).int bols(x, intercept = FALSE).x
- -0.1298897900 0.0003555856
-> coef(lm(y ~ x, data = tmpdata))
- (Intercept) x
--0.1298898174 0.0003555861
+ -0.130000 0.000355
+> signif(coef(lm(y ~ x, data = tmpdata)), 3)
+(Intercept) x
+ -0.130000 0.000356
>
-> ### quicker and better with (mean-) centering
+> ### much quicker and better with (mean-) centering
> tmpdata$x_center <- tmpdata$x - mean(tmpdata$x)
> mod_center <- gamboost(y ~ bols(int, intercept = FALSE) +
+ bols(x_center, intercept = FALSE),
+ data = tmpdata,
-+ control = boost_control(mstop = 500))
++ control = boost_control(mstop = 100))
> cf_center <- unlist(coef(mod_center, which=1:2))
> ## due to the shift in x direction we need to subtract
> ## beta_1 * mean(x) to get the correct intercept
> cf_center[1] <- cf_center[1] + mod_center$offset -
+ cf_center[2] * mean(tmpdata$x)
-> cf_center
+> signif(cf_center, 3)
bols(int, intercept = FALSE).int
- -0.1298898010
+ -0.130000
bols(x_center, intercept = FALSE).x_center
- 0.0003555858
-> coef(lm(y ~ x, data = tmpdata))
- (Intercept) x
--0.1298898174 0.0003555861
+ 0.000356
+> signif(coef(lm(y ~ x, data = tmpdata)), 3)
+(Intercept) x
+ -0.130000 0.000356
>
-> ### large data set with ties
-> nunique <- 100
-> xindex <- sample(1:nunique, 1000000, replace = TRUE)
-> x <- runif(nunique)
-> y <- rnorm(length(xindex))
-> w <- rep.int(1, length(xindex))
+> ## To speed up testing do not run this automatically.
+> ## Not run:
+> ##D ### large data set with ties
+> ##D nunique <- 100
+> ##D xindex <- sample(1:nunique, 1000000, replace = TRUE)
+> ##D x <- runif(nunique)
+> ##D y <- rnorm(length(xindex))
+> ##D w <- rep.int(1, length(xindex))
+> ##D
+> ##D ### brute force computations
+> ##D op <- options()
+> ##D options(mboost_indexmin = Inf, mboost_useMatrix = FALSE)
+> ##D ## data pre-processing
+> ##D b1 <- bbs(x[xindex])$dpp(w)
+> ##D ## model fitting
+> ##D c1 <- b1$fit(y)$model
+> ##D options(op)
+> ##D
+> ##D ### automatic search for ties, faster
+> ##D b2 <- bbs(x[xindex])$dpp(w)
+> ##D c2 <- b2$fit(y)$model
+> ##D
+> ##D ### manual specification of ties, even faster
+> ##D b3 <- bbs(x, index = xindex)$dpp(w)
+> ##D c3 <- b3$fit(y)$model
+> ##D
+> ##D all.equal(c1, c2)
+> ##D all.equal(c1, c3)
+> ## End(Not run)
>
-> ### brute force computations
-> op <- options()
-> options(mboost_indexmin = Inf, mboost_useMatrix = FALSE)
-> ## data pre-processing
-> b1 <- bbs(x[xindex])$dpp(w)
-> ## model fitting
-> c1 <- b1$fit(y)$model
-> options(op)
->
-> ### automatic search for ties, faster
-> b2 <- bbs(x[xindex])$dpp(w)
-> c2 <- b2$fit(y)$model
->
-> ### manual specification of ties, even faster
-> b3 <- bbs(x, index = xindex)$dpp(w)
-> c3 <- b3$fit(y)$model
->
-> all.equal(c1, c2)
-[1] TRUE
-> all.equal(c1, c3)
-[1] TRUE
->
> ### cyclic P-splines
> set.seed(781)
> x <- runif(200, 0,(2*pi))
@@ -559,34 +776,17 @@
> volf <- matrix(fitted(mod), nrow = nrow(volcano))
> image(volf, main = "fitted")
>
-> ## the old-fashioned way, a waste of space and time
-> x <- expand.grid(x1, x2)
-> modx <- mboost(vol ~ bbs(Var2, df = 3, knots = 10)%X%
-+ bbs(Var1, df = 3, knots = 10), data = x,
-+ control = boost_control(nu = 0.25))
-> modx[250]
-
- Model-based Boosting
-
-Call:
-mboost(formula = vol ~ bbs(Var2, df = 3, knots = 10) %X% bbs(Var1, df = 3, knots = 10), data = x, control = boost_control(nu = 0.25))
-
-
- Squared Error (Regression)
-
-Loss function: (y - f)^2
-
-
-Number of boosting iterations: mstop = 250
-Step size: 0.25
-Offset: 130.1879
-Number of baselearners: 1
-
+> ## Not run:
+> ##D ## the old-fashioned way, a waste of space and time
+> ##D x <- expand.grid(x1, x2)
+> ##D modx <- mboost(vol ~ bbs(Var2, df = 3, knots = 10) %X%
+> ##D bbs(Var1, df = 3, knots = 10), data = x,
+> ##D control = boost_control(nu = 0.25))
+> ##D modx[250]
+> ##D
+> ##D max(abs(fitted(mod) - fitted(modx)))
+> ## End(Not run)
>
-> max(abs(fitted(mod) - fitted(modx)))
-[1] 1.907665e-10
->
->
> ### setting contrasts via contrasts.arg
> x <- as.factor(sample(1:4, 100, replace = TRUE))
>
@@ -716,26 +916,19 @@
> cars.gb <- blackboost(dist ~ speed, data = cars,
+ control = boost_control(mstop = 50))
Loading required package: party
-Loading required package: survival
-Loading required package: splines
Loading required package: grid
-Loading required package: modeltools
-Loading required package: stats4
-Loading required package: coin
-Loading required package: mvtnorm
Loading required package: zoo
Attaching package: ‘zoo’
-The following object(s) are masked from ‘package:base’:
+The following object is masked from ‘package:base’:
as.Date, as.Date.numeric
Loading required package: sandwich
Loading required package: strucchange
-Loading required package: vcd
-Loading required package: MASS
-Loading required package: colorspace
+Loading required package: modeltools
+Loading required package: stats4
> cars.gb
Model-based Boosting
@@ -776,11 +969,9 @@
>
> cleanEx()
-detaching ‘package:party’, ‘package:vcd’, ‘package:colorspace’,
- ‘package:MASS’, ‘package:strucchange’, ‘package:sandwich’,
- ‘package:zoo’, ‘package:coin’, ‘package:mvtnorm’,
- ‘package:modeltools’, ‘package:stats4’, ‘package:grid’,
- ‘package:survival’, ‘package:splines’
+detaching ‘package:party’, ‘package:modeltools’, ‘package:stats4’,
+ ‘package:strucchange’, ‘package:sandwich’, ‘package:zoo’,
+ ‘package:grid’
> nameEx("bodyfat")
> ### * bodyfat
@@ -845,7 +1036,7 @@
>
> ### Name: cvrisk
> ### Title: Cross-Validation
-> ### Aliases: cvrisk cv
+> ### Aliases: cvrisk cvrisk.mboost cv
> ### Keywords: models regression
>
> ### ** Examples
@@ -995,26 +1186,19 @@
> ### trees
> blackbox <- blackboost(DEXfat ~ ., data = bodyfat)
Loading required package: party
-Loading required package: survival
-Loading required package: splines
Loading required package: grid
-Loading required package: modeltools
-Loading required package: stats4
-Loading required package: coin
-Loading required package: mvtnorm
Loading required package: zoo
Attaching package: ‘zoo’
-The following object(s) are masked from ‘package:base’:
+The following object is masked from ‘package:base’:
as.Date, as.Date.numeric
Loading required package: sandwich
Loading required package: strucchange
-Loading required package: vcd
-Loading required package: MASS
-Loading required package: colorspace
+Loading required package: modeltools
+Loading required package: stats4
> cvtree <- cvrisk(blackbox, papply = lapply)
> plot(cvtree)
>
@@ -1049,11 +1233,9 @@
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
-detaching ‘package:party’, ‘package:vcd’, ‘package:colorspace’,
- ‘package:MASS’, ‘package:strucchange’, ‘package:sandwich’,
- ‘package:zoo’, ‘package:coin’, ‘package:mvtnorm’,
- ‘package:modeltools’, ‘package:stats4’, ‘package:grid’,
- ‘package:survival’, ‘package:splines’
+detaching ‘package:party’, ‘package:modeltools’, ‘package:stats4’,
+ ‘package:strucchange’, ‘package:sandwich’, ‘package:zoo’,
+ ‘package:grid’
> nameEx("gamboost")
> ### * gamboost
@@ -1132,14 +1314,14 @@
>
> ### a simple two-dimensional example: cars data
> cars.gb <- glmboost(dist ~ speed, data = cars,
-+ control = boost_control(mstop = 5000),
++ control = boost_control(mstop = 2000),
+ center = FALSE)
> cars.gb
Generalized Linear Models Fitted via Gradient Boosting
Call:
-glmboost.formula(formula = dist ~ speed, data = cars, center = FALSE, control = boost_control(mstop = 5000))
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/mboost -r 732
More information about the Mboost-commits
mailing list