* checking for working latex ... OK
* using log directory 'd:/Rcompile/CRANpkg/check/1.8/ipred.Rcheck'
* checking for file 'ipred/DESCRIPTION' ... OK
* checking if this is a source package ... OK
---------- Making package ipred ------------
adding build stamp to DESCRIPTION
installing NAMESPACE file
making DLL ...
making SdiffKM.d from SdiffKM.c
gcc -Id:/Rcompile/recent/R-1.8.1/src/include -Wall -O2 -c SdiffKM.c -o SdiffKM.o
ar cr ipred.a *.o
ranlib ipred.a
windres --include-dir d:/Rcompile/recent/R-1.8.1/src/include -i ipred_res.rc -o ipred_res.o
gcc --shared -s -o ipred.dll ipred.def ipred.a ipred_res.o -Ld:/Rcompile/recent/R-1.8.1/src/gnuwin32 -lg2c -lR
... DLL made
installing DLL
installing R files
installing inst files
installing data files
installing man source files
installing indices
not zipping data
installing help
>>> Building/Updating help pages for package 'ipred'
Formats: text html latex example
DLBCL text html latex example
GBSG2 text html latex example
GlaucomaM text html latex example
GlaucomaMVF text html latex example
Smoking text html latex
bagging text html latex example
missing link(s): lda
bootest text html latex
control.errorest text html latex
cv text html latex
dystrophy text html latex example
errorest text html latex example
inbagg text html latex example
inclass text html latex example
ipred-internal text html latex
ipredknn text html latex example
kfoldcv text html latex example
mypredict.lm text html latex
predict.bagging text html latex example
predict.inbagg text html latex example
predict.inclass text html latex example
predict.ipredknn text html latex
predict.slda text html latex
print.bagging text html latex
print.cvclass text html latex
print.inbagg text html latex
print.inclass text html latex
prune.bagging text html latex example
rsurv text html latex example
sbrier text html latex example
slda text html latex example
summary.bagging text html latex
summary.inbagg text html latex
summary.inclass text html latex
varset text html latex example
>>> Building/Updating help pages for package 'ipred'
Formats: chm
DLBCL chm
GBSG2 chm
GlaucomaM chm
GlaucomaMVF chm
Smoking chm
bagging chm
bootest chm
control.errorest chm
cv chm
dystrophy chm
errorest chm
inbagg chm
inclass chm
ipred-internal chm
ipredknn chm
kfoldcv chm
mypredict.lm chm
predict.bagging chm
predict.inbagg chm
predict.inclass chm
predict.ipredknn chm
predict.slda chm
print.bagging chm
print.cvclass chm
print.inbagg chm
print.inclass chm
prune.bagging chm
rsurv chm
sbrier chm
slda chm
summary.bagging chm
summary.inbagg chm
summary.inclass chm
varset chm
Microsoft HTML Help Compiler 4.74.8702
Compiling d:\Rcompile\CRANpkg\check\1.8\ipred\chm\ipred.chm
Compile time: 0 minutes, 2 seconds
35 Topics
135 Local links
3 Internet links
1 Graphic
Created d:\Rcompile\CRANpkg\check\1.8\ipred\chm\ipred.chm, 75,641 bytes
Compression decreased file by 77,173 bytes.
adding MD5 sums
installing R.css in d:/Rcompile/CRANpkg/check/1.8/ipred.Rcheck
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking package dependencies ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for syntax errors ... OK
* checking R files for library.dynam ... OK
* checking S3 generic/method consistency ... OK
* checking for replacement functions with final arg not named 'value' ... OK
* checking Rd files ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking for CRLF line endings in C sources/headers ... OK
* creating ipred-Ex.R ... OK
* checking examples ... OK
* checking tests ...
make[1]: Entering directory `/cygdrive/d/Rcompile/CRANpkg/check/1.8/ipred.Rcheck/tests'
Running 'ipred-bugs.R'
Comparing 'ipred-bugs.Rout' to 'ipred-bugs.Rout.save' ...4c4,5
< >
---
> Warning message:
> package 'mva' has been merged into 'stats'
30c31
< Out-of-bag estimate of misclassification error: 0.041
---
> Out-of-bag estimate of misclassification error: 0.0425
165c166
< [1] 0.949367
---
> [1] 0.9789321
167c168
< [1] 0.9148273
---
> [1] 0.9136014
OK
Running 'ipred-segfault.R'
Comparing 'ipred-segfault.Rout' to 'ipred-segfault.Rout.save' ...3a4,5
> Warning message:
> package 'mva' has been merged into 'stats'
29c31
< Out-of-bag estimate of misclassification error: 0.19
---
> Out-of-bag estimate of misclassification error: 0.195
32c34
< [1] 1 1 1 1 2 2 1 1 1 1
---
> [1] 1 1 1 2 2 2 1 1 1 1
50c52
< [1] 1 1 1 1 2 2 1 2 1 2
---
> [1] 1 1 1 1 1 2 1 2 1 2
56c58
< [1] 1 1 1 1 1 2 1 2 1 2
---
> [1] 1 1 1 1 2 2 1 2 1 2
67c69
< [8,] 0.0 1.0
---
> [8,] 0.1 0.9
79c81
< [8,] 0.0 1.0
---
> [8,] 0.1 0.9
84,93c86,95
< [1,] 1.0000000 0.000000000
< [2,] 0.9976303 0.002369668
< [3,] 1.0000000 0.000000000
< [4,] 1.0000000 0.000000000
< [5,] 0.5311111 0.468888889
< [6,] 0.0000000 1.000000000
< [7,] 1.0000000 0.000000000
< [8,] 0.0000000 1.000000000
< [9,] 1.0000000 0.000000000
< [10,] 0.0000000 1.000000000
---
> [1,] 1.000000000 0.000000000
> [2,] 0.996441281 0.003558719
> [3,] 1.000000000 0.000000000
> [4,] 1.000000000 0.000000000
> [5,] 0.484359233 0.515640767
> [6,] 0.000000000 1.000000000
> [7,] 1.000000000 0.000000000
> [8,] 0.001138952 0.998861048
> [9,] 1.000000000 0.000000000
> [10,] 0.000000000 1.000000000
106c108
< Misclassification error: 0.04
---
> Misclassification error: 0.035
147c149
< Misclassification error: 0.105
---
> Misclassification error: 0.13
158c160
< Misclassification error: 0.045
---
> Misclassification error: 0.07
171c173
< Standard deviation: 0.0034
---
> Standard deviation: 0.0023
183c185
< Misclassification error: 0.0326
---
> Misclassification error: 0.0331
201c203
< Out-of-bag estimate of root mean squared error: 3.8853
---
> Out-of-bag estimate of root mean squared error: 3.4471
204,205c206,207
< [1] 10.81664 17.73551 11.59625 11.12409 12.64024 11.54341 NA 13.37817
< [9] 21.40661 NA
---
> [1] 14.832807 9.278918 9.219854 12.524778 16.815055 8.967995 NA
> [8] 13.428337 12.907729 14.159305
208,209c210,211
< [1] 17.38947 19.63268 10.65900 20.19306 17.21303 10.61301 17.93208 11.61466
< [9] 10.07293 14.95946
---
> [1] 17.886853 15.918700 10.594017 21.354134 16.893509 15.526948 16.583579
> [8] 9.883741 15.016663 18.026174
211,212c213,214
< [1] 17.38947 19.63268 10.65900 20.19306 17.21303 10.61301 17.93208 11.61466
< [9] 10.07293 14.95946
---
> [1] 17.886853 15.918700 10.594017 21.354134 16.893509 15.526948 16.583579
> [8] 9.883741 15.016663 18.026174
214,215c216,217
< [1] 17.66740 19.65567 10.89005 20.17381 17.38077 10.77897 18.22338 11.62500
< [9] 10.13806 14.60351
---
> [1] 18.15920 15.90136 10.70243 21.22251 16.81084 15.64950 16.95415 10.27786
> [9] 15.63578 18.30429
223c225
< Root mean squared error: 2.9591
---
> Root mean squared error: 2.8058
234c236
< Root mean squared error: 2.905
---
> Root mean squared error: 2.7246
262c264
< Root mean squared error: 3.0737
---
> Root mean squared error: 2.9613
284c286
< 119.000 119.000 0.574 0.044 0.489 0.398 0.489
---
> 1.43e+02 1.43e+02 6.86e-02 7.27e-03 4.92e-02 4.11e-02 5.97e-02
290c292
< 1.42e+02 1.42e+02 9.66e-02 9.37e-03 5.08e-02 4.35e-02 6.75e-02
---
> 128.0000 128.0000 0.3946 0.0355 0.2834 0.2425 0.3663
296c298
< 122.0000 122.0000 0.5965 0.0442 0.4888 0.3976 0.5315
---
> 1.30e+02 1.30e+02 4.54e-02 3.49e-03 3.66e-02 2.91e-02 4.49e-02
302c304
< 1.41e+02 1.41e+02 5.13e-02 5.25e-03 3.78e-02 3.36e-02 4.35e-02
---
> 138.0000 138.0000 0.3892 0.0348 0.2736 0.2187 0.2942
308c310
< 1.34e+02 1.34e+02 6.21e-02 7.78e-03 3.59e-02 3.02e-02 4.35e-02
---
> 139.0000 139.0000 0.1337 0.0221 0.0492 0.0439 0.0552
314c316
< 131.0000 131.0000 0.5436 0.0413 0.3976 0.3605 0.4888
---
> 133.0000 133.0000 0.1747 0.0134 0.1372 0.1111 0.1626
320c322
< 1.31e+02 1.31e+02 5.39e-02 6.46e-03 3.36e-02 1.97e-02 3.78e-02
---
> 1.46e+02 1.46e+02 9.17e-02 6.54e-03 6.82e-02 5.44e-02 1.12e-01
326c328
< 127.000 127.000 0.526 0.042 0.398 0.361 0.489
---
> 124.0000 124.0000 0.3698 0.0384 0.2603 0.1817 0.2942
332c334
< 1.39e+02 1.39e+02 3.14e-02 3.61e-03 1.87e-02 1.39e-02 3.02e-02
---
> 1.46e+02 1.46e+02 7.71e-02 7.65e-03 5.52e-02 4.13e-02 7.68e-02
338c340
< 157.0000 157.0000 0.1847 0.0215 0.1050 0.0568 0.1375
---
> 1.35e+02 1.35e+02 3.44e-02 2.58e-03 2.84e-02 2.41e-02 3.42e-02
356c358
< Brier's score: 0.0953
---
> Brier's score: 0.0617
369c371
< Brier's score: 0.0947
---
> Brier's score: 0.095
403,404c405,406
< [1] 21.880856 7.246768 15.482136 11.982010 15.758885 13.131722 7.039301
< [8] 21.829846 7.785673 14.375108
---
> [1] 19.884659 7.979953 15.136274 17.090984 10.593808 15.343204 17.641397
> [8] 12.360645 14.277689 10.893690
418c420
< 903.0 443.0 1582.7 30.5 1641.0 1528.0 1753.0
---
> 1086.0 485.0 1696.4 29.4 1753.0 1675.0 1814.0
424c426
< 663.0 303.0 1575.2 38.4 1753.0 1528.0 1814.0
---
> 583.0 279.0 1580.3 39.9 1814.0 1701.0 2015.0
430c432
< 699.0 411.0 1304.0 32.9 1105.0 1002.0 1253.0
---
> 651.0 324.0 1482.9 35.9 1493.0 1337.0 1814.0
444c446
< Root mean squared error: 30.5108
---
> Root mean squared error: 30.3495
451c453
< Root mean squared error: 30.7493
---
> Root mean squared error: 31.8694
460a463
> >
OK
Running 'ipred-smalltest.R'
Running 'ipred-tests.R'
Comparing 'ipred-tests.Rout' to 'ipred-tests.Rout.save' ...3d2
< > TestsEx <- TRUE
6d4
< >
30a29,61
> > assign("ptime", proc.time(), env = .CheckExEnv)
> > postscript("ipred-Examples.ps")
> > assign("par.postscript", par(no.readonly = TRUE), env = .CheckExEnv)
> > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly"))
> > library('ipred')
> Warning message:
> package 'mva' has been merged into 'stats'
> > cleanEx(); ..nameEx <- "DLBCL"
> > ###--- >>> `DLBCL' <<<----- Diffuse Large B-Cell Lymphoma
> >
> > ## alias help(DLBCL)
> >
> > ##___ Examples ___:
> >
> > data(DLBCL)
> > survfit(Surv(time, cens), data=DLBCL)
> Call: survfit(formula = Surv(time, cens), data = DLBCL)
>
> n events rmean se(rmean) median 0.95LCL 0.95UCL
> 40.00 22.00 66.43 9.18 36.05 15.50 Inf
> >
> >
> > ## Keywords: 'datasets'.
> >
> >
> > cleanEx(); ..nameEx <- "GBSG2"
> > ###--- >>> `GBSG2' <<<----- German Breast Cancer Study Group 2
> >
> > ## alias help(GBSG2)
> >
> > ##___ Examples ___:
> >
> > data(GBSG2)
32,61c63
< > if(TestsEx) {
< + assign("ptime", proc.time(), env = .CheckExEnv)
< + postscript("ipred-Examples.ps")
< + assign("par.postscript", par(no.readonly = TRUE), env = .CheckExEnv)
< + options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly"))
< + library('ipred')
< + cleanEx(); ..nameEx <- "DLBCL"
< + ###--- >>> `DLBCL' <<<----- Diffuse Large B-Cell Lymphoma
< +
< + ## alias help(DLBCL)
< +
< + ##___ Examples ___:
< +
< + data(DLBCL)
< + survfit(Surv(time, cens), data=DLBCL)
< +
< +
< + ## Keywords: 'datasets'.
< +
< +
< + cleanEx(); ..nameEx <- "GBSG2"
< + ###--- >>> `GBSG2' <<<----- German Breast Cancer Study Group 2
< +
< + ## alias help(GBSG2)
< +
< + ##___ Examples ___:
< +
< + data(GBSG2)
< +
< + thsum <- function(x) {
---
> > thsum <- function(x) {
66,67c68,69
< +
< + t(apply(GBSG2[,c("age", "tsize", "pnodes",
---
> >
> > t(apply(GBSG2[,c("age", "tsize", "pnodes",
69,96c71,121
< +
< + table(GBSG2$menostat)
< + table(GBSG2$tgrade)
< + table(GBSG2$horTh)
< +
< + # pooled Kaplan-Meier
< +
< + mod <- survfit(Surv(time, cens), data=GBSG2)
< + # integrated Brier score
< + sbrier(Surv(GBSG2$time, GBSG2$cens), mod)
< + # Brier score at 5 years
< + sbrier(Surv(GBSG2$time, GBSG2$cens), mod, btime=1825)
< +
< + # Nottingham prognostic index
< +
< + GBSG2 <- GBSG2[order(GBSG2$time),]
< +
< + NPI <- 0.2*GBSG2$tsize/10 + 1 + as.integer(GBSG2$tgrade)
< + NPI[NPI < 3.4] <- 1
< + NPI[NPI >= 3.4 & NPI <=5.4] <- 2
< + NPI[NPI > 5.4] <- 3
< +
< + mod <- survfit(Surv(time, cens) ~ NPI, data=GBSG2)
< + plot(mod)
< +
< + pred <- c()
< + survs <- c()
< + for (i in sort(unique(NPI)))
---
> Median 25% 75%
> age 53.0 46 61.00
> tsize 25.0 20 35.00
> pnodes 3.0 1 7.00
> progrec 32.5 7 131.75
> estrec 36.0 8 114.00
> >
> > table(GBSG2$menostat)
>
> Pre Post
> 290 396
> > table(GBSG2$tgrade)
>
> I II III
> 81 444 161
> > table(GBSG2$horTh)
>
> no yes
> 440 246
> >
> > # pooled Kaplan-Meier
> >
> > mod <- survfit(Surv(time, cens), data=GBSG2)
> > # integrated Brier score
> > sbrier(Surv(GBSG2$time, GBSG2$cens), mod)
> integrated Brier score
> 0.1919286
> attr(,"time")
> [1] 8 2659
> > # Brier score at 5 years
> > sbrier(Surv(GBSG2$time, GBSG2$cens), mod, btime=1825)
> Brier score
> 0.2499263
> attr(,"time")
> [1] 1825
> >
> > # Nottingham prognostic index
> >
> > GBSG2 <- GBSG2[order(GBSG2$time),]
> >
> > NPI <- 0.2*GBSG2$tsize/10 + 1 + as.integer(GBSG2$tgrade)
> > NPI[NPI < 3.4] <- 1
> > NPI[NPI >= 3.4 & NPI <=5.4] <- 2
> > NPI[NPI > 5.4] <- 3
> >
> > mod <- survfit(Surv(time, cens) ~ NPI, data=GBSG2)
> > plot(mod)
> >
> > pred <- c()
> > survs <- c()
> > for (i in sort(unique(NPI)))
98,99c123,124
< +
< + for (i in 1:nrow(GBSG2))
---
> >
> > for (i in 1:nrow(GBSG2))
101,117c126,146
< +
< + # Brier score of NPI at t=5 years
< + sbrier(Surv(GBSG2$time, GBSG2$cens), pred, btime=1825)
< +
< +
< + ## Keywords: 'datasets'.
< +
< +
< + cleanEx(); ..nameEx <- "GlaucomaM"
< + ###--- >>> `GlaucomaM' <<<----- Glaucoma Database
< +
< + ## alias help(GlaucomaM)
< +
< + ##___ Examples ___:
< +
< + data(GlaucomaM)
< + errorest(Class ~ ., data=GlaucomaM, model=rpart,
---
> >
> > # Brier score of NPI at t=5 years
> > sbrier(Surv(GBSG2$time, GBSG2$cens), pred, btime=1825)
> Brier score
> 0.2337553
> attr(,"time")
> [1] 1825
> >
> >
> > ## Keywords: 'datasets'.
> >
> >
> > cleanEx(); ..nameEx <- "GlaucomaM"
> > ###--- >>> `GlaucomaM' <<<----- Glaucoma Database
> >
> > ## alias help(GlaucomaM)
> >
> > ##___ Examples ___:
> >
> > data(GlaucomaM)
> > errorest(Class ~ ., data=GlaucomaM, model=rpart,
121,137c150,183
< + glbagg <- bagging(Class ~ ., data=GlaucomaM, coob=TRUE)
< + glbagg
< +
< +
< + ## Keywords: 'datasets'.
< +
< +
< + cleanEx(); ..nameEx <- "GlaucomaMVF"
< + ###--- >>> `GlaucomaMVF' <<<----- Glaucoma Database
< +
< + ## alias help(GlaucomaMVF)
< +
< + ##___ Examples ___:
< +
< + data(GlaucomaMVF)
< +
< + response <- function (data) {
---
>
> Call:
> errorest.data.frame(formula = Class ~ ., data = GlaucomaM, model = rpart,
> predict = function(obj, newdata) predict(obj, newdata, type = "class"),
> control = rpart.control(xval = 0))
>
> 10-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.2143
>
> > glbagg <- bagging(Class ~ ., data=GlaucomaM, coob=TRUE)
> > glbagg
>
> Bagging classification trees with 25 bootstrap replications
>
> Call: bagging.data.frame(formula = Class ~ ., data = GlaucomaM, coob = TRUE)
>
> Out-of-bag estimate of misclassification error: 0.1276
>
> >
> >
> > ## Keywords: 'datasets'.
> >
> >
> > cleanEx(); ..nameEx <- "GlaucomaMVF"
> > ###--- >>> `GlaucomaMVF' <<<----- Glaucoma Database
> >
> > ## alias help(GlaucomaMVF)
> >
> > ##___ Examples ___:
> >
> > data(GlaucomaMVF)
> >
> > response <- function (data) {
147,148c193,194
< +
< + errorest(Class~clv+lora+cs~., data = GlaucomaMVF, model=inclass,
---
> >
> > errorest(Class~clv+lora+cs~., data = GlaucomaMVF, model=inclass,
151,177c197,233
< +
< +
< + ## Keywords: 'datasets'.
< +
< +
< + cleanEx(); ..nameEx <- "bagging"
< + ###--- >>> `bagging' <<<----- Bagging Classification, Regression and Survival Trees
< +
< + ## alias help(bagging)
< + ## alias help(ipredbagg)
< + ## alias help(ipredbagg.factor)
< + ## alias help(ipredbagg.numeric)
< + ## alias help(ipredbagg.Surv)
< + ## alias help(ipredbagg.default)
< + ## alias help(bagging.data.frame)
< + ## alias help(bagging.default)
< +
< + ##___ Examples ___:
< +
< +
< + # Classification: Breast Cancer data
< +
< + data(BreastCancer)
< +
< + # Test set error bagging (nbagg = 50): 3.7% (Breiman, 1998, Table 5)
< +
< + mod <- bagging(Class ~ Cl.thickness + Cell.size
---
>
> Call:
> errorest.data.frame(formula = Class ~ clv + lora + cs ~ ., data = GlaucomaMVF,
> model = inclass, estimator = "cv", pFUN = list(list(model = rpart)),
> cFUN = response)
>
> 10-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.2059
>
> >
> >
> > ## Keywords: 'datasets'.
> >
> >
> > cleanEx(); ..nameEx <- "bagging"
> > ###--- >>> `bagging' <<<----- Bagging Classification, Regression and Survival Trees
> >
> > ## alias help(bagging)
> > ## alias help(ipredbagg)
> > ## alias help(ipredbagg.factor)
> > ## alias help(ipredbagg.numeric)
> > ## alias help(ipredbagg.Surv)
> > ## alias help(ipredbagg.default)
> > ## alias help(bagging.data.frame)
> > ## alias help(bagging.default)
> >
> > ##___ Examples ___:
> >
> >
> > # Classification: Breast Cancer data
> >
> > data(BreastCancer)
> >
> > # Test set error bagging (nbagg = 50): 3.7% (Breiman, 1998, Table 5)
> >
> > mod <- bagging(Class ~ Cl.thickness + Cell.size
182,196c238,269
< + print(mod)
< +
< + # Test set error bagging (nbagg=50): 7.9% (Breiman, 1996a, Table 2)
< +
< + data(Ionosphere)
< + Ionosphere$V2 <- NULL # constant within groups
< +
< + bagging(Class ~ ., data=Ionosphere, coob=TRUE)
< +
< + # Double-Bagging: combine LDA and classification trees
< +
< + # predict returns the linear discriminant values, i.e. linear combinations
< + # of the original predictors
< +
< + comb.lda <- list(list(model=lda, predict=function(obj, newdata)
---
> > print(mod)
>
> Bagging classification trees with 25 bootstrap replications
>
> Call: bagging.data.frame(formula = Class ~ Cl.thickness + Cell.size +
> Cell.shape + Marg.adhesion + Epith.c.size + Bare.nuclei +
> Bl.cromatin + Normal.nucleoli + Mitoses, data = BreastCancer,
> coob = TRUE)
>
> Out-of-bag estimate of misclassification error: 0.0425
>
> >
> > # Test set error bagging (nbagg=50): 7.9% (Breiman, 1996a, Table 2)
> >
> > data(Ionosphere)
> > Ionosphere$V2 <- NULL # constant within groups
> >
> > bagging(Class ~ ., data=Ionosphere, coob=TRUE)
>
> Bagging classification trees with 25 bootstrap replications
>
> Call: bagging.data.frame(formula = Class ~ ., data = Ionosphere, coob = TRUE)
>
> Out-of-bag estimate of misclassification error: 0.0912
>
> >
> > # Double-Bagging: combine LDA and classification trees
> >
> > # predict returns the linear discriminant values, i.e. linear combinations
> > # of the original predictors
> >
> > comb.lda <- list(list(model=lda, predict=function(obj, newdata)
198,229c271,319
< +
< + # Note: out-of-bag estimator is not available in this situation, use
< + # errorest
< +
< + mod <- bagging(Class ~ ., data=Ionosphere, comb=comb.lda)
< +
< + predict(mod, Ionosphere[1:10,])
< +
< + # Regression:
< +
< + data(BostonHousing)
< +
< + # Test set error (nbagg=25, trees pruned): 3.41 (Breiman, 1996a, Table 8)
< +
< + mod <- bagging(medv ~ ., data=BostonHousing, coob=TRUE)
< + print(mod)
< +
< + learn <- as.data.frame(mlbench.friedman1(200))
< +
< + # Test set error (nbagg=25, trees pruned): 2.47 (Breiman, 1996a, Table 8)
< +
< + mod <- bagging(y ~ ., data=learn, coob=TRUE)
< + print(mod)
< +
< + # Survival data
< +
< + # Brier score for censored data estimated by
< + # 10 times 10-fold cross-validation: 0.2 (Hothorn et al,
< + # 2002)
< +
< + data(DLBCL)
< + mod <- bagging(Surv(time,cens) ~ MGEc.1 + MGEc.2 + MGEc.3 + MGEc.4 + MGEc.5 +
---
> >
> > # Note: out-of-bag estimator is not available in this situation, use
> > # errorest
> >
> > mod <- bagging(Class ~ ., data=Ionosphere, comb=comb.lda)
> >
> > predict(mod, Ionosphere[1:10,])
> [1] good bad good bad good bad good bad good bad
> Levels: bad good
> >
> > # Regression:
> >
> > data(BostonHousing)
> >
> > # Test set error (nbagg=25, trees pruned): 3.41 (Breiman, 1996a, Table 8)
> >
> > mod <- bagging(medv ~ ., data=BostonHousing, coob=TRUE)
> > print(mod)
>
> Bagging regression trees with 25 bootstrap replications
>
> Call: bagging.data.frame(formula = medv ~ ., data = BostonHousing,
> coob = TRUE)
>
> Out-of-bag estimate of root mean squared error: 4.0209
>
> >
> > learn <- as.data.frame(mlbench.friedman1(200))
> >
> > # Test set error (nbagg=25, trees pruned): 2.47 (Breiman, 1996a, Table 8)
> >
> > mod <- bagging(y ~ ., data=learn, coob=TRUE)
> > print(mod)
>
> Bagging regression trees with 25 bootstrap replications
>
> Call: bagging.data.frame(formula = y ~ ., data = learn, coob = TRUE)
>
> Out-of-bag estimate of root mean squared error: 2.9212
>
> >
> > # Survival data
> >
> > # Brier score for censored data estimated by
> > # 10 times 10-fold cross-validation: 0.2 (Hothorn et al,
> > # 2002)
> >
> > data(DLBCL)
> > mod <- bagging(Surv(time,cens) ~ MGEc.1 + MGEc.2 + MGEc.3 + MGEc.4 + MGEc.5 +
232,255c322,354
< +
< + print(mod)
< +
< +
< + ## Keywords: 'tree'.
< +
< +
< + cleanEx(); ..nameEx <- "errorest"
< + ###--- >>> `errorest' <<<----- Estimators of Prediction Error
< +
< + ## alias help(errorest)
< + ## alias help(errorest.data.frame)
< + ## alias help(errorest.default)
< + ## alias help(errorestinclass)
< +
< + ##___ Examples ___:
< +
< +
< + # Classification
< +
< + data(iris)
< +
< + # force predict to return class labels only
< + mypredict.lda <- function(object, newdata)
---
> >
> > print(mod)
>
> Bagging survival trees with 25 bootstrap replications
>
> Call: bagging.data.frame(formula = Surv(time, cens) ~ MGEc.1 + MGEc.2 +
> MGEc.3 + MGEc.4 + MGEc.5 + MGEc.6 + MGEc.7 + MGEc.8 + MGEc.9 +
> MGEc.10 + IPI, data = DLBCL, coob = TRUE)
>
> Out-of-bag estimate of Brier's score: 0.1924
>
> >
> >
> > ## Keywords: 'tree'.
> >
> >
> > cleanEx(); ..nameEx <- "errorest"
> > ###--- >>> `errorest' <<<----- Estimators of Prediction Error
> >
> > ## alias help(errorest)
> > ## alias help(errorest.data.frame)
> > ## alias help(errorest.default)
> > ## alias help(errorestinclass)
> >
> > ##___ Examples ___:
> >
> >
> > # Classification
> >
> > data(iris)
> >
> > # force predict to return class labels only
> > mypredict.lda <- function(object, newdata)
257,259c356,358
< +
< + # 10-fold cv of LDA for Iris data
< + errorest(Species ~ ., data=iris, model=lda,
---
> >
> > # 10-fold cv of LDA for Iris data
> > errorest(Species ~ ., data=iris, model=lda,
261,265c360,373
< +
< + data(PimaIndiansDiabetes)
< +
< + # 632+ bootstrap of LDA for Diabetes data
< + errorest(diabetes ~ ., data=PimaIndiansDiabetes, model=lda,
---
>
> Call:
> errorest.data.frame(formula = Species ~ ., data = iris, model = lda,
> predict = mypredict.lda, estimator = "cv")
>
> 10-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.02
>
> >
> > data(PimaIndiansDiabetes)
> >
> > # 632+ bootstrap of LDA for Diabetes data
> > errorest(diabetes ~ ., data=PimaIndiansDiabetes, model=lda,
267,276c375,394
< +
< + data(Glass)
< +
< + # LDA has cross-validated misclassification error of
< + # 38% (Ripley, 1996, page 98)
< +
< + # Pruned trees about 32% (Ripley, 1996, page 230)
< +
< + # use stratified sampling here, i.e. preserve the class proportions
< + errorest(Type ~ ., data=Glass, model=lda,
---
>
> Call:
> errorest.data.frame(formula = diabetes ~ ., data = PimaIndiansDiabetes,
> model = lda, predict = mypredict.lda, estimator = "632plus")
>
> .632+ Bootstrap estimator of misclassification error
> with 25 bootstrap replications
>
> Misclassification error: 0.2282
>
> >
> > data(Glass)
> >
> > # LDA has cross-validated misclassification error of
> > # 38% (Ripley, 1996, page 98)
> >
> > # Pruned trees about 32% (Ripley, 1996, page 230)
> >
> > # use stratified sampling here, i.e. preserve the class proportions
> > errorest(Type ~ ., data=Glass, model=lda,
278,280c396,407
< +
< + # force predict to return class labels
< + mypredict.rpart <- function(object, newdata)
---
>
> Call:
> errorest.data.frame(formula = Type ~ ., data = Glass, model = lda,
> predict = mypredict.lda, est.para = control.errorest(strat = TRUE))
>
> 10-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.3785
>
> >
> > # force predict to return class labels
> > mypredict.rpart <- function(object, newdata)
282,283c409,410
< +
< + pruneit <- function(formula, ...)
---
> >
> > pruneit <- function(formula, ...)
285,286c412,413
< +
< + errorest(Type ~ ., data=Glass, model=pruneit,
---
> >
> > errorest(Type ~ ., data=Glass, model=pruneit,
288,293c415,429
< +
< + # compute sensitivity and specifity for stabilised LDA
< +
< + data(GlaucomaM)
< +
< + error <- errorest(Class ~ ., data=GlaucomaM, model=slda,
---
>
> Call:
> errorest.data.frame(formula = Type ~ ., data = Glass, model = pruneit,
> predict = mypredict.rpart, est.para = control.errorest(strat = TRUE))
>
> 10-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.3131
>
> >
> > # compute sensitivity and specifity for stabilised LDA
> >
> > data(GlaucomaM)
> >
> > error <- errorest(Class ~ ., data=GlaucomaM, model=slda,
295,312c431,450
< +
< + # sensitivity
< +
< + mean(error$predictions[GlaucomaM$Class == "glaucoma"] != "glaucoma")
< +
< + # specifity
< +
< + mean(error$predictions[GlaucomaM$Class == "normal"] != "normal")
< +
< + # Indirect Classification: Smoking data
< +
< + data(Smoking)
< + # Set three groups of variables:
< + # 1) explanatory variables are: TarY, NicY, COY, Sex, Age
< + # 2) intermediate variables are: TVPS, BPNL, COHB
< + # 3) response (resp) is defined by:
< +
< + resp <- function(data){
---
> >
> > # sensitivity
> >
> > mean(error$predictions[GlaucomaM$Class == "glaucoma"] != "glaucoma")
> [1] 0.1938776
> >
> > # specifity
> >
> > mean(error$predictions[GlaucomaM$Class == "normal"] != "normal")
> [1] 0.1326531
> >
> > # Indirect Classification: Smoking data
> >
> > data(Smoking)
> > # Set three groups of variables:
> > # 1) explanatory variables are: TarY, NicY, COY, Sex, Age
> > # 2) intermediate variables are: TVPS, BPNL, COHB
> > # 3) response (resp) is defined by:
> >
> > resp <- function(data){
318,328c456,466
< +
< + response <- resp(Smoking[ ,c("TVPS", "BPNL", "COHB")])
< + smoking <- cbind(Smoking, response)
< +
< + formula <- response~TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age
< +
< + # Estimation per leave-one-out estimate for the misclassification is
< + # 36.36% (Hand et al., 2001), using indirect classification with
< + # linear models
< +
< + errorest(formula, data = smoking, model = inclass,
---
> >
> > response <- resp(Smoking[ ,c("TVPS", "BPNL", "COHB")])
> > smoking <- cbind(Smoking, response)
> >
> > formula <- response~TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age
> >
> > # Estimation per leave-one-out estimate for the misclassification is
> > # 36.36% (Hand et al., 2001), using indirect classification with
> > # linear models
> >
> > errorest(formula, data = smoking, model = inclass,
331,337c469,485
< +
< + # Regression
< +
< + data(BostonHousing)
< +
< + # 10-fold cv of lm for Boston Housing data
< + errorest(medv ~ ., data=BostonHousing, model=lm,
---
>
> Call:
> errorest.data.frame(formula = formula, data = smoking, model = inclass,
> estimator = "cv", est.para = control.errorest(k = nrow(smoking)),
> pFUN = list(list(model = lm)), cFUN = resp)
>
> 55-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.3273
>
> >
> > # Regression
> >
> > data(BostonHousing)
> >
> > # 10-fold cv of lm for Boston Housing data
> > errorest(medv ~ ., data=BostonHousing, model=lm,
339,340c487,497
< +
< + mylm <- function(formula, data) {
---
>
> Call:
> errorest.data.frame(formula = medv ~ ., data = BostonHousing,
> model = lm, est.para = control.errorest(random = FALSE))
>
> 10-fold cross-validation estimator of root mean squared error
>
> Root mean squared error: 5.877
>
> >
> > mylm <- function(formula, data) {
344,345c501,502
< +
< + errorest(medv ~ ., data=BostonHousing, model=mylm,
---
> >
> > errorest(medv ~ ., data=BostonHousing, model=mylm,
347,357c504,523
< +
< +
< + # Survival data
< +
< + data(GBSG2)
< +
< + # prediction is fitted Kaplan-Meier
< + predict.survfit <- function(object, newdata) object
< +
< + # 5-fold cv of Kaplan-Meier for GBSG2 study
< + errorest(Surv(time, cens) ~ 1, data=GBSG2, model=survfit,
---
>
> Call:
> errorest.data.frame(formula = medv ~ ., data = BostonHousing,
> model = mylm, est.para = control.errorest(random = FALSE))
>
> 10-fold cross-validation estimator of root mean squared error
>
> Root mean squared error: 5.877
>
> >
> >
> > # Survival data
> >
> > data(GBSG2)
> >
> > # prediction is fitted Kaplan-Meier
> > predict.survfit <- function(object, newdata) object
> >
> > # 5-fold cv of Kaplan-Meier for GBSG2 study
> > errorest(Surv(time, cens) ~ 1, data=GBSG2, model=survfit,
359,381c525,556
< +
< +
< + ## Keywords: 'misc'.
< +
< +
< + cleanEx(); ..nameEx <- "inclass"
< + ###--- >>> `inclass' <<<----- Indirect Classification
< +
< + ## alias help(inclass)
< + ## alias help(inclass.formula)
< + ## alias help(inclass.default)
< + ## alias help(inclass.flist)
< +
< + ##___ Examples ___:
< +
< +
< + data(Smoking)
< + # Set three groups of variables:
< + # 1) explanatory variables are: TarY, NicY, COY, Sex, Age
< + # 2) intermediate variables are: TVPS, BPNL, COHB
< + # 3) response (resp) is defined by:
< +
< + resp <- function(data){
---
>
> Call:
> errorest.data.frame(formula = Surv(time, cens) ~ 1, data = GBSG2,
> model = survfit, predict = predict.survfit, est.para = control.errorest(k = 5))
>
> 5-fold cross-validation estimator of Brier's score
>
> Brier's score: 0.1881
>
> >
> >
> > ## Keywords: 'misc'.
> >
> >
> > cleanEx(); ..nameEx <- "inclass"
> > ###--- >>> `inclass' <<<----- Indirect Classification
> >
> > ## alias help(inclass)
> > ## alias help(inclass.formula)
> > ## alias help(inclass.default)
> > ## alias help(inclass.flist)
> >
> > ##___ Examples ___:
> >
> >
> > data(Smoking)
> > # Set three groups of variables:
> > # 1) explanatory variables are: TarY, NicY, COY, Sex, Age
> > # 2) intermediate variables are: TVPS, BPNL, COHB
> > # 3) response (resp) is defined by:
> >
> > resp <- function(data){
387,409c562,589
< +
< + response <- resp(Smoking[ ,c("TVPS", "BPNL", "COHB")])
< + smoking <- data.frame(Smoking, response)
< +
< + formula <- response~TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age
< +
< + inclass(formula, pFUN = list(list(model = lm)), cFUN = resp, data = smoking)
< +
< +
< + ## Keywords: 'misc'.
< +
< +
< + cleanEx(); ..nameEx <- "ipredknn"
< + ###--- >>> `ipredknn' <<<----- k-Nearest Neighbour Classification
< +
< + ## alias help(ipredknn)
< +
< + ##___ Examples ___:
< +
< +
< + learn <- as.data.frame(mlbench.twonorm(300))
< +
< + mypredict.knn <- function(object, newdata)
---
> >
> > response <- resp(Smoking[ ,c("TVPS", "BPNL", "COHB")])
> > smoking <- data.frame(Smoking, response)
> >
> > formula <- response~TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age
> >
> > inclass(formula, pFUN = list(list(model = lm)), cFUN = resp, data = smoking)
>
> Indirect classification, with 3 intermediate variables:
> TVPS BPNL COHB
>
> Predictive model per intermediate is lm
> >
> >
> > ## Keywords: 'misc'.
> >
> >
> > cleanEx(); ..nameEx <- "ipredknn"
> > ###--- >>> `ipredknn' <<<----- k-Nearest Neighbour Classification
> >
> > ## alias help(ipredknn)
> >
> > ##___ Examples ___:
> >
> >
> > learn <- as.data.frame(mlbench.twonorm(300))
> >
> > mypredict.knn <- function(object, newdata)
411,412c591,592
< +
< + errorest(classes ~., data=learn, model=ipredknn,
---
> >
> > errorest(classes ~., data=learn, model=ipredknn,
414,487c594,693
< +
< +
< + ## Keywords: 'multivariate'.
< +
< +
< + cleanEx(); ..nameEx <- "kfoldcv"
< + ###--- >>> `kfoldcv' <<<----- Subsamples for k-fold Cross-Validation
< +
< + ## alias help(kfoldcv)
< +
< + ##___ Examples ___:
< +
< +
< + # 10-fold CV with N = 91
< +
< + kfoldcv(10, 91)
< +
< +
< + k <- sample(5:15, 1)
< + k
< + N <- sample(50:150, 1)
< + N
< + stopifnot(sum(kfoldcv(k, N)) == N)
< +
< +
< +
< + ## Keywords: 'misc'.
< +
< +
< + cleanEx(); ..nameEx <- "predict.bagging"
< + ###--- >>> `predict.classbagg' <<<----- Predictions from Bagging Trees
< +
< + ## alias help(predict.classbagg)
< + ## alias help(predict.regbagg)
< + ## alias help(predict.survbagg)
< +
< + ##___ Examples ___:
< +
< +
< + data(Ionosphere)
< + Ionosphere$V2 <- NULL # constant within groups
< +
< + # nbagg = 10 for performance reasons here
< + mod <- bagging(Class ~ ., data=Ionosphere)
< +
< + # out-of-bag estimate
< +
< + mean(predict(mod) != Ionosphere$Class)
< +
< + # predictions for the first 10 observations
< +
< + predict(mod, newdata=Ionosphere[1:10,])
< +
< + predict(mod, newdata=Ionosphere[1:10,], type="prob")
< +
< +
< + ## Keywords: 'tree'.
< +
< +
< + cleanEx(); ..nameEx <- "predict.inclass"
< + ###--- >>> `predict.inclass' <<<----- Predictions from an Inclass Object
< +
< + ## alias help(predict.inclass)
< +
< + ##___ Examples ___:
< +
< + # Simulation model, classification rule following Hand et al. (2001)
< +
< + theta90 <- varset(N = 1000, sigma = 0.1, theta = 90, threshold = 0)
< +
< + dataset <- as.data.frame(cbind(theta90$explanatory, theta90$intermediate))
< + names(dataset) <- c(colnames(theta90$explanatory), colnames(theta90$intermediate))
< +
< + classify <- function(Y, threshold = 0) {
---
>
> Call:
> errorest.data.frame(formula = classes ~ ., data = learn, model = ipredknn,
> predict = mypredict.knn)
>
> 10-fold cross-validation estimator of misclassification error
>
> Misclassification error: 0.0267
>
> >
> >
> > ## Keywords: 'multivariate'.
> >
> >
> > cleanEx(); ..nameEx <- "kfoldcv"
> > ###--- >>> `kfoldcv' <<<----- Subsamples for k-fold Cross-Validation
> >
> > ## alias help(kfoldcv)
> >
> > ##___ Examples ___:
> >
> >
> > # 10-fold CV with N = 91
> >
> > kfoldcv(10, 91)
> [1] 10 9 9 9 9 9 9 9 9 9
> >
> >
> > k <- sample(5:15, 1)
> > k
> [1] 8
> > N <- sample(50:150, 1)
> > N
> [1] 78
> > stopifnot(sum(kfoldcv(k, N)) == N)
> >
> >
> >
> > ## Keywords: 'misc'.
> >
> >
> > cleanEx(); ..nameEx <- "predict.bagging"
> > ###--- >>> `predict.classbagg' <<<----- Predictions from Bagging Trees
> >
> > ## alias help(predict.classbagg)
> > ## alias help(predict.regbagg)
> > ## alias help(predict.survbagg)
> >
> > ##___ Examples ___:
> >
> >
> > data(Ionosphere)
> > Ionosphere$V2 <- NULL # constant within groups
> >
> > # nbagg = 10 for performance reasons here
> > mod <- bagging(Class ~ ., data=Ionosphere)
> >
> > # out-of-bag estimate
> >
> > mean(predict(mod) != Ionosphere$Class)
> [1] 0.0911681
> >
> > # predictions for the first 10 observations
> >
> > predict(mod, newdata=Ionosphere[1:10,])
> [1] good bad good bad good bad good bad good bad
> Levels: bad good
> >
> > predict(mod, newdata=Ionosphere[1:10,], type="prob")
> bad good
> [1,] 0.00 1.00
> [2,] 0.76 0.24
> [3,] 0.00 1.00
> [4,] 0.80 0.20
> [5,] 0.00 1.00
> [6,] 1.00 0.00
> [7,] 0.00 1.00
> [8,] 1.00 0.00
> [9,] 0.00 1.00
> [10,] 1.00 0.00
> >
> >
> > ## Keywords: 'tree'.
> >
> >
> > cleanEx(); ..nameEx <- "predict.inclass"
> > ###--- >>> `predict.inclass' <<<----- Predictions from an Inclass Object
> >
> > ## alias help(predict.inclass)
> >
> > ##___ Examples ___:
> >
> > # Simulation model, classification rule following Hand et al. (2001)
> >
> > theta90 <- varset(N = 1000, sigma = 0.1, theta = 90, threshold = 0)
> >
> > dataset <- as.data.frame(cbind(theta90$explanatory, theta90$intermediate))
> > names(dataset) <- c(colnames(theta90$explanatory), colnames(theta90$intermediate))
> >
> > classify <- function(Y, threshold = 0) {
494,510c700,745
< +
< + response <- classify(dataset)
< + dataset <- data.frame(dataset)
< +
< + formula <- response~y1+y2~x1+x2
< +
< + fit <- inclass(formula, pFUN = list(list(model = lm)), cFUN = classify, data = dataset)
< +
< + predict(object = fit, newdata = dataset)
< +
< + data(Smoking)
< +
< + # explanatory variables are: TarY, NicY, COY, Sex, Age
< + # intermediate variables are: TVPS, BPNL, COHB
< + # reponse is defined by:
< +
< + classify <- function(data){
---
> >
> > response <- classify(dataset)
> > dataset <- data.frame(dataset)
> >
> > formula <- response~y1+y2~x1+x2
> >
> > fit <- inclass(formula, pFUN = list(list(model = lm)), cFUN = classify, data = dataset)
> >
> > predict(object = fit, newdata = dataset)
> [1] 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1
> [38] 1 1 0 0 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0
> [75] 1 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0
> [112] 1 0 1 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 1 0 0 1 0 1 0 1
> [149] 1 0 0 1 1 0 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1
> [186] 1 0 1 0 0 0 0 0 0 1 1 0 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0
> [223] 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 0 1 1 0 1 0 0
> [260] 1 0 0 0 1 1 0 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0
> [297] 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0
> [334] 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 1
> [371] 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 1
> [408] 1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 0 1
> [445] 1 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0
> [482] 1 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1
> [519] 1 0 0 0 1 1 0 1 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1 0
> [556] 0 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 0
> [593] 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 1 0
> [630] 0 0 0 1 1 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 1
> [667] 0 0 0 1 1 0 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0
> [704] 0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0
> [741] 1 1 1 1 1 0 0 1 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 1 0
> [778] 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 1 0
> [815] 1 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0 1
> [852] 1 1 0 0 0 1 0 1 0 1 1 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0
> [889] 0 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1
> [926] 0 0 0 0 0 1 0 0 0 1 1 1 0 0 1 1 1 1 1 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0
> [963] 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 1 0
> [1000] 0
> Levels: 0 1
> >
> > data(Smoking)
> >
> > # explanatory variables are: TarY, NicY, COY, Sex, Age
> > # intermediate variables are: TVPS, BPNL, COHB
> > # reponse is defined by:
> >
> > classify <- function(data){
516,532c751,770
< +
< + response <- classify(Smoking[ ,c("TVPS", "BPNL", "COHB")])
< + smoking <- data.frame(Smoking, response)
< +
< + formula <- response~TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age
< +
< + fit <- inclass(formula, pFUN = list(list(model = lm)), cFUN = classify, data = smoking)
< +
< + predict(object = fit, newdata = smoking)
< +
< + data(GlaucomaMVF)
< + glaucoma <- GlaucomaMVF
< + # explanatory variables are derived by laser scanning image and intra occular pressure
< + # intermediate variables are: clv, cs, lora
< + # response is defined by
< +
< + classify <- function (data) {
---
> >
> > response <- classify(Smoking[ ,c("TVPS", "BPNL", "COHB")])
> > smoking <- data.frame(Smoking, response)
> >
> > formula <- response~TVPS+BPNL+COHB~TarY+NicY+COY+Sex+Age
> >
> > fit <- inclass(formula, pFUN = list(list(model = lm)), cFUN = classify, data = smoking)
> >
> > predict(object = fit, newdata = smoking)
> [1] 1 1 0 1 0 1 1 0 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> [39] 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1
> Levels: 0 1
> >
> > data(GlaucomaMVF)
> > glaucoma <- GlaucomaMVF
> > # explanatory variables are derived by laser scanning image and intra occular pressure
> > # intermediate variables are: clv, cs, lora
> > # response is defined by
> >
> > classify <- function (data) {
542,543c780,781
< +
< + fit <- inbagg(Class~clv+lora+cs~., data = glaucoma, pFUN = list(list(model
---
> >
> > fit <- inbagg(Class~clv+lora+cs~., data = glaucoma, pFUN = list(list(model
545,740c783,826
< + predict(object = fit, newdata = glaucoma)
< +
< +
< + ## Keywords: 'misc'.
< +
< +
< + cleanEx(); ..nameEx <- "prune.bagging"
< + ###--- >>> `prune.classbagg' <<<----- Pruning for Bagging
< +
< + ## alias help(prune.classbagg)
< + ## alias help(prune.regbagg)
< + ## alias help(prune.survbagg)
< +
< + ##___ Examples ___:
< +
< +
< + data(Glass)
< +
< + mod <- bagging(Type ~ ., data=Glass, nbagg=10, coob=TRUE)
< + pmod <- prune(mod)
< + print(pmod)
< +
< +
< + ## Keywords: 'tree'.
< +
< +
< + cleanEx(); ..nameEx <- "rsurv"
< + ###--- >>> `rsurv' <<<----- Simulate Survival Data
< +
< + ## alias help(rsurv)
< +
< + ##___ Examples ___:
< +
< +
< + # 3*X1 + X2
< + simdat <- rsurv(500, model="C")
< + coxph(Surv(time, cens) ~ ., data=simdat)
< +
< +
< + ## Keywords: 'survival'.
< +
< +
< + cleanEx(); ..nameEx <- "sbrier"
< + ###--- >>> `sbrier' <<<----- Model Fit for Survival Data
< +
< + ## alias help(sbrier)
< +
< + ##___ Examples ___:
< +
< +
< + data(DLBCL)
< + smod <- Surv(DLBCL$time, DLBCL$cens)
< +
< + KM <- survfit(smod)
< + # integrated Brier score up to max(DLBCL$time)
< + sbrier(smod, KM)
< +
< + # integrated Brier score up to time=50
< + sbrier(smod, KM, btime=c(0, 50))
< +
< + # Brier score for time=50
< + sbrier(smod, KM, btime=50)
< +
< + # a "real" model: one single survival tree with Intern. Prognostic Index
< + # and mean gene expression in the first cluster as predictors
< + mod <- bagging(Surv(time, cens) ~ MGEc.1 + IPI, data=DLBCL, nbagg=1)
< +
< + # this is a list of survfit objects (==KM-curves), one for each observation
< + # in DLBCL
< + pred <- predict(mod, newdata=DLBCL)
< +
< + # integrated Brier score up to max(time)
< + sbrier(smod, pred)
< +
< + # Brier score at time=50
< + sbrier(smod, pred, btime=50)
< + # artificial examples and illustrations
< +
< + cleans <- function(x) { attr(x, "time") <- NULL; names(x) <- NULL; x }
< +
< + n <- 100
< + time <- rpois(n, 20)
< + cens <- rep(1, n)
< +
< + # checks, Graf et al. page 2536, no censoring at all!
< + # no information: \pi(t) = 0.5
< +
< + a <- sbrier(Surv(time, cens), rep(0.5, n), time[50])
< + stopifnot(all.equal(cleans(a),0.25))
< +
< + # some information: \pi(t) = S(t)
< +
< + n <- 100
< + time <- 1:100
< + mod <- survfit(Surv(time, cens))
< + a <- sbrier(Surv(time, cens), rep(list(mod), n))
< + mymin <- mod$surv * (1 - mod$surv)
< + stopifnot(all.equal(cleans(a),sum(mymin)/max(time)))
< +
< + # independent of ordering
< + rand <- sample(1:100)
< + b <- sbrier(Surv(time, cens)[rand], rep(list(mod), n)[rand])
< + stopifnot(all.equal(cleans(a), cleans(b)))
< +
< +
< + # total information: \pi(t | X) known for every obs
< +
< + time <- 1:10
< + cens <- rep(1,10)
< + pred <- diag(10)
< + pred[upper.tri(pred)] <- 1
< + diag(pred) <- 0
< + #
< + # a <- sbrier(Surv(time, cens), pred)
< + # stopifnot(all.equal(a, 0))
< + #
< +
< +
< + # 2 groups at different risk
< +
< + time <- c(1:10, 21:30)
< + strata <- c(rep(1, 10), rep(2, 10))
< + cens <- rep(1, length(time))
< +
< + # no information about the groups
< +
< + a <- sbrier(Surv(time, cens), survfit(Surv(time, cens)))
< + b <- sbrier(Surv(time, cens), rep(list(survfit(Surv(time, cens))), 20))
< + stopifnot(all.equal(a, b))
< +
< + # risk groups known
< +
< + mod <- survfit(Surv(time, cens) ~ strata)
< + b <- sbrier(Surv(time, cens), c(rep(list(mod[1]), 10), rep(list(mod[2]), 10)))
< + stopifnot(a > b)
< +
< +
< + ## Keywords: 'survival'.
< +
< +
< + cleanEx(); ..nameEx <- "slda"
< + ###--- >>> `slda' <<<----- Stabilised Linear Discriminant Analysis
< +
< + ## alias help(slda)
< + ## alias help(slda.default)
< + ## alias help(slda.formula)
< + ## alias help(slda.factor)
< +
< + ##___ Examples ___:
< +
< +
< + learn <- as.data.frame(mlbench.twonorm(100))
< + test <- as.data.frame(mlbench.twonorm(1000))
< +
< + mlda <- lda(classes ~ ., data=learn)
< + mslda <- slda(classes ~ ., data=learn)
< +
< + print(mean(predict(mlda, newdata=test)$class != test$classes))
< + print(mean(predict(mslda, newdata=test)$class != test$classes))
< +
< +
< + ## Keywords: 'multivariate'.
< +
< +
< + cleanEx(); ..nameEx <- "varset"
< + ###--- >>> `varset' <<<----- Simulation Model
< +
< + ## alias help(varset)
< +
< + ##___ Examples ___:
< +
< +
< + theta90 <- varset(N = 1000, sigma = 0.1, theta = 90, threshold = 0)
< + theta0 <- varset(N = 1000, sigma = 0.1, theta = 0, threshold = 0)
< + par(mfrow = c(1, 2))
< + plot(theta0$intermediate)
< + plot(theta90$intermediate)
< +
< +
< + ## Keywords: 'misc'.
< +
< +
< + par(get("par.postscript", env = .CheckExEnv))
< + cat("Time elapsed: ", proc.time() - get("ptime", env = .CheckExEnv),"\n")
< + dev.off(); quit('no')
< + }
<
< Bagging classification trees with 25 bootstrap replications
<
< Call: bagging.data.frame(formula = Class ~ Cl.thickness + Cell.size +
< Cell.shape + Marg.adhesion + Epith.c.size + Bare.nuclei +
< Bl.cromatin + Normal.nucleoli + Mitoses, data = BreastCancer,
< coob = TRUE)
<
< Out-of-bag estimate of misclassification error: 0.0381
<
---
> > predict(object = fit, newdata = glaucoma)
> [1] normal normal normal glaucoma normal normal normal normal
> [9] normal normal normal normal normal normal normal normal
> [17] glaucoma normal normal normal normal glaucoma normal glaucoma
> [25] glaucoma normal normal normal normal glaucoma normal normal
> [33] normal normal glaucoma normal normal normal glaucoma glaucoma
> [41] normal normal normal glaucoma normal normal normal normal
> [49] normal normal normal normal normal glaucoma normal normal
> [57] normal normal normal glaucoma normal normal normal normal
> [65] normal normal normal glaucoma normal normal normal normal
> [73] glaucoma normal glaucoma normal normal normal normal normal
> [81] glaucoma normal normal normal glaucoma glaucoma glaucoma glaucoma
> [89] normal glaucoma glaucoma normal glaucoma glaucoma normal glaucoma
> [97] glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma
> [105] glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma
> [113] glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma
> [121] glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma
> [129] glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma
> [137] glaucoma glaucoma normal normal glaucoma glaucoma glaucoma glaucoma
> [145] glaucoma glaucoma normal glaucoma glaucoma glaucoma normal glaucoma
> [153] glaucoma glaucoma glaucoma normal glaucoma glaucoma glaucoma glaucoma
> [161] normal glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma glaucoma
> [169] glaucoma glaucoma
> Levels: glaucoma normal
> >
> >
> > ## Keywords: 'misc'.
> >
> >
> > cleanEx(); ..nameEx <- "prune.bagging"
> > ###--- >>> `prune.classbagg' <<<----- Pruning for Bagging
> >
> > ## alias help(prune.classbagg)
> > ## alias help(prune.regbagg)
> > ## alias help(prune.survbagg)
> >
> > ##___ Examples ___:
> >
> >
> > data(Glass)
> >
> > mod <- bagging(Type ~ ., data=Glass, nbagg=10, coob=TRUE)
> > pmod <- prune(mod)
> > print(pmod)
742c828
< Bagging regression trees with 25 bootstrap replications
---
> Bagging classification trees with 10 bootstrap replications
744c830
< Call: bagging.data.frame(formula = medv ~ ., data = BostonHousing,
---
> Call: bagging.data.frame(formula = Type ~ ., data = Glass, nbagg = 10,
747,755c833
< Out-of-bag estimate of root mean squared error: 3.9809
<
<
< Bagging regression trees with 25 bootstrap replications
<
< Call: bagging.data.frame(formula = y ~ ., data = learn, coob = TRUE)
<
< Out-of-bag estimate of root mean squared error: 2.8832
<
---
> Out-of-bag estimate of misclassification error: 0.3411
757,766c835,852
< Bagging survival trees with 25 bootstrap replications
<
< Call: bagging.data.frame(formula = Surv(time, cens) ~ MGEc.1 + MGEc.2 +
< MGEc.3 + MGEc.4 + MGEc.5 + MGEc.6 + MGEc.7 + MGEc.8 + MGEc.9 +
< MGEc.10 + IPI, data = DLBCL, coob = TRUE)
<
< Out-of-bag estimate of Brier's score: 0.1925
<
<
< Bagging classification trees with 10 bootstrap replications
---
> >
> >
> > ## Keywords: 'tree'.
> >
> >
> > cleanEx(); ..nameEx <- "rsurv"
> > ###--- >>> `rsurv' <<<----- Simulate Survival Data
> >
> > ## alias help(rsurv)
> >
> > ##___ Examples ___:
> >
> >
> > # 3*X1 + X2
> > simdat <- rsurv(500, model="C")
> > coxph(Surv(time, cens) ~ ., data=simdat)
> Call:
> coxph(formula = Surv(time, cens) ~ ., data = simdat)
768,769d853
< Call: bagging.data.frame(formula = Type ~ ., data = Glass, nbagg = 10,
< coob = TRUE)
771c855,860
< Out-of-bag estimate of misclassification error: 0.3224
---
> coef exp(coef) se(coef) z p
> X1 3.2257 25.172 0.204 15.810 0.0e+00
> X2 0.9599 2.611 0.164 5.845 5.1e-09
> X3 -0.0558 0.946 0.157 -0.357 7.2e-01
> X4 -0.1049 0.900 0.163 -0.643 5.2e-01
> X5 -0.0833 0.920 0.158 -0.527 6.0e-01
772a862,1003
> Likelihood ratio test=275 on 5 df, p=0 n= 500
> >
> >
> > ## Keywords: 'survival'.
> >
> >
> > cleanEx(); ..nameEx <- "sbrier"
> > ###--- >>> `sbrier' <<<----- Model Fit for Survival Data
> >
> > ## alias help(sbrier)
> >
> > ##___ Examples ___:
> >
> >
> > data(DLBCL)
> > smod <- Surv(DLBCL$time, DLBCL$cens)
> >
> > KM <- survfit(smod)
> > # integrated Brier score up to max(DLBCL$time)
> > sbrier(smod, KM)
> integrated Brier score
> 0.2076454
> attr(,"time")
> [1] 1.3 129.9
> >
> > # integrated Brier score up to time=50
> > sbrier(smod, KM, btime=c(0, 50))
> integrated Brier score
> 0.2141826
> attr(,"time")
> [1] 1.3 39.6
> >
> > # Brier score for time=50
> > sbrier(smod, KM, btime=50)
> Brier score
> 0.249375
> attr(,"time")
> [1] 50
> >
> > # a "real" model: one single survival tree with Intern. Prognostic Index
> > # and mean gene expression in the first cluster as predictors
> > mod <- bagging(Surv(time, cens) ~ MGEc.1 + IPI, data=DLBCL, nbagg=1)
> >
> > # this is a list of survfit objects (==KM-curves), one for each observation
> > # in DLBCL
> > pred <- predict(mod, newdata=DLBCL)
> >
> > # integrated Brier score up to max(time)
> > sbrier(smod, pred)
> integrated Brier score
> 0.1408247
> attr(,"time")
> [1] 1.3 129.9
> >
> > # Brier score at time=50
> > sbrier(smod, pred, btime=50)
> Brier score
> 0.1774478
> attr(,"time")
> [1] 50
> > # artificial examples and illustrations
> >
> > cleans <- function(x) { attr(x, "time") <- NULL; names(x) <- NULL; x }
> >
> > n <- 100
> > time <- rpois(n, 20)
> > cens <- rep(1, n)
> >
> > # checks, Graf et al. page 2536, no censoring at all!
> > # no information: \pi(t) = 0.5
> >
> > a <- sbrier(Surv(time, cens), rep(0.5, n), time[50])
> > stopifnot(all.equal(cleans(a),0.25))
> >
> > # some information: \pi(t) = S(t)
> >
> > n <- 100
> > time <- 1:100
> > mod <- survfit(Surv(time, cens))
> > a <- sbrier(Surv(time, cens), rep(list(mod), n))
> > mymin <- mod$surv * (1 - mod$surv)
> > stopifnot(all.equal(cleans(a),sum(mymin)/max(time)))
> >
> > # independent of ordering
> > rand <- sample(1:100)
> > b <- sbrier(Surv(time, cens)[rand], rep(list(mod), n)[rand])
> > stopifnot(all.equal(cleans(a), cleans(b)))
> >
> >
> > # total information: \pi(t | X) known for every obs
> >
> > time <- 1:10
> > cens <- rep(1,10)
> > pred <- diag(10)
> > pred[upper.tri(pred)] <- 1
> > diag(pred) <- 0
> > #
> > # a <- sbrier(Surv(time, cens), pred)
> > # stopifnot(all.equal(a, 0))
> > #
> >
> >
> > # 2 groups at different risk
> >
> > time <- c(1:10, 21:30)
> > strata <- c(rep(1, 10), rep(2, 10))
> > cens <- rep(1, length(time))
> >
> > # no information about the groups
> >
> > a <- sbrier(Surv(time, cens), survfit(Surv(time, cens)))
> > b <- sbrier(Surv(time, cens), rep(list(survfit(Surv(time, cens))), 20))
> > stopifnot(all.equal(a, b))
> >
> > # risk groups known
> >
> > mod <- survfit(Surv(time, cens) ~ strata)
> > b <- sbrier(Surv(time, cens), c(rep(list(mod[1]), 10), rep(list(mod[2]), 10)))
> > stopifnot(a > b)
> >
> >
> > ## Keywords: 'survival'.
> >
> >
> > cleanEx(); ..nameEx <- "slda"
> > ###--- >>> `slda' <<<----- Stabilised Linear Discriminant Analysis
> >
> > ## alias help(slda)
> > ## alias help(slda.default)
> > ## alias help(slda.formula)
> > ## alias help(slda.factor)
> >
> > ##___ Examples ___:
> >
> >
> > learn <- as.data.frame(mlbench.twonorm(100))
> > test <- as.data.frame(mlbench.twonorm(1000))
> >
> > mlda <- lda(classes ~ ., data=learn)
> > mslda <- slda(classes ~ ., data=learn)
> >
> > print(mean(predict(mlda, newdata=test)$class != test$classes))
773a1005
> > print(mean(predict(mslda, newdata=test)$class != test$classes))
774a1007,1034
> >
> >
> > ## Keywords: 'multivariate'.
> >
> >
> > cleanEx(); ..nameEx <- "varset"
> > ###--- >>> `varset' <<<----- Simulation Model
> >
> > ## alias help(varset)
> >
> > ##___ Examples ___:
> >
> >
> > theta90 <- varset(N = 1000, sigma = 0.1, theta = 90, threshold = 0)
> > theta0 <- varset(N = 1000, sigma = 0.1, theta = 0, threshold = 0)
> > par(mfrow = c(1, 2))
> > plot(theta0$intermediate)
> > plot(theta90$intermediate)
> >
> >
> > ## Keywords: 'misc'.
> >
> >
> > par(get("par.postscript", env = .CheckExEnv))
> > cat("Time elapsed: ", proc.time() - get("ptime", env = .CheckExEnv),"\n")
> > dev.off(); quit('no')
> null device
> 1
OK
make[1]: Leaving directory `/cygdrive/d/Rcompile/CRANpkg/check/1.8/ipred.Rcheck/tests'
OK
* checking package vignettes in 'inst/doc' ... OK
* creating ipred-manual.tex ... OK
* checking ipred-manual.tex ... OK