[Mboost-commits] r858 - in pkg/mboostPatch/tests: . Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 12 11:47:20 CEST 2015
Author: hofner
Date: 2015-08-12 11:47:20 +0200 (Wed, 12 Aug 2015)
New Revision: 858
Modified:
pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save
pkg/mboostPatch/tests/birds_Biometrics.Rout.save
pkg/mboostPatch/tests/bugfixes.R
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
pkg/mboostPatch/tests/regtest-inference.Rout.save
Log:
Updated tests and .Rout.save files
Modified: pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save
===================================================================
--- pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/Examples/mboost-Ex.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -35,7 +35,7 @@
> library('mboost')
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See ‘package?mboost’ and ‘news(package = "mboost")’
+This is mboost 2.4-3. See ‘package?mboost’ and ‘news(package = "mboost")’
for a complete list of changes.
>
@@ -151,27 +151,43 @@
>
> ### ** Examples
>
+> ### Define a new family
+> MyGaussian <- function(){
++ Family(ngradient = function(y, f, w = 1) y - f,
++ loss = function(y, f) (y - f)^2,
++ name = "My Gauss Variant")
++ }
>
-> Laplace()
+>
+> ### Multinomial logit model via a linear array model
+> ## One needs to convert the data to a list
+> myiris <- as.list(iris)
+> ## ... and define a dummy vector with one factor level less
+> ## than the outcome, which is used as reference category.
+> myiris$class <- factor(levels(iris$Species)[-nlevels(iris$Species)])
+> ## Now fit the linear array model
+> mlm <- mboost(Species ~ bols(Sepal.Length, df = 2) %O%
++ bols(class, df = 2, contrasts.arg = "contr.dummy"),
++ data = myiris,
++ family = Multinomial())
+> coef(mlm) ## one should use more boosting iterations.
+$`"bols(Sepal.Length, df = 2) %O% bols(class, df = 2, contrasts.arg = \\"contr.dummy\\")"`
+ (Intercept)_classsetosa Sepal.Length_classsetosa
+ 11.6398483 -2.0190645
+ (Intercept)_classversicolor Sepal.Length_classversicolor
+ 2.3384902 -0.3845469
- Absolute Error
-
-Loss function: abs(y - f)
-
->
-> MyGaussian <- function(){
-+ Family(ngradient = function(y, f, w = 1) y - f,
-+ loss = function(y, f) (y - f)^2,
-+ name = "My Gauss Variant")
-+ }
->
-> ### fitting multinomial logit model via a linear array model
-> X0 <- K0 <- diag(nlevels(iris$Species) - 1)
-> colnames(X0) <- levels(iris$Species)[-nlevels(iris$Species)]
-> mlm <- mboost(Species ~ bols(Sepal.Length, df = 2) %O%
-+ buser(X0, K0, df = 2), data = iris,
-+ family = Multinomial())
-> head(round(predict(mlm, type = "response"), 2))
+attr(,"offset")
+ [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+[112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+[149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+[186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+[223] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+[260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+[297] 0 0 0 0
+> head(round(pred <- predict(mlm, type = "response"), 2))
setosa versicolor virginica
[1,] 0.61 0.23 0.16
[2,] 0.69 0.19 0.12
@@ -180,6 +196,21 @@
[5,] 0.65 0.21 0.14
[6,] 0.48 0.30 0.23
>
+> ## Prediction with new data:
+> newdata <- as.list(iris[1,])
+> ## One always needs to keep the dummy vector class as above!
+> newdata$class <- factor(levels(iris$Species)[-nlevels(iris$Species)])
+> pred2 <- predict(mlm, type = "response", newdata = newdata)
+Warning in object$predict(newdata = newdata, which = which, aggregate = aggregate) :
+ Offset not used for prediction when ‘newdata’ is specified
+> ## check results
+> pred[1, ]
+ setosa versicolor virginica
+ 0.6090049 0.2319469 0.1590482
+> pred2
+ setosa versicolor virginica
+[1,] 0.6090049 0.2319469 0.1590482
+[2,] 0.6090049 0.2319469 0.1590482
>
>
>
@@ -195,8 +226,8 @@
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: baselearners
> ### Title: Base-learners for Gradient Boosting
-> ### Aliases: bols bbs bspatial brad brandom btree bmono bmrf buser bns bss
-> ### %+% %X% %O%
+> ### Aliases: baselearners bols bbs bspatial brad brandom btree bmono bmrf
+> ### buser bns bss %+% %X% %O%
> ### Keywords: models
>
> ### ** Examples
@@ -858,32 +889,12 @@
> ### ** Examples
>
>
-> ### a simple two-dimensional example: cars data
-> cars.gb <- blackboost(dist ~ speed, data = cars,
-+ control = boost_control(mstop = 50))
-Loading required package: party
-Loading required package: grid
-Loading required package: zoo
+> ### a simple two-dimensional example: cars data
+> cars.gb <- blackboost(dist ~ speed, data = cars,
++ control = boost_control(mstop = 50))
+Loading required namespace: party
+> cars.gb
-Attaching package: ‘zoo’
-
-The following objects are masked from ‘package:base’:
-
- as.Date, as.Date.numeric
-
-Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: ‘modeltools’
-
-The following object is masked from ‘package:stabs’:
-
- parameters
-
-> cars.gb
-
Model-based Boosting
Call:
@@ -901,21 +912,45 @@
Number of baselearners: 1
>
-> ### plot fit
-> plot(dist ~ speed, data = cars)
-> lines(cars$speed, predict(cars.gb), col = "red")
+> ### plot fit
+> plot(dist ~ speed, data = cars)
+> lines(cars$speed, predict(cars.gb), col = "red")
>
-> ### set up and plot additive tree model
-> ctrl <- ctree_control(maxdepth = 3)
-> viris <- subset(iris, Species != "setosa")
-> viris$Species <- viris$Species[, drop = TRUE]
-> imod <- mboost(Species ~ btree(Sepal.Length, tree_controls = ctrl) +
+> ### set up and plot additive tree model
+> if (require("party")) {
++ ctrl <- ctree_control(maxdepth = 3)
++ viris <- subset(iris, Species != "setosa")
++ viris$Species <- viris$Species[, drop = TRUE]
++ imod <- mboost(Species ~ btree(Sepal.Length, tree_controls = ctrl) +
+ btree(Sepal.Width, tree_controls = ctrl) +
+ btree(Petal.Length, tree_controls = ctrl) +
+ btree(Petal.Width, tree_controls = ctrl),
+ data = viris, family = Binomial())[500]
-> layout(matrix(1:4, ncol = 2))
-> plot(imod)
++ layout(matrix(1:4, ncol = 2))
++ plot(imod)
++ }
+Loading required package: party
+Loading required package: grid
+Loading required package: mvtnorm
+Loading required package: modeltools
+Loading required package: stats4
+
+Attaching package: ‘modeltools’
+
+The following object is masked from ‘package:stabs’:
+
+ parameters
+
+Loading required package: strucchange
+Loading required package: zoo
+
+Attaching package: ‘zoo’
+
+The following objects are masked from ‘package:base’:
+
+ as.Date, as.Date.numeric
+
+Loading required package: sandwich
>
>
>
@@ -924,9 +959,9 @@
> base::cat("blackboost", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
> cleanEx()
-detaching ‘package:party’, ‘package:modeltools’, ‘package:stats4’,
- ‘package:strucchange’, ‘package:sandwich’, ‘package:zoo’,
- ‘package:grid’
+detaching ‘package:party’, ‘package:strucchange’, ‘package:sandwich’,
+ ‘package:zoo’, ‘package:modeltools’, ‘package:stats4’,
+ ‘package:mvtnorm’, ‘package:grid’
> nameEx("boost_family-class")
> ### * boost_family-class
@@ -974,7 +1009,6 @@
>
> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
> base::cat("confint", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
-> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("cvrisk")
> ### * cvrisk
@@ -1133,27 +1167,6 @@
>
> ### trees
> blackbox <- blackboost(DEXfat ~ ., data = bodyfat)
-Loading required package: party
-Loading required package: grid
-Loading required package: zoo
-
-Attaching package: ‘zoo’
-
-The following objects are masked from ‘package:base’:
-
- as.Date, as.Date.numeric
-
-Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: ‘modeltools’
-
-The following object is masked from ‘package:stabs’:
-
- parameters
-
> cvtree <- cvrisk(blackbox, papply = lapply)
> plot(cvtree)
>
@@ -1189,11 +1202,6 @@
> base::cat("cvrisk", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
-
-detaching ‘package:party’, ‘package:modeltools’, ‘package:stats4’,
- ‘package:strucchange’, ‘package:sandwich’, ‘package:zoo’,
- ‘package:grid’
-
> nameEx("gamboost")
> ### * gamboost
>
@@ -1267,7 +1275,6 @@
> ### Name: glmboost
> ### Title: Gradient Boosting with Component-wise Linear Models
> ### Aliases: glmboost glmboost.formula glmboost.matrix glmboost.default
-> ### plot.glmboost
> ### Keywords: models regression
>
> ### ** Examples
@@ -1322,10 +1329,10 @@
+ control = boost_control(mstop = 2000),
+ center = TRUE)
>
-> ## plot coefficient paths oth glmboost
+> ## plot coefficient paths of glmboost
> par(mfrow=c(1,2), mai = par("mai") * c(1, 1, 1, 2.5))
-> plot(cars.gb, main="without centering")
-> plot(cars.gb_centered, main="with centering")
+> plot(cars.gb, main = "without centering")
+> plot(cars.gb_centered, main = "with centering")
>
> ### alternative loss function: absolute loss
> cars.gbl <- glmboost(dist ~ speed, data = cars,
@@ -1427,27 +1434,6 @@
> ### and a smooth non-linear smooth function in `hipcirc'
> mod <- mboost(DEXfat ~ btree(age) + bols(waistcirc) + bbs(hipcirc),
+ data = bodyfat)
-Loading required package: party
-Loading required package: grid
-Loading required package: zoo
-
-Attaching package: ‘zoo’
-
-The following objects are masked from ‘package:base’:
-
- as.Date, as.Date.numeric
-
-Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: ‘modeltools’
-
-The following object is masked from ‘package:stabs’:
-
- parameters
-
> layout(matrix(1:6, nc = 3, byrow = TRUE))
> plot(mod, ask = FALSE, main = "formula")
>
@@ -1491,11 +1477,6 @@
> base::cat("mboost", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
-
-detaching ‘package:party’, ‘package:modeltools’, ‘package:stats4’,
- ‘package:strucchange’, ‘package:sandwich’, ‘package:zoo’,
- ‘package:grid’
-
> nameEx("mboost_package")
> ### * mboost_package
>
@@ -1521,27 +1502,6 @@
+ ### hip and waist circumference
+ bbs(kneebreadth), ### a smooth function of kneebreadth
+ data = bodyfat, control = boost_control(mstop = 100))
-Loading required package: party
-Loading required package: grid
-Loading required package: zoo
-
-Attaching package: ‘zoo’
-
-The following objects are masked from ‘package:base’:
-
- as.Date, as.Date.numeric
-
-Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: ‘modeltools’
-
-The following object is masked from ‘package:stabs’:
-
- parameters
-
>
> ### bootstrap for assessing `optimal' number of boosting iterations
> cvm <- cvrisk(model, papply = lapply)
@@ -1578,11 +1538,6 @@
> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
> base::cat("mboost_package", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
> cleanEx()
-
-detaching ‘package:party’, ‘package:modeltools’, ‘package:stats4’,
- ‘package:strucchange’, ‘package:sandwich’, ‘package:zoo’,
- ‘package:grid’
-
> nameEx("methods")
> ### * methods
>
@@ -1598,8 +1553,8 @@
> ### resid.mboost variable.names.glmboost variable.names.mboost risk
> ### risk.mboost extract extract.mboost extract.gamboost extract.glmboost
> ### extract.blackboost extract.blg extract.bl_lin extract.bl_tree
-> ### logLik.mboost hatvalues.gamboost hatvalues.glmboost selected.mboost
-> ### nuisance nuisance.mboost
+> ### logLik.mboost hatvalues.gamboost hatvalues.glmboost selected
+> ### selected.mboost nuisance nuisance.mboost
> ### Keywords: methods
>
> ### ** Examples
@@ -3169,6 +3124,108 @@
> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
> base::cat("methods", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
> cleanEx()
+> nameEx("plot")
+> ### * plot
+>
+> flush(stderr()); flush(stdout())
+>
+> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
+> ### Name: plot
+> ### Title: Plot effect estimates of boosting models
+> ### Aliases: plot plot.glmboost plot.mboost lines.mboost
+> ### Keywords: methods
+>
+> ### ** Examples
+>
+>
+> ### a simple example: cars data with one random variable
+> set.seed(1234)
+> cars$z <- rnorm(50)
+>
+> ########################################
+> ## Plot linear models
+> ########################################
+>
+> ## fit a linear model
+> cars.lm <- glmboost(dist ~ speed + z, data = cars)
+>
+> ## plot coefficient paths of glmboost
+> par(mfrow = c(3, 1), mar = c(4, 4, 4, 8))
+> plot(cars.lm,
++ main = "Coefficient paths (offset not included)")
+> plot(cars.lm, off2int = TRUE,
++ main = "Coefficient paths (offset included in intercept)")
+>
+> ## plot coefficient paths only for the first 15 steps,
+> ## i.e., bevore z is selected
+> mstop(cars.lm) <- 15
+> plot(cars.lm, off2int = TRUE, main = "z is not yet selected")
+>
+>
+> ########################################
+> ## Plot additive models; basics
+> ########################################
+>
+> ## fit an additive model
+> cars.gam <- gamboost(dist ~ speed + z, data = cars)
+>
+> ## plot effects
+> par(mfrow = c(1, 2), mar = c(4, 4, 0.1, 0.1))
+> plot(cars.gam)
+>
+> ## use same y-lims
+> plot(cars.gam, ylim = c(-50, 50))
+>
+> ## plot only the effect of speed
+> plot(cars.gam, which = "speed")
+> ## as partial matching is used we could also use
+> plot(cars.gam, which = "sp")
+>
+>
+> ########################################
+> ## More complex plots
+> ########################################
+>
+> ## Let us use more boosting iterations and compare the effects.
+>
+> ## We change the plot type and plot both effects in one figure:
+> par(mfrow = c(1, 1), mar = c(4, 4, 4, 0.1))
+> mstop(cars.gam) <- 100
+> plot(cars.gam, which = 1, col = "red", type = "l", rug = FALSE,
++ main = "Compare effect for various models")
+>
+> ## Now the same model with 1000 iterations
+> mstop(cars.gam) <- 1000
+> lines(cars.gam, which = 1, col = "grey", lty = "dotted")
+>
+> ## There are some gaps in the data. Use newdata to get a smoother curve:
+> newdata <- data.frame(speed = seq(min(cars$speed), max(cars$speed),
++ length = 200))
+> lines(cars.gam, which = 1, col = "grey", lty = "dashed",
++ newdata = newdata)
+>
+> ## The model with 1000 steps seems to overfit the data.
+> ## Usually one should use e.g. cross-validation to tune the model.
+>
+> ## Finally we refit the model using linear effects as comparison
+> cars.glm <- gamboost(dist ~ speed + z, baselearner = bols, data = cars)
+> lines(cars.glm, which = 1, col = "black")
+> ## We see that all effects are more or less linear.
+>
+> ## Add a legend
+> legend("topleft", title = "Model",
++ legend = c("... with mstop = 100", "... with mstop = 1000",
++ "... with linear effects"),
++ lty = c("solid", "dashed", "solid"),
++ col = c("red", "grey", "black"))
+>
+>
+>
+>
+> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
+> base::cat("plot", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
+> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+> cleanEx()
> nameEx("stabsel")
> ### * stabsel
>
@@ -3252,7 +3309,6 @@
>
>
> library("survival")
-Loading required package: splines
> data("ovarian", package = "survival")
>
> fm <- Surv(futime,fustat) ~ age + resid.ds + rx + ecog.ps
@@ -3323,7 +3379,7 @@
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 15.457 0.544 18.843 1.57 0.183
+Time elapsed: 10.61 0.369 13.02 1.317 0.12
> grDevices::dev.off()
null device
1
Modified: pkg/mboostPatch/tests/birds_Biometrics.Rout.save
===================================================================
--- pkg/mboostPatch/tests/birds_Biometrics.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/birds_Biometrics.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -19,7 +19,7 @@
> library("mboost")
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See 'package?mboost' and 'news(package = "mboost")'
+This is mboost 2.4-3. See 'package?mboost' and 'news(package = "mboost")'
for a complete list of changes.
> data("birds", package = "TH.data")
@@ -192,7 +192,7 @@
[ 281] ...................................... -- risk: 129.1004
[ 321] ...................................... -- risk: 128.511
[ 361] ...................................... -- risk: 127.9744
-[ 401] ...................................... -- risk: 127.4638
+[ 401] ...................................... -- risk: 127.4639
[ 441] ...................................... -- risk: 127.0067
[ 481] ..................
Final risk: 126.7845
@@ -315,4 +315,4 @@
>
> proc.time()
user system elapsed
- 20.078 0.342 21.018
+ 15.190 0.145 15.674
Modified: pkg/mboostPatch/tests/bugfixes.R
===================================================================
--- pkg/mboostPatch/tests/bugfixes.R 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/bugfixes.R 2015-08-12 09:47:20 UTC (rev 858)
@@ -477,3 +477,24 @@
extract(mod1, "bnames")
extract(mod2, "bnames")
extract(mod3, "bnames")
+
+## check handling of newdata = list(), at least for common scenarios with lists
+## [https://github.com/hofnerb/mboost/issues/15]
+data("bodyfat", package = "TH.data")
+bf <- as.list(bodyfat)
+mod <- mboost(DEXfat ~ bols(waistcirc) + bmono(hipcirc) + btree(age),
+ data = bf)
+## predict with data frame
+nd <- bodyfat[1:2,]
+pr1 <- predict(mod, newdata = nd)
+## predict with list
+nd <- as.list(bodyfat[1:2,])
+pr2 <- predict(mod, newdata = nd)
+stopifnot(pr1 == pr2)
+## check plotting
+nd <- list(waistcirc = 1, age = 1,
+ hipcirc = seq(min(bf$hipcirc), max(bf$hipcirc), length = 100))
+plot(mod, which = 2, newdata = nd)
+nd <- data.frame(waistcirc = 1, age = 1,
+ hipcirc = seq(min(bf$hipcirc), max(bf$hipcirc), length = 100))
+plot(mod, which = 2, newdata = nd)
Modified: pkg/mboostPatch/tests/bugfixes.Rout.save
===================================================================
--- pkg/mboostPatch/tests/bugfixes.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/bugfixes.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -20,7 +20,7 @@
Loading required package: mboost
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See 'package?mboost' and 'news(package = "mboost")'
+This is mboost 2.4-3. See 'package?mboost' and 'news(package = "mboost")'
for a complete list of changes.
> require("Matrix")
@@ -32,27 +32,7 @@
> dummy <- data.frame(y = gl(2, 100), x = runif(200))
> pr <- predict(blackboost(y ~ x, data = dummy, family = Binomial()),
+ newdata = dummy, type = "class")
-Loading required package: party
-Loading required package: grid
-Loading required package: zoo
-
-Attaching package: 'zoo'
-
-The following objects are masked from 'package:base':
-
- as.Date, as.Date.numeric
-
-Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: 'modeltools'
-
-The following object is masked from 'package:stabs':
-
- parameters
-
+Loading required namespace: party
> stopifnot(is.factor(pr) && all(levels(pr) %in% levels(dummy$y)))
>
> ### predict for g{al}mboost.matrix did not work
@@ -303,15 +283,39 @@
+ stopifnot(max(abs(predict(x[i]) - predict(x[max(s)], agg = "cumsum")[,i])) < eps)
>
> ### make sure environment(formula) is used for evaluation
-> data("cars")
-> ctl <- boost_control(mstop = 100, trace = TRUE)
-> tctl <- ctree_control(teststat = "max", testtype = "Teststat",
-+ mincrit = 0, maxdepth = 5, savesplitstat = FALSE)
-> myfun <- function(cars, xx, zz){
-+ mboost(dist ~ btree(speed, tree_controls = zz),
-+ data = cars, control = xx)
+> if (require("party")) {
++ data("cars")
++ ctl <- boost_control(mstop = 100, trace = TRUE)
++ tctl <- ctree_control(teststat = "max", testtype = "Teststat",
++ mincrit = 0, maxdepth = 5, savesplitstat = FALSE)
++ myfun <- function(cars, xx, zz){
++ mboost(dist ~ btree(speed, tree_controls = zz),
++ data = cars, control = xx)
++ }
++ try(mod <- myfun(cars, xx = ctl, zz = tctl))
+ }
-> try(mod <- myfun(cars, xx = ctl, zz = tctl))
+Loading required package: party
+Loading required package: grid
+Loading required package: mvtnorm
+Loading required package: modeltools
+Loading required package: stats4
+
+Attaching package: 'modeltools'
+
+The following object is masked from 'package:stabs':
+
+ parameters
+
+Loading required package: strucchange
+Loading required package: zoo
+
+Attaching package: 'zoo'
+
+The following objects are masked from 'package:base':
+
+ as.Date, as.Date.numeric
+
+Loading required package: sandwich
[ 1] ...................................... -- risk: 9246.895
[ 41] ...................................... -- risk: 9006.37
[ 81] ..................
@@ -676,29 +680,7 @@
> mod <- mboost(y ~ bols(x1) + bbs(x1) + brandom(z1) +
+ bspatial(x1, x2) + brad(x1, x2, knots = 20) +
+ bmono(x1) + buser(x1, K = 1, lambda = 0) + x2)
-Loading required package: fields
-Loading required package: spam
-Spam version 0.41-0 (2014-02-26) is loaded.
-Type 'help( Spam)' or 'demo( spam)' for a short introduction
-and overview of this package.
-Help for individual functions is also obtained by adding the
-suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
-
-Attaching package: 'spam'
-
-The following object is masked _by_ '.GlobalEnv':
-
- germany
-
-The following object is masked from 'package:stats4':
-
- mle
-
-The following objects are masked from 'package:base':
-
- backsolve, forwardsolve
-
-Loading required package: maps
+Loading required namespace: fields
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.
@@ -741,6 +723,27 @@
> extract(mod3, "bnames")
[1] "s1" "s2"
>
+> ## check handling of newdata = list(), at least for common scenarios with lists
+> ## [https://github.com/hofnerb/mboost/issues/15]
+> data("bodyfat", package = "TH.data")
+> bf <- as.list(bodyfat)
+> mod <- mboost(DEXfat ~ bols(waistcirc) + bmono(hipcirc) + btree(age),
++ data = bf)
+> ## predict with data frame
+> nd <- bodyfat[1:2,]
+> pr1 <- predict(mod, newdata = nd)
+> ## predict with list
+> nd <- as.list(bodyfat[1:2,])
+> pr2 <- predict(mod, newdata = nd)
+> stopifnot(pr1 == pr2)
+> ## check plotting
+> nd <- list(waistcirc = 1, age = 1,
++ hipcirc = seq(min(bf$hipcirc), max(bf$hipcirc), length = 100))
+> plot(mod, which = 2, newdata = nd)
+> nd <- data.frame(waistcirc = 1, age = 1,
++ hipcirc = seq(min(bf$hipcirc), max(bf$hipcirc), length = 100))
+> plot(mod, which = 2, newdata = nd)
+>
> proc.time()
user system elapsed
- 28.136 0.475 29.138
+ 22.141 0.279 22.817
Modified: pkg/mboostPatch/tests/regtest-baselearner.Rout.save
===================================================================
--- pkg/mboostPatch/tests/regtest-baselearner.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/regtest-baselearner.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -19,7 +19,7 @@
> library("mboost")
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See 'package?mboost' and 'news(package = "mboost")'
+This is mboost 2.4-3. See 'package?mboost' and 'news(package = "mboost")'
for a complete list of changes.
> attach(asNamespace("mboost"))
@@ -28,12 +28,12 @@
%+%, %O%, %X%, AUC, AdaExp, Binomial, CoxPH, ExpectReg, FP, Family,
GammaReg, GaussClass, GaussReg, Gaussian, Gehan, Huber, Hurdle,
IPCweights, Laplace, Loglog, Lognormal, Multinomial, NBinomial,
- Poisson, PropOdds, QuantReg, Weibull, bbs, blackboost, bmono, bmrf,
- bns, bols, boost_control, brad, brandom, bspatial, bss, btree,
- buser, confint.glmboost, confint.mboost, cv, cvrisk, extract,
- gamboost, glmboost, mboost, mboost_fit, mstop, mstop<-, nuisance,
- risk, selected.mboost, stabsel.mboost, stabsel_parameters.mboost,
- survFit
+ Poisson, PropOdds, QuantReg, Weibull, bbs, bl_lin, blackboost,
+ bmono, bmrf, bns, bols, boost_control, brad, brandom, bspatial,
+ bss, btree, buser, confint.glmboost, confint.mboost, cv, cvrisk,
+ df2lambda, extract, gamboost, glmboost, hyper_bbs, mboost,
+ mboost_fit, mstop, mstop<-, nuisance, risk, selected.mboost,
+ stabsel.mboost, stabsel_parameters.mboost, survFit
> library("MASS")
> library("Matrix")
@@ -1203,4 +1203,4 @@
>
> proc.time()
user system elapsed
- 33.272 0.514 34.343
+ 31.611 0.581 32.588
Modified: pkg/mboostPatch/tests/regtest-blackboost.Rout.save
===================================================================
--- pkg/mboostPatch/tests/regtest-blackboost.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/regtest-blackboost.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -20,7 +20,7 @@
Loading required package: mboost
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See 'package?mboost' and 'news(package = "mboost")'
+This is mboost 2.4-3. See 'package?mboost' and 'news(package = "mboost")'
for a complete list of changes.
> if (require("party")) {
@@ -132,6 +132,17 @@
+ }
Loading required package: party
Loading required package: grid
+Loading required package: mvtnorm
+Loading required package: modeltools
+Loading required package: stats4
+
+Attaching package: 'modeltools'
+
+The following object is masked from 'package:stabs':
+
+ parameters
+
+Loading required package: strucchange
Loading required package: zoo
Attaching package: 'zoo'
@@ -141,22 +152,12 @@
as.Date, as.Date.numeric
Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: 'modeltools'
-
-The following object is masked from 'package:stabs':
-
- parameters
-
[1] 2.367443
Loading required package: gbm
Loading required package: survival
+Loading required package: lattice
Loading required package: splines
-Loading required package: lattice
-Loaded gbm 2.1
+Loaded gbm 2.1.1
[1] 2.753747
$surv
[,1]
@@ -211,4 +212,4 @@
>
> proc.time()
user system elapsed
- 8.407 0.225 9.009
+ 6.276 0.154 6.643
Modified: pkg/mboostPatch/tests/regtest-family.Rout.save
===================================================================
--- pkg/mboostPatch/tests/regtest-family.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/regtest-family.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -19,7 +19,7 @@
> library("mboost")
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See 'package?mboost' and 'news(package = "mboost")'
+This is mboost 2.4-3. See 'package?mboost' and 'news(package = "mboost")'
for a complete list of changes.
>
@@ -205,7 +205,6 @@
+
+ }
Loading required package: survival
-Loading required package: splines
[1] 0.4493619
>
>
@@ -404,4 +403,4 @@
>
> proc.time()
user system elapsed
- 16.272 0.166 16.638
+ 13.090 0.126 13.372
Modified: pkg/mboostPatch/tests/regtest-gamboost.Rout.save
===================================================================
--- pkg/mboostPatch/tests/regtest-gamboost.Rout.save 2015-08-12 09:45:37 UTC (rev 857)
+++ pkg/mboostPatch/tests/regtest-gamboost.Rout.save 2015-08-12 09:47:20 UTC (rev 858)
@@ -1,6 +1,6 @@
-R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
-Copyright (C) 2014 The R Foundation for Statistical Computing
+R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
+Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -20,12 +20,11 @@
Loading required package: mboost
Loading required package: parallel
Loading required package: stabs
-This is mboost 2.4-1. See 'package?mboost' and 'news(package = "mboost")'
+This is mboost 2.4-3. See 'package?mboost' and 'news(package = "mboost")'
for a complete list of changes.
> require("survival")
Loading required package: survival
-Loading required package: splines
>
> set.seed(290875)
>
@@ -194,27 +193,7 @@
> fm1 <- y ~ btree(x1) + btree(x2)
> fm2 <- y ~ x1 + x2
> mod1 <- gamboost(fm1, data = tmp)
-Loading required package: party
-Loading required package: grid
-Loading required package: zoo
-
-Attaching package: 'zoo'
-
-The following objects are masked from 'package:base':
-
- as.Date, as.Date.numeric
-
-Loading required package: sandwich
-Loading required package: strucchange
-Loading required package: modeltools
-Loading required package: stats4
-
-Attaching package: 'modeltools'
-
-The following object is masked from 'package:stabs':
-
- parameters
-
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/mboost -r 858
More information about the Mboost-commits
mailing list