a b/partyMod/tests/Predict-regtest.Rout.save
1
2
R Under development (unstable) (2014-06-29 r66051) -- "Unsuffered Consequences"
3
Copyright (C) 2014 The R Foundation for Statistical Computing
4
Platform: x86_64-unknown-linux-gnu (64-bit)
5
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
8
Type 'license()' or 'licence()' for distribution details.
9
10
R is a collaborative project with many contributors.
11
Type 'contributors()' for more information and
12
'citation()' on how to cite R or R packages in publications.
13
14
Type 'demo()' for some demos, 'help()' for on-line help, or
15
'help.start()' for an HTML browser interface to help.
16
Type 'q()' to quit R.
17
18
> 
19
> set.seed(290875)
20
> library("party")
21
Loading required package: grid
22
Loading required package: zoo
23
24
Attaching package: 'zoo'
25
26
The following objects are masked from 'package:base':
27
28
    as.Date, as.Date.numeric
29
30
Loading required package: sandwich
31
Loading required package: strucchange
32
Loading required package: modeltools
33
Loading required package: stats4
34
> if (!require("TH.data"))
35
+     stop("cannot load package TH.data")
36
Loading required package: TH.data
37
> if (!require("coin"))
38
+     stop("cannot load package coin")
39
Loading required package: coin
40
Loading required package: survival
41
Loading required package: splines
42
> 
43
> ### get rid of the NAMESPACE
44
> attach(asNamespace("party"))
45
The following objects are masked from package:party:
46
47
    cforest, cforest_classical, cforest_control, cforest_unbiased,
48
    conditionalTree, ctree, ctree_control, ctree_memory, edge_simple,
49
    mob, mob_control, node_barplot, node_bivplot, node_boxplot,
50
    node_density, node_hist, node_inner, node_scatterplot, node_surv,
51
    node_terminal, proximity, ptrafo, reweight, sctest.mob, varimp,
52
    varimpAUC
53
54
> 
55
> data(treepipit, package = "coin")
56
> ct <- ctree(counts ~ ., data = treepipit)
57
> stopifnot(isequal(predict(ct), predict(ct, newdata = treepipit)))
58
> 
59
> 
60
> data(GlaucomaM, package = "TH.data")
61
> ct <- ctree(Class ~ ., data = GlaucomaM)
62
> stopifnot(isequal(predict(ct), predict(ct, newdata = GlaucomaM)))
63
> stopifnot(isequal(predict(ct, type = "prob"), predict(ct, type = "prob", 
64
+                   newdata = GlaucomaM)))
65
> stopifnot(isequal(predict(ct, type = "node"), predict(ct, type = "node", 
66
+                   newdata = GlaucomaM)))
67
> stopifnot(isequal(predict(ct, type = "prob"), treeresponse(ct)))
68
> 
69
> data("GBSG2", package = "TH.data")  
70
> 
71
> GBSG2tree <- ctree(Surv(time, cens) ~ ., data = GBSG2)
72
> stopifnot(isequal(GBSG2tree@predict_response(), 
73
+           GBSG2tree@predict_response(newdata = GBSG2)))
74
> stopifnot(isequal(GBSG2tree@cond_distr_response(), 
75
+           GBSG2tree@cond_distr_response(newdata = GBSG2)))
76
> 
77
> data("mammoexp", package = "TH.data")
78
> attr(mammoexp$ME, "scores") <- 1:3   
79
> attr(mammoexp$SYMPT, "scores") <- 1:4
80
> attr(mammoexp$DECT, "scores") <- 1:3 
81
> names(mammoexp)[names(mammoexp) == "SYMPT"] <- "symptoms"
82
> names(mammoexp)[names(mammoexp) == "PB"] <- "benefit"
83
> 
84
> names(mammoexp)
85
[1] "ME"       "symptoms" "benefit"  "HIST"     "BSE"      "DECT"    
86
> mtree <- ctree(ME ~ ., data = mammoexp)
87
> stopifnot(isequal(predict(mtree), predict(mtree, newdata = mammoexp)))
88
> stopifnot(isequal(predict(mtree), predict(mtree, newdata = mammoexp)))
89
> 
90
> proc.time()
91
   user  system elapsed 
92
   1.60    0.06    1.66