- using R Under development (unstable) (2018-04-18 r74618)
- using platform: x86_64-pc-linux-gnu (64-bit)
- using session charset: UTF-8
- checking for file ‘partykit/DESCRIPTION’ ... OK
- this is package ‘partykit’ version ‘1.2-0’
- checking package namespace information ... OK
- checking package dependencies ... OK
- checking if this is a source package ... OK
- checking if there is a namespace ... OK
- checking for executable files ... OK
- checking for hidden files and directories ... OK
- checking for portable file names ... OK
- checking for sufficient/correct file permissions ... OK
- checking serialization versions ... OK
- checking whether package ‘partykit’ can be installed ... OK
- checking package directory ... OK
- checking ‘build’ directory ... OK
- checking DESCRIPTION meta-information ... OK
- checking top-level files ... OK
- checking for left-over files ... OK
- checking index information ... OK
- checking package subdirectories ... OK
- checking R files for non-ASCII characters ... OK
- checking R files for syntax errors ... OK
- checking whether the package can be loaded ... OK
- checking whether the package can be loaded with stated dependencies ... OK
- checking whether the package can be unloaded cleanly ... OK
- checking whether the namespace can be loaded with stated dependencies ... OK
- checking whether the namespace can be unloaded cleanly ... OK
- checking loading without being on the library search path ... OK
- checking use of S3 registration ... OK
- checking dependencies in R code ... OK
- checking S3 generic/method consistency ... OK
- checking replacement functions ... OK
- checking foreign function calls ... OK
- checking R code for possible problems ... [30s/32s] OK
- checking Rd files ... OK
- checking Rd metadata ... OK
- checking Rd line widths ... OK
- checking Rd cross-references ... OK
- checking for missing documentation entries ... OK
- checking for code/documentation mismatches ... OK
- checking Rd \usage sections ... OK
- checking Rd contents ... OK
- checking for unstated dependencies in examples ... OK
- checking contents of ‘data’ directory ... OK
- checking data for non-ASCII characters ... OK
- checking data for ASCII and uncompressed saves ... OK
- checking line endings in shell scripts ... OK
- checking line endings in C/C++/Fortran sources/headers ... OK
- checking pragmas in C/C++ headers and code ... OK
- checking compilation flags used ... OK
- checking compiled code ... OK
- checking sizes of PDF files under ‘inst/doc’ ... OK
- checking installed files from ‘inst/doc’ ... OK
- checking files in ‘vignettes’ ... OK
- checking examples ... [23s/26s] OK
- checking differences from ‘partykit-Ex.Rout’ to ‘partykit-Ex.Rout.save’ ... OK
304,310d303
< Attaching package: 'survival'
<
< The following object is masked from 'package:rpart':
<
< solder
<
<
935,941d927
< Attaching package: 'survival'
<
< The following object is masked from 'package:rpart':
<
< solder
<
<
1077,1078c1063
< 'package:lmtest', 'package:zoo', 'package:car', 'package:carData',
< 'package:mlbench'
---
> 'package:lmtest', 'package:zoo', 'package:car', 'package:mlbench'
- checking for unstated dependencies in ‘tests’ ... OK
- checking tests ... [34s/41s] ERROR
Running ‘bugfixes.R’ [7s/8s]
Comparing ‘bugfixes.Rout’ to ‘bugfixes.Rout.save’ ...724,730d723
<
< Attaching package: 'survival'
<
< The following object is masked from 'package:rpart':
<
< solder
<
Running ‘regtest-MIA.R’ [2s/3s]
Comparing ‘regtest-MIA.Rout’ to ‘regtest-MIA.Rout.save’ ... OK
Running ‘regtest-cforest.R’ [11s/13s]
Comparing ‘regtest-cforest.Rout’ to ‘regtest-cforest.Rout.save’ ... OK
Running ‘regtest-ctree.R’ [2s/3s]
Comparing ‘regtest-ctree.Rout’ to ‘regtest-ctree.Rout.save’ ... OK
Running ‘regtest-glmtree.R’ [12s/13s]
Running the tests in ‘tests/regtest-glmtree.R’ failed.
Complete output:
>
> library("partykit")
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: rpart
> library("sandwich")
>
> set.seed(29)
> n <- 1000
> x <- runif(n)
> z <- runif(n)
> y <- rnorm(n, mean = x * c(-1, 1)[(z > 0.7) + 1], sd = 3)
> z_noise <- factor(sample(1:3, size = n, replace = TRUE))
> d <- data.frame(y = y, x = x, z = z, z_noise = z_noise)
>
>
> fmla <- as.formula("y ~ x | z + z_noise")
> fmly <- gaussian()
> fit <- partykit:::glmfit
>
> # versions of the data
> d1 <- d
> d1$z <- signif(d1$z, digits = 1)
>
> k <- 20
> zs_noise <- matrix(rnorm(n*k), nrow = n)
> colnames(zs_noise) <- paste0("z_noise_", 1:k)
> d2 <- cbind(d, zs_noise)
> fmla2 <- as.formula(paste("y ~ x | z + z_noise +",
+ paste0("z_noise_", 1:k, collapse = " + ")))
>
>
> d3 <- d2
> d3$z <- factor(sample(1:3, size = n, replace = TRUE, prob = c(0.1, 0.5, 0.4)))
> d3$y <- rnorm(n, mean = x * c(-1, 1)[(d3$z == 2) + 1], sd = 3)
>
> ## check weights
> w <- rep(1, n)
> w[1:10] <- 2
> (mw1 <- glmtree(formula = fmla, data = d, weights = w))
Generalized linear model tree (family: gaussian)
Model formula:
y ~ x | z + z_noise
Fitted party:
[1] root
| [2] z <= 0.70311: n = 706
| (Intercept) x
| -0.1447422 -0.8138701
| [3] z > 0.70311: n = 304
| (Intercept) x
| 0.07006626 0.73278593
Number of inner nodes: 1
Number of terminal nodes: 2
Number of parameters per node: 2
Objective function (negative log-likelihood): 2551.48
> (mw2 <- glmtree(formula = fmla, data = d, weights = w, caseweights = FALSE))
Generalized linear model tree (family: gaussian)
Model formula:
y ~ x | z + z_noise
Fitted party:
[1] root
| [2] z <= 0.70311: n = 704
| (Intercept) x
| -0.1447422 -0.8138701
| [3] z > 0.70311: n = 296
| (Intercept) x
| 0.07006626 0.73278593
Number of inner nodes: 1
Number of terminal nodes: 2
Number of parameters per node: 2
Objective function (negative log-likelihood): 2551.48
>
>
>
> ## check dfsplit
> (mmfluc2 <- mob(formula = fmla, data = d, fit = partykit:::glmfit))
Model-based recursive partitioning (partykit:::glmfit)
Model formula:
y ~ x | z + z_noise
Fitted party:
[1] root
| [2] z <= 0.70311: n = 704
| (Intercept) x
| -0.1619978 -0.7896293
| [3] z > 0.70311: n = 296
| (Intercept) x
| 0.08683535 0.65598287
Number of inner nodes: 1
Number of terminal nodes: 2
Number of parameters per node: 2
Objective function: 2551.673
> (mmfluc3 <- glmtree(formula = fmla, data = d))
Generalized linear model tree (family: gaussian)
Model formula:
y ~ x | z + z_noise
Fitted party:
[1] root
| [2] z <= 0.70311: n = 704
| (Intercept) x
| -0.1619978 -0.7896293
| [3] z > 0.70311: n = 296
| (Intercept) x
| 0.08683535 0.65598287
Number of inner nodes: 1
Number of terminal nodes: 2
Number of parameters per node: 2
Objective function (negative log-likelihood): 2551.673
> (mmfluc3_dfsplit <- glmtree(formula = fmla, data = d, dfsplit = 10))
Generalized linear model tree (family: gaussian)
Model formula:
y ~ x | z + z_noise
Fitted party:
[1] root
| [2] z <= 0.70311: n = 704
| (Intercept) x
| -0.1619978 -0.7896293
| [3] z > 0.70311: n = 296
| (Intercept) x
| 0.08683535 0.65598287
Number of inner nodes: 1
Number of terminal nodes: 2
Number of parameters per node: 2
Objective function (negative log-likelihood): 2551.673
>
>
> ## check tests
> library("strucchange")
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
> sctest(mmfluc3, node = 1) # does not yet work
Error in UseMethod("estfun") :
no applicable method for 'estfun' applied to an object of class "c('glmtree', 'modelparty', 'party')"
Calls: sctest -> sctest.default -> gefp -> scores
Execution halted
- checking for unstated dependencies in vignettes ... OK
- checking package vignettes in ‘inst/doc’ ... OK
- checking running R code from vignettes ... [24s/30s] ERROR
Errors in running code in vignettes:
when running code in ‘ctree.Rnw’
...
> options(width = 70, SweaveHooks = list(leftpar = function() par(mai = par("mai") *
+ c(1, 1.1, 1, 1))))
> require("partykit")
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: rpart
> require("coin")
Loading required package: coin
Loading required package: survival
Attaching package: ‘survival’
The following object is masked from ‘package:rpart’:
solder
> require("strucchange")
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
> require("coin")
> require("Formula")
Loading required package: Formula
> require("survival")
> require("sandwich")
> set.seed(290875)
> ctree_control(teststat = "max")
$criterion
[1] "p.value"
$logmincriterion
[1] -0.05129329
$minsplit
[1] 20
$minbucket
[1] 7
$minprob
[1] 0.01
$stump
[1] FALSE
$nmax
yx z
Inf Inf
$lookahead
[1] FALSE
$mtry
[1] Inf
$maxdepth
[1] Inf
$multiway
[1] FALSE
$splittry
[1] 2
$maxsurrogate
[1] 0
$numsurrogate
[1] FALSE
$majority
[1] FALSE
$caseweights
[1] TRUE
$applyfun
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
<bytecode: 0x246ab10>
<environment: namespace:base>
$saveinfo
[1] TRUE
$bonferroni
[1] TRUE
$update
NULL
$selectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe097230>
$splitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe09d8b8>
$svselectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe09d7d8>
$svsplitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe09d688>
$teststat
[1] "maximum"
$splitstat
[1] "quadratic"
$splittest
[1] FALSE
$pargs
$maxpts
[1] 25000
$abseps
[1] 0.001
$releps
[1] 0
attr(,"class")
[1] "GenzBretz"
$testtype
[1] "Bonferroni"
$nresample
[1] 9999
$tol
[1] 1.490116e-08
$intersplit
[1] FALSE
$MIA
[1] FALSE
> ctree_control(teststat = "quad")
$criterion
[1] "p.value"
$logmincriterion
[1] -0.05129329
$minsplit
[1] 20
$minbucket
[1] 7
$minprob
[1] 0.01
$stump
[1] FALSE
$nmax
yx z
Inf Inf
$lookahead
[1] FALSE
$mtry
[1] Inf
$maxdepth
[1] Inf
$multiway
[1] FALSE
$splittry
[1] 2
$maxsurrogate
[1] 0
$numsurrogate
[1] FALSE
$majority
[1] FALSE
$caseweights
[1] TRUE
$applyfun
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
<bytecode: 0x246ab10>
<environment: namespace:base>
$saveinfo
[1] TRUE
$bonferroni
[1] TRUE
$update
NULL
$selectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0c1ed0>
$splitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0c1df0>
$svselectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0c1d10>
$svsplitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0c1bc0>
$teststat
[1] "quadratic"
$splitstat
[1] "quadratic"
$splittest
[1] FALSE
$pargs
$maxpts
[1] 25000
$abseps
[1] 0.001
$releps
[1] 0
attr(,"class")
[1] "GenzBretz"
$testtype
[1] "Bonferroni"
$nresample
[1] 9999
$tol
[1] 1.490116e-08
$intersplit
[1] FALSE
$MIA
[1] FALSE
> ctree_control(testtype = "Bonferroni")
$criterion
[1] "p.value"
$logmincriterion
[1] -0.05129329
$minsplit
[1] 20
$minbucket
[1] 7
$minprob
[1] 0.01
$stump
[1] FALSE
$nmax
yx z
Inf Inf
$lookahead
[1] FALSE
$mtry
[1] Inf
$maxdepth
[1] Inf
$multiway
[1] FALSE
$splittry
[1] 2
$maxsurrogate
[1] 0
$numsurrogate
[1] FALSE
$majority
[1] FALSE
$caseweights
[1] TRUE
$applyfun
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
<bytecode: 0x246ab10>
<environment: namespace:base>
$saveinfo
[1] TRUE
$bonferroni
[1] TRUE
$update
NULL
$selectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0d6988>
$splitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0d68a8>
$svselectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0d67c8>
$svsplitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0d6678>
$teststat
[1] "quadratic"
$splitstat
[1] "quadratic"
$splittest
[1] FALSE
$pargs
$maxpts
[1] 25000
$abseps
[1] 0.001
$releps
[1] 0
attr(,"class")
[1] "GenzBretz"
$testtype
[1] "Bonferroni"
$nresample
[1] 9999
$tol
[1] 1.490116e-08
$intersplit
[1] FALSE
$MIA
[1] FALSE
> ctree_control(minsplit = 20)
$criterion
[1] "p.value"
$logmincriterion
[1] -0.05129329
$minsplit
[1] 20
$minbucket
[1] 7
$minprob
[1] 0.01
$stump
[1] FALSE
$nmax
yx z
Inf Inf
$lookahead
[1] FALSE
$mtry
[1] Inf
$maxdepth
[1] Inf
$multiway
[1] FALSE
$splittry
[1] 2
$maxsurrogate
[1] 0
$numsurrogate
[1] FALSE
$majority
[1] FALSE
$caseweights
[1] TRUE
$applyfun
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
<bytecode: 0x246ab10>
<environment: namespace:base>
$saveinfo
[1] TRUE
$bonferroni
[1] TRUE
$update
NULL
$selectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0e6a40>
$splitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0e6960>
$svselectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0e6880>
$svsplitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0e6730>
$teststat
[1] "quadratic"
$splitstat
[1] "quadratic"
$splittest
[1] FALSE
$pargs
$maxpts
[1] 25000
$abseps
[1] 0.001
$releps
[1] 0
attr(,"class")
[1] "GenzBretz"
$testtype
[1] "Bonferroni"
$nresample
[1] 9999
$tol
[1] 1.490116e-08
$intersplit
[1] FALSE
$MIA
[1] FALSE
> ctree_control(maxsurrogate = 3)
$criterion
[1] "p.value"
$logmincriterion
[1] -0.05129329
$minsplit
[1] 20
$minbucket
[1] 7
$minprob
[1] 0.01
$stump
[1] FALSE
$nmax
yx z
Inf Inf
$lookahead
[1] FALSE
$mtry
[1] Inf
$maxdepth
[1] Inf
$multiway
[1] FALSE
$splittry
[1] 2
$maxsurrogate
[1] 3
$numsurrogate
[1] FALSE
$majority
[1] FALSE
$caseweights
[1] TRUE
$applyfun
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
<bytecode: 0x246ab10>
<environment: namespace:base>
$saveinfo
[1] TRUE
$bonferroni
[1] TRUE
$update
NULL
$selectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0f7578>
$splitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0fb2c8>
$svselectfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.select(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe097e00>
<environment: 0xe0fb1e8>
$svsplitfun
function (model, trafo, data, subset, weights, whichvar, ctrl)
{
args <- list(...)
ctrl[names(args)] <- args
.split(model, trafo, data, subset, weights, whichvar, ctrl,
FUN = .ctree_test)
}
<bytecode: 0xe096318>
<environment: 0xe0fb098>
$teststat
[1] "quadratic"
$splitstat
[1] "quadratic"
$splittest
[1] FALSE
$pargs
$maxpts
[1] 25000
$abseps
[1] 0.001
$releps
[1] 0
attr(,"class")
[1] "GenzBretz"
$testtype
[1] "Bonferroni"
$nresample
[1] 9999
$tol
[1] 1.490116e-08
$intersplit
[1] FALSE
$MIA
[1] FALSE
> ls <- data.frame(y = gl(3, 50, labels = c("A", "B",
+ "C")), x1 = rnorm(150) + rep(c(1, 0, 0), c(50, 50, 50)),
+ x2 = runif(150))
> library("partykit")
> ctree(y ~ x1 + x2, data = ls)
Model formula:
y ~ x1 + x2
Fitted party:
[1] root
| [2] x1 <= 0.82552: C (n = 96, err = 57.3%)
| [3] x1 > 0.82552: A (n = 54, err = 42.6%)
Number of inner nodes: 1
Number of terminal nodes: 2
> ct <- ctree(y ~ x1 + x2, data = ls)
> ct
Model formula:
y ~ x1 + x2
Fitted party:
[1] root
| [2] x1 <= 0.82552: C (n = 96, err = 57.3%)
| [3] x1 > 0.82552: A (n = 54, err = 42.6%)
Number of inner nodes: 1
Number of terminal nodes: 2
> plot(ct)
> ct[1]
Model formula:
y ~ x1 + x2
Fitted party:
[1] root
| [2] x1 <= 0.82552: C (n = 96, err = 57.3%)
| [3] x1 > 0.82552: A (n = 54, err = 42.6%)
Number of inner nodes: 1
Number of terminal nodes: 2
> class(ct[1])
[1] "constparty" "party"
> predict(ct, newdata = ls)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
A A A A C A C A C C A A C A A A A
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
C A C A A A C A A A C C A A C A A
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
C A A C C C A A C C C C A A A A A
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
A C C C C A C C A C C C C C C A A
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
A A A C C A C A C C C C C C C C C
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
C C C A C A C A C C C C C C C C A
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
C C C A C C A C C C C C C C A C C
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
C C C C C C C C C C C C C C C C C
137 138 139 140 141 142 143 144 145 146 147 148 149 150
C A C C C C A C C A C A C A
Levels: A B C
> predict(ct, newdata = ls[c(1, 51, 101), ], type = "prob")
A B C
1 0.5740741 0.2592593 0.1666667
51 0.5740741 0.2592593 0.1666667
101 0.1979167 0.3750000 0.4270833
> predict(ct, newdata = ls[c(1, 51, 101), ], type = "node")
1 51 101
3 3 2
> library("strucchange")
> sctest(ct)
When sourcing ‘ctree.R’:
Error: no applicable method for ‘estfun’ applied to an object of class "c('constparty', 'party')"
Execution halted
when running code in ‘mob.Rnw’
...
> library("partykit")
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: rpart
> options(prompt = "R> ", continue = "+ ", digits = 4,
+ useFancyQuotes = FALSE)
> data("PimaIndiansDiabetes", package = "mlbench")
> pid_formula <- diabetes ~ glucose | pregnant + pressure +
+ triceps + insulin + mass + pedigree + age
> logit <- function(y, x, start = NULL, weights = NULL,
+ offset = NULL, ...) {
+ glm(y ~ 0 + x, family = binomial, start = start, ...)
+ }
> pid_tree <- mob(pid_formula, data = PimaIndiansDiabetes,
+ fit = logit)
> pid_tree
Model-based recursive partitioning (logit)
Model formula:
diabetes ~ glucose | pregnant + pressure + triceps + insulin +
mass + pedigree + age
Fitted party:
[1] root
| [2] mass <= 26.3: n = 167
| x(Intercept) xglucose
| -9.95151 0.05871
| [3] mass > 26.3
| | [4] age <= 30: n = 304
| | x(Intercept) xglucose
| | -6.70559 0.04684
| | [5] age > 30: n = 297
| | x(Intercept) xglucose
| | -2.77095 0.02354
Number of inner nodes: 2
Number of terminal nodes: 3
Number of parameters per node: 2
Objective function: 355.5
> pid_tree2 <- glmtree(diabetes ~ glucose | pregnant +
+ pressure + triceps + insulin + mass + pedigree + age, data = PimaIndiansDiabetes,
+ .... [TRUNCATED]
> plot(pid_tree)
> plot(pid_tree2, tp_args = list(ylines = 1, margins = c(1.5,
+ 1.5, 1.5, 2.5)))
Loading required namespace: vcd
> library("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
> sctest(pid_tree, node = 1)
When sourcing 'mob.R':
Error: no applicable method for ‘estfun’ applied to an object of class "c('modelparty', 'party')"
Execution halted
- checking re-building of vignette outputs ... [18s/29s] WARNING
Error in re-building vignettes:
...
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: rpart
Loading required package: RWeka
Loading required namespace: XML
Loading required package: XML
Attaching package: ‘XML’
The following object is masked from ‘package:tools’:
toHTML
Loading required package: coin
Loading required package: survival
Attaching package: ‘survival’
The following object is masked from ‘package:rpart’:
solder
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
Loading required package: Formula
Error: processing vignette ‘ctree.Rnw’ failed with diagnostics:
chunk 17 (label = party-sctest)
Error in UseMethod("estfun") :
no applicable method for ‘estfun’ applied to an object of class "c('constparty', 'party')"
Execution halted
- checking PDF version of manual ... OK
- DONE
Status: 2 ERRORs, 1 WARNING