[fbf06f]: / partyMod / tests / Predict-regtest.Rout.save

Download this file

93 lines (81 with data), 3.3 kB

R Under development (unstable) (2014-06-29 r66051) -- "Unsuffered Consequences"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 
> set.seed(290875)
> library("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
> if (!require("TH.data"))
+     stop("cannot load package TH.data")
Loading required package: TH.data
> if (!require("coin"))
+     stop("cannot load package coin")
Loading required package: coin
Loading required package: survival
Loading required package: splines
> 
> ### get rid of the NAMESPACE
> attach(asNamespace("party"))
The following objects are masked from package:party:

    cforest, cforest_classical, cforest_control, cforest_unbiased,
    conditionalTree, ctree, ctree_control, ctree_memory, edge_simple,
    mob, mob_control, node_barplot, node_bivplot, node_boxplot,
    node_density, node_hist, node_inner, node_scatterplot, node_surv,
    node_terminal, proximity, ptrafo, reweight, sctest.mob, varimp,
    varimpAUC

> 
> data(treepipit, package = "coin")
> ct <- ctree(counts ~ ., data = treepipit)
> stopifnot(isequal(predict(ct), predict(ct, newdata = treepipit)))
> 
> 
> data(GlaucomaM, package = "TH.data")
> ct <- ctree(Class ~ ., data = GlaucomaM)
> stopifnot(isequal(predict(ct), predict(ct, newdata = GlaucomaM)))
> stopifnot(isequal(predict(ct, type = "prob"), predict(ct, type = "prob", 
+                   newdata = GlaucomaM)))
> stopifnot(isequal(predict(ct, type = "node"), predict(ct, type = "node", 
+                   newdata = GlaucomaM)))
> stopifnot(isequal(predict(ct, type = "prob"), treeresponse(ct)))
> 
> data("GBSG2", package = "TH.data")  
> 
> GBSG2tree <- ctree(Surv(time, cens) ~ ., data = GBSG2)
> stopifnot(isequal(GBSG2tree@predict_response(), 
+           GBSG2tree@predict_response(newdata = GBSG2)))
> stopifnot(isequal(GBSG2tree@cond_distr_response(), 
+           GBSG2tree@cond_distr_response(newdata = GBSG2)))
> 
> data("mammoexp", package = "TH.data")
> attr(mammoexp$ME, "scores") <- 1:3   
> attr(mammoexp$SYMPT, "scores") <- 1:4
> attr(mammoexp$DECT, "scores") <- 1:3 
> names(mammoexp)[names(mammoexp) == "SYMPT"] <- "symptoms"
> names(mammoexp)[names(mammoexp) == "PB"] <- "benefit"
> 
> names(mammoexp)
[1] "ME"       "symptoms" "benefit"  "HIST"     "BSE"      "DECT"    
> mtree <- ctree(ME ~ ., data = mammoexp)
> stopifnot(isequal(predict(mtree), predict(mtree, newdata = mammoexp)))
> stopifnot(isequal(predict(mtree), predict(mtree, newdata = mammoexp)))
> 
> proc.time()
   user  system elapsed 
   1.60    0.06    1.66