R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-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. > x <- array(list(176508 + ,54 + ,559 + ,50 + ,179321 + ,89 + ,967 + ,125 + ,123185 + ,40 + ,270 + ,40 + ,52746 + ,25 + ,143 + ,37 + ,385534 + ,92 + ,1562 + ,63 + ,33170 + ,18 + ,109 + ,44 + ,101645 + ,63 + ,371 + ,88 + ,149061 + ,44 + ,656 + ,66 + ,165446 + ,33 + ,511 + ,57 + ,237213 + ,84 + ,655 + ,74 + ,173326 + ,88 + ,465 + ,49 + ,133131 + ,55 + ,525 + ,52 + ,258873 + ,60 + ,885 + ,88 + ,180083 + ,66 + ,497 + ,36 + ,324799 + ,154 + ,1436 + ,108 + ,230964 + ,53 + ,612 + ,43 + ,236785 + ,119 + ,865 + ,75 + ,135473 + ,41 + ,385 + ,32 + ,202925 + ,61 + ,567 + ,44 + ,215147 + ,58 + ,639 + ,85 + ,344297 + ,75 + ,963 + ,86 + ,153935 + ,33 + ,398 + ,56 + ,132943 + ,40 + ,410 + ,50 + ,174724 + ,92 + ,966 + ,135 + ,174415 + ,100 + ,801 + ,63 + ,225548 + ,112 + ,892 + ,81 + ,223632 + ,73 + ,513 + ,52 + ,124817 + ,40 + ,469 + ,44 + ,221698 + ,45 + ,683 + ,113 + ,210767 + ,60 + ,643 + ,39 + ,170266 + ,62 + ,535 + ,73 + ,260561 + ,75 + ,625 + ,48 + ,84853 + ,31 + ,264 + ,33 + ,294424 + ,77 + ,992 + ,59 + ,101011 + ,34 + ,238 + ,41 + ,215641 + ,46 + ,818 + ,69 + ,325107 + ,99 + ,937 + ,64 + ,7176 + ,17 + ,70 + ,1 + ,167542 + ,66 + ,507 + ,59 + ,106408 + ,30 + ,260 + ,32 + ,96560 + ,76 + ,503 + ,129 + ,265769 + ,146 + ,927 + ,37 + ,269651 + ,67 + ,1269 + ,31 + ,149112 + ,56 + ,537 + ,65 + ,175824 + ,107 + ,910 + ,107 + ,152871 + ,58 + ,532 + ,74 + ,111665 + ,34 + ,345 + ,54 + ,116408 + ,61 + ,918 + ,76 + ,362301 + ,119 + ,1635 + ,715 + ,78800 + ,42 + ,330 + ,57 + ,183167 + ,66 + ,557 + ,66 + ,277965 + ,89 + ,1178 + ,106 + ,150629 + ,44 + ,740 + ,54 + ,168809 + ,66 + ,452 + ,32 + ,24188 + ,24 + ,218 + ,20 + ,329267 + ,259 + ,764 + ,71 + ,65029 + ,17 + ,255 + ,21 + ,101097 + ,64 + ,454 + ,70 + ,218946 + ,41 + ,866 + ,112 + ,244052 + ,68 + ,574 + ,66 + ,341570 + ,168 + ,1276 + ,190 + ,103597 + ,43 + ,379 + ,66 + ,233328 + ,132 + ,825 + ,165 + ,256462 + ,105 + ,798 + ,56 + ,206161 + ,71 + ,663 + ,61 + ,311473 + ,112 + ,1069 + ,53 + ,235800 + ,94 + ,921 + ,127 + ,177939 + ,82 + ,858 + ,63 + ,207176 + ,70 + ,711 + ,38 + ,196553 + ,57 + ,503 + ,50 + ,174184 + ,53 + ,382 + ,52 + ,143246 + ,103 + ,464 + ,42 + ,187559 + ,121 + ,717 + ,76 + ,187681 + ,62 + ,690 + ,67 + ,119016 + ,52 + ,462 + ,50 + ,182192 + ,52 + ,657 + ,53 + ,73566 + ,32 + ,385 + ,39 + ,194979 + ,62 + ,577 + ,50 + ,167488 + ,45 + ,619 + ,77 + ,143756 + ,46 + ,479 + ,57 + ,275541 + ,63 + ,817 + ,73 + ,243199 + ,75 + ,752 + ,34 + ,182999 + ,88 + ,430 + ,39 + ,135649 + ,46 + ,451 + ,46 + ,152299 + ,53 + ,537 + ,63 + ,120221 + ,37 + ,519 + ,35 + ,346485 + ,90 + ,1000 + ,106 + ,145790 + ,63 + ,637 + ,43 + ,193339 + ,78 + ,465 + ,47 + ,80953 + ,25 + ,437 + ,31 + ,122774 + ,45 + ,711 + ,162 + ,130585 + ,46 + ,299 + ,57 + ,112611 + ,41 + ,248 + ,36 + ,286468 + ,144 + ,1162 + ,263 + ,241066 + ,82 + ,714 + ,78 + ,148446 + ,91 + ,905 + ,63 + ,204713 + ,71 + ,649 + ,54 + ,182079 + ,63 + ,512 + ,63 + ,140344 + ,53 + ,472 + ,77 + ,220516 + ,62 + ,905 + ,79 + ,243060 + ,63 + ,786 + ,110 + ,162765 + ,32 + ,489 + ,56 + ,182613 + ,39 + ,479 + ,56 + ,232138 + ,62 + ,617 + ,43 + ,265318 + ,117 + ,925 + ,111 + ,85574 + ,34 + ,351 + ,71 + ,310839 + ,92 + ,1144 + ,62 + ,225060 + ,93 + ,669 + ,56 + ,232317 + ,54 + ,707 + ,74 + ,144966 + ,144 + ,458 + ,60 + ,43287 + ,14 + ,214 + ,43 + ,155754 + ,61 + ,599 + ,68 + ,164709 + ,109 + ,572 + ,53 + ,201940 + ,38 + ,897 + ,87 + ,235454 + ,73 + ,819 + ,46 + ,220801 + ,75 + ,720 + ,105 + ,99466 + ,50 + ,273 + ,32 + ,92661 + ,61 + ,508 + ,133 + ,133328 + ,55 + ,506 + ,79 + ,61361 + ,77 + ,451 + ,51 + ,125930 + ,75 + ,699 + ,207 + ,100750 + ,72 + ,407 + ,67 + ,224549 + ,50 + ,465 + ,47 + ,82316 + ,32 + ,245 + ,34 + ,102010 + ,53 + ,370 + ,66 + ,101523 + ,42 + ,316 + ,76 + ,243511 + ,71 + ,603 + ,65 + ,22938 + ,10 + ,154 + ,9 + ,41566 + ,35 + ,229 + ,42 + ,152474 + ,65 + ,577 + ,45 + ,61857 + ,25 + ,192 + ,25 + ,99923 + ,66 + ,617 + ,115 + ,132487 + ,41 + ,411 + ,97 + ,317394 + ,86 + ,975 + ,53 + ,21054 + ,16 + ,146 + ,2 + ,209641 + ,42 + ,705 + ,52 + ,22648 + ,19 + ,184 + ,44 + ,31414 + ,19 + ,200 + ,22 + ,46698 + ,45 + ,274 + ,35 + ,131698 + ,65 + ,502 + ,74 + ,91735 + ,35 + ,382 + ,103 + ,244749 + ,95 + ,964 + ,144 + ,184510 + ,49 + ,537 + ,60 + ,79863 + ,37 + ,438 + ,134 + ,128423 + ,64 + ,369 + ,89 + ,97839 + ,38 + ,417 + ,42 + ,38214 + ,34 + ,276 + ,52 + ,151101 + ,32 + ,514 + ,98 + ,272458 + ,65 + ,822 + ,99 + ,172494 + ,52 + ,389 + ,52 + ,108043 + ,62 + ,466 + ,29 + ,328107 + ,65 + ,1255 + ,125 + ,250579 + ,83 + ,694 + ,106 + ,351067 + ,95 + ,1024 + ,95 + ,158015 + ,29 + ,400 + ,40 + ,98866 + ,18 + ,397 + ,140 + ,85439 + ,33 + ,350 + ,43 + ,229242 + ,247 + ,719 + ,128 + ,351619 + ,139 + ,1277 + ,142 + ,84207 + ,29 + ,356 + ,73 + ,120445 + ,118 + ,457 + ,72 + ,324598 + ,110 + ,1402 + ,128 + ,131069 + ,67 + ,600 + ,61 + ,204271 + ,42 + ,480 + ,73 + ,165543 + ,65 + ,595 + ,148 + ,141722 + ,94 + ,436 + ,64 + ,116048 + ,64 + ,230 + ,45 + ,250047 + ,81 + ,651 + ,58 + ,299775 + ,95 + ,1367 + ,97 + ,195838 + ,67 + ,564 + ,50 + ,173260 + ,63 + ,716 + ,37 + ,254488 + ,83 + ,747 + ,50 + ,104389 + ,45 + ,467 + ,105 + ,136084 + ,30 + ,671 + ,69 + ,199476 + ,70 + ,861 + ,46 + ,92499 + ,32 + ,319 + ,57 + ,224330 + ,83 + ,612 + ,52 + ,135781 + ,31 + ,433 + ,98 + ,74408 + ,67 + ,434 + ,61 + ,81240 + ,66 + ,503 + ,89 + ,14688 + ,10 + ,85 + ,0 + ,181633 + ,70 + ,564 + ,48 + ,271856 + ,103 + ,824 + ,91 + ,7199 + ,5 + ,74 + ,0 + ,46660 + ,20 + ,259 + ,7 + ,17547 + ,5 + ,69 + ,3 + ,133368 + ,36 + ,535 + ,54 + ,95227 + ,34 + ,239 + ,70 + ,152601 + ,48 + ,438 + ,36 + ,98146 + ,40 + ,459 + ,37 + ,79619 + ,43 + ,426 + ,123 + ,59194 + ,31 + ,288 + ,247 + ,139942 + ,42 + ,498 + ,46 + ,118612 + ,46 + ,454 + ,72 + ,72880 + ,33 + ,376 + ,41 + ,65475 + ,18 + ,225 + ,24 + ,99643 + ,55 + ,555 + ,45 + ,71965 + ,35 + ,252 + ,33 + ,77272 + ,59 + ,208 + ,27 + ,49289 + ,19 + ,130 + ,36 + ,135131 + ,66 + ,481 + ,87 + ,108446 + ,60 + ,389 + ,90 + ,89746 + ,36 + ,565 + ,114 + ,44296 + ,25 + ,173 + ,31 + ,77648 + ,47 + ,278 + ,45 + ,181528 + ,54 + ,609 + ,69 + ,134019 + ,53 + ,422 + ,51 + ,124064 + ,40 + ,445 + ,34 + ,92630 + ,40 + ,387 + ,60 + ,121848 + ,39 + ,339 + ,45 + ,52915 + ,14 + ,181 + ,54 + ,81872 + ,45 + ,245 + ,25 + ,58981 + ,36 + ,384 + ,38 + ,53515 + ,28 + ,212 + ,52 + ,60812 + ,44 + ,399 + ,67 + ,56375 + ,30 + ,229 + ,74 + ,65490 + ,22 + ,224 + ,38 + ,80949 + ,17 + ,203 + ,30 + ,76302 + ,31 + ,333 + ,26 + ,104011 + ,55 + ,384 + ,67 + ,98104 + ,54 + ,636 + ,132 + ,67989 + ,21 + ,185 + ,42 + ,30989 + ,14 + ,93 + ,35 + ,135458 + ,81 + ,581 + ,118 + ,73504 + ,35 + ,248 + ,68 + ,63123 + ,43 + ,304 + ,43 + ,61254 + ,46 + ,344 + ,76 + ,74914 + ,30 + ,407 + ,64 + ,31774 + ,23 + ,170 + ,48 + ,81437 + ,38 + ,312 + ,64 + ,87186 + ,54 + ,507 + ,56 + ,50090 + ,20 + ,224 + ,71 + ,65745 + ,53 + ,340 + ,75 + ,56653 + ,45 + ,168 + ,39 + ,158399 + ,39 + ,443 + ,42 + ,46455 + ,20 + ,204 + ,39 + ,73624 + ,24 + ,367 + ,93 + ,38395 + ,31 + ,210 + ,38 + ,91899 + ,35 + ,335 + ,60 + ,139526 + ,151 + ,364 + ,71 + ,52164 + ,52 + ,178 + ,52 + ,51567 + ,30 + ,206 + ,27 + ,70551 + ,31 + ,279 + ,59 + ,84856 + ,29 + ,387 + ,40 + ,102538 + ,57 + ,490 + ,79 + ,86678 + ,40 + ,238 + ,44 + ,85709 + ,44 + ,343 + ,65 + ,34662 + ,25 + ,232 + ,10 + ,150580 + ,77 + ,530 + ,124 + ,99611 + ,35 + ,291 + ,81 + ,19349 + ,11 + ,67 + ,15 + ,99373 + ,63 + ,397 + ,92 + ,86230 + ,44 + ,467 + ,42 + ,30837 + ,19 + ,178 + ,10 + ,31706 + ,13 + ,175 + ,24 + ,89806 + ,42 + ,299 + ,64 + ,62088 + ,38 + ,154 + ,45 + ,40151 + ,29 + ,106 + ,22 + ,27634 + ,20 + ,189 + ,56 + ,76990 + ,27 + ,194 + ,94 + ,37460 + ,20 + ,135 + ,19 + ,54157 + ,19 + ,201 + ,35 + ,49862 + ,37 + ,207 + ,32 + ,84337 + ,26 + ,280 + ,35 + ,64175 + ,42 + ,260 + ,48 + ,59382 + ,49 + ,227 + ,49 + ,119308 + ,30 + ,239 + ,48 + ,76702 + ,49 + ,333 + ,62 + ,103425 + ,67 + ,428 + ,96 + ,70344 + ,28 + ,230 + ,45 + ,43410 + ,19 + ,292 + ,63 + ,104838 + ,49 + ,350 + ,71 + ,62215 + ,27 + ,186 + ,26 + ,69304 + ,30 + ,326 + ,48 + ,53117 + ,22 + ,155 + ,29 + ,19764 + ,12 + ,75 + ,19 + ,86680 + ,31 + ,361 + ,45 + ,84105 + ,20 + ,261 + ,45 + ,77945 + ,20 + ,299 + ,67 + ,89113 + ,39 + ,300 + ,30 + ,91005 + ,29 + ,450 + ,36 + ,40248 + ,16 + ,183 + ,34 + ,64187 + ,27 + ,238 + ,36 + ,50857 + ,21 + ,165 + ,34 + ,56613 + ,19 + ,234 + ,37 + ,62792 + ,35 + ,176 + ,46 + ,72535 + ,14 + ,329 + ,44) + ,dim=c(4 + ,287) + ,dimnames=list(c('time_in_rfc' + ,'logins' + ,'compendium_views_info' + ,'compendium_views_pr') + ,1:287)) > y <- array(NA,dim=c(4,287),dimnames=list(c('time_in_rfc','logins','compendium_views_info','compendium_views_pr'),1:287)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '1' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '1' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., 2012, Recursive Partitioning (Regression Trees) (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_regression_trees.wasp/ > #Source of accompanying publication: > # > library(party) Loading required package: survival Loading required package: splines Loading required package: grid Loading required package: modeltools Loading required package: stats4 Loading required package: coin Loading required package: mvtnorm Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, as.Date.numeric Loading required package: sandwich Loading required package: strucchange Loading required package: vcd Loading required package: MASS Loading required package: colorspace > library(Hmisc) Hmisc library by Frank E Harrell Jr Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview') to see overall documentation. NOTE:Hmisc no longer redefines [.factor to drop unused levels when subsetting. To get the old behavior of Hmisc type dropUnusedLevels(). Attaching package: 'Hmisc' The following object(s) are masked from 'package:survival': untangle.specials The following object(s) are masked from 'package:base': format.pval, round.POSIXt, trunc.POSIXt, units > par1 <- as.numeric(par1) > par3 <- as.numeric(par3) > x <- data.frame(t(y)) > is.data.frame(x) [1] TRUE > x <- x[!is.na(x[,par1]),] > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "time_in_rfc" > x[,par1] [1] 176508 179321 123185 52746 385534 33170 101645 149061 165446 237213 [11] 173326 133131 258873 180083 324799 230964 236785 135473 202925 215147 [21] 344297 153935 132943 174724 174415 225548 223632 124817 221698 210767 [31] 170266 260561 84853 294424 101011 215641 325107 7176 167542 106408 [41] 96560 265769 269651 149112 175824 152871 111665 116408 362301 78800 [51] 183167 277965 150629 168809 24188 329267 65029 101097 218946 244052 [61] 341570 103597 233328 256462 206161 311473 235800 177939 207176 196553 [71] 174184 143246 187559 187681 119016 182192 73566 194979 167488 143756 [81] 275541 243199 182999 135649 152299 120221 346485 145790 193339 80953 [91] 122774 130585 112611 286468 241066 148446 204713 182079 140344 220516 [101] 243060 162765 182613 232138 265318 85574 310839 225060 232317 144966 [111] 43287 155754 164709 201940 235454 220801 99466 92661 133328 61361 [121] 125930 100750 224549 82316 102010 101523 243511 22938 41566 152474 [131] 61857 99923 132487 317394 21054 209641 22648 31414 46698 131698 [141] 91735 244749 184510 79863 128423 97839 38214 151101 272458 172494 [151] 108043 328107 250579 351067 158015 98866 85439 229242 351619 84207 [161] 120445 324598 131069 204271 165543 141722 116048 250047 299775 195838 [171] 173260 254488 104389 136084 199476 92499 224330 135781 74408 81240 [181] 14688 181633 271856 7199 46660 17547 133368 95227 152601 98146 [191] 79619 59194 139942 118612 72880 65475 99643 71965 77272 49289 [201] 135131 108446 89746 44296 77648 181528 134019 124064 92630 121848 [211] 52915 81872 58981 53515 60812 56375 65490 80949 76302 104011 [221] 98104 67989 30989 135458 73504 63123 61254 74914 31774 81437 [231] 87186 50090 65745 56653 158399 46455 73624 38395 91899 139526 [241] 52164 51567 70551 84856 102538 86678 85709 34662 150580 99611 [251] 19349 99373 86230 30837 31706 89806 62088 40151 27634 76990 [261] 37460 54157 49862 84337 64175 59382 119308 76702 103425 70344 [271] 43410 104838 62215 69304 53117 19764 86680 84105 77945 89113 [281] 91005 40248 64187 50857 56613 62792 72535 > if (par2 == 'kmeans') { + cl <- kmeans(x[,par1], par3) + print(cl) + clm <- matrix(cbind(cl$centers,1:par3),ncol=2) + clm <- clm[sort.list(clm[,1]),] + for (i in 1:par3) { + cl$cluster[cl$cluster==clm[i,2]] <- paste('C',i,sep='') + } + cl$cluster <- as.factor(cl$cluster) + print(cl$cluster) + x[,par1] <- cl$cluster + } > if (par2 == 'quantiles') { + x[,par1] <- cut2(x[,par1],g=par3) + } > if (par2 == 'hclust') { + hc <- hclust(dist(x[,par1])^2, 'cen') + print(hc) + memb <- cutree(hc, k = par3) + dum <- c(mean(x[memb==1,par1])) + for (i in 2:par3) { + dum <- c(dum, mean(x[memb==i,par1])) + } + hcm <- matrix(cbind(dum,1:par3),ncol=2) + hcm <- hcm[sort.list(hcm[,1]),] + for (i in 1:par3) { + memb[memb==hcm[i,2]] <- paste('C',i,sep='') + } + memb <- as.factor(memb) + print(memb) + x[,par1] <- memb + } > if (par2=='equal') { + ed <- cut(as.numeric(x[,par1]),par3,labels=paste('C',1:par3,sep='')) + x[,par1] <- as.factor(ed) + } > table(x[,par1]) 7176 7199 14688 17547 19349 19764 21054 22648 22938 24188 27634 1 1 1 1 1 1 1 1 1 1 1 30837 30989 31414 31706 31774 33170 34662 37460 38214 38395 40151 1 1 1 1 1 1 1 1 1 1 1 40248 41566 43287 43410 44296 46455 46660 46698 49289 49862 50090 1 1 1 1 1 1 1 1 1 1 1 50857 51567 52164 52746 52915 53117 53515 54157 56375 56613 56653 1 1 1 1 1 1 1 1 1 1 1 58981 59194 59382 60812 61254 61361 61857 62088 62215 62792 63123 1 1 1 1 1 1 1 1 1 1 1 64175 64187 65029 65475 65490 65745 67989 69304 70344 70551 71965 1 1 1 1 1 1 1 1 1 1 1 72535 72880 73504 73566 73624 74408 74914 76302 76702 76990 77272 1 1 1 1 1 1 1 1 1 1 1 77648 77945 78800 79619 79863 80949 80953 81240 81437 81872 82316 1 1 1 1 1 1 1 1 1 1 1 84105 84207 84337 84853 84856 85439 85574 85709 86230 86678 86680 1 1 1 1 1 1 1 1 1 1 1 87186 89113 89746 89806 91005 91735 91899 92499 92630 92661 95227 1 1 1 1 1 1 1 1 1 1 1 96560 97839 98104 98146 98866 99373 99466 99611 99643 99923 100750 1 1 1 1 1 1 1 1 1 1 1 101011 101097 101523 101645 102010 102538 103425 103597 104011 104389 104838 1 1 1 1 1 1 1 1 1 1 1 106408 108043 108446 111665 112611 116048 116408 118612 119016 119308 120221 1 1 1 1 1 1 1 1 1 1 1 120445 121848 122774 123185 124064 124817 125930 128423 130585 131069 131698 1 1 1 1 1 1 1 1 1 1 1 132487 132943 133131 133328 133368 134019 135131 135458 135473 135649 135781 1 1 1 1 1 1 1 1 1 1 1 136084 139526 139942 140344 141722 143246 143756 144966 145790 148446 149061 1 1 1 1 1 1 1 1 1 1 1 149112 150580 150629 151101 152299 152474 152601 152871 153935 155754 158015 1 1 1 1 1 1 1 1 1 1 1 158399 162765 164709 165446 165543 167488 167542 168809 170266 172494 173260 1 1 1 1 1 1 1 1 1 1 1 173326 174184 174415 174724 175824 176508 177939 179321 180083 181528 181633 1 1 1 1 1 1 1 1 1 1 1 182079 182192 182613 182999 183167 184510 187559 187681 193339 194979 195838 1 1 1 1 1 1 1 1 1 1 1 196553 199476 201940 202925 204271 204713 206161 207176 209641 210767 215147 1 1 1 1 1 1 1 1 1 1 1 215641 218946 220516 220801 221698 223632 224330 224549 225060 225548 229242 1 1 1 1 1 1 1 1 1 1 1 230964 232138 232317 233328 235454 235800 236785 237213 241066 243060 243199 1 1 1 1 1 1 1 1 1 1 1 243511 244052 244749 250047 250579 254488 256462 258873 260561 265318 265769 1 1 1 1 1 1 1 1 1 1 1 269651 271856 272458 275541 277965 286468 294424 299775 310839 311473 317394 1 1 1 1 1 1 1 1 1 1 1 324598 324799 325107 328107 329267 341570 344297 346485 351067 351619 362301 1 1 1 1 1 1 1 1 1 1 1 385534 1 > colnames(x) [1] "time_in_rfc" "logins" "compendium_views_info" [4] "compendium_views_pr" > colnames(x)[par1] [1] "time_in_rfc" > x[,par1] [1] 176508 179321 123185 52746 385534 33170 101645 149061 165446 237213 [11] 173326 133131 258873 180083 324799 230964 236785 135473 202925 215147 [21] 344297 153935 132943 174724 174415 225548 223632 124817 221698 210767 [31] 170266 260561 84853 294424 101011 215641 325107 7176 167542 106408 [41] 96560 265769 269651 149112 175824 152871 111665 116408 362301 78800 [51] 183167 277965 150629 168809 24188 329267 65029 101097 218946 244052 [61] 341570 103597 233328 256462 206161 311473 235800 177939 207176 196553 [71] 174184 143246 187559 187681 119016 182192 73566 194979 167488 143756 [81] 275541 243199 182999 135649 152299 120221 346485 145790 193339 80953 [91] 122774 130585 112611 286468 241066 148446 204713 182079 140344 220516 [101] 243060 162765 182613 232138 265318 85574 310839 225060 232317 144966 [111] 43287 155754 164709 201940 235454 220801 99466 92661 133328 61361 [121] 125930 100750 224549 82316 102010 101523 243511 22938 41566 152474 [131] 61857 99923 132487 317394 21054 209641 22648 31414 46698 131698 [141] 91735 244749 184510 79863 128423 97839 38214 151101 272458 172494 [151] 108043 328107 250579 351067 158015 98866 85439 229242 351619 84207 [161] 120445 324598 131069 204271 165543 141722 116048 250047 299775 195838 [171] 173260 254488 104389 136084 199476 92499 224330 135781 74408 81240 [181] 14688 181633 271856 7199 46660 17547 133368 95227 152601 98146 [191] 79619 59194 139942 118612 72880 65475 99643 71965 77272 49289 [201] 135131 108446 89746 44296 77648 181528 134019 124064 92630 121848 [211] 52915 81872 58981 53515 60812 56375 65490 80949 76302 104011 [221] 98104 67989 30989 135458 73504 63123 61254 74914 31774 81437 [231] 87186 50090 65745 56653 158399 46455 73624 38395 91899 139526 [241] 52164 51567 70551 84856 102538 86678 85709 34662 150580 99611 [251] 19349 99373 86230 30837 31706 89806 62088 40151 27634 76990 [261] 37460 54157 49862 84337 64175 59382 119308 76702 103425 70344 [271] 43410 104838 62215 69304 53117 19764 86680 84105 77945 89113 [281] 91005 40248 64187 50857 56613 62792 72535 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/rcomp/createtable") > > if (par2 != 'none') { + m <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data = x) + if (par4=='yes') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'10-Fold Cross Validation',3+2*par3,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'',1,TRUE) + a<-table.element(a,'Prediction (training)',par3+1,TRUE) + a<-table.element(a,'Prediction (testing)',par3+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Actual',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) + a<-table.element(a,'CV',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) + a<-table.element(a,'CV',1,TRUE) + a<-table.row.end(a) + for (i in 1:10) { + ind <- sample(2, nrow(x), replace=T, prob=c(0.9,0.1)) + m.ct <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data =x[ind==1,]) + if (i==1) { + m.ct.i.pred <- predict(m.ct, newdata=x[ind==1,]) + m.ct.i.actu <- x[ind==1,par1] + m.ct.x.pred <- predict(m.ct, newdata=x[ind==2,]) + m.ct.x.actu <- x[ind==2,par1] + } else { + m.ct.i.pred <- c(m.ct.i.pred,predict(m.ct, newdata=x[ind==1,])) + m.ct.i.actu <- c(m.ct.i.actu,x[ind==1,par1]) + m.ct.x.pred <- c(m.ct.x.pred,predict(m.ct, newdata=x[ind==2,])) + m.ct.x.actu <- c(m.ct.x.actu,x[ind==2,par1]) + } + } + print(m.ct.i.tab <- table(m.ct.i.actu,m.ct.i.pred)) + numer <- 0 + for (i in 1:par3) { + print(m.ct.i.tab[i,i] / sum(m.ct.i.tab[i,])) + numer <- numer + m.ct.i.tab[i,i] + } + print(m.ct.i.cp <- numer / sum(m.ct.i.tab)) + print(m.ct.x.tab <- table(m.ct.x.actu,m.ct.x.pred)) + numer <- 0 + for (i in 1:par3) { + print(m.ct.x.tab[i,i] / sum(m.ct.x.tab[i,])) + numer <- numer + m.ct.x.tab[i,i] + } + print(m.ct.x.cp <- numer / sum(m.ct.x.tab)) + for (i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + for (jjj in 1:par3) a<-table.element(a,m.ct.i.tab[i,jjj]) + a<-table.element(a,round(m.ct.i.tab[i,i]/sum(m.ct.i.tab[i,]),4)) + for (jjj in 1:par3) a<-table.element(a,m.ct.x.tab[i,jjj]) + a<-table.element(a,round(m.ct.x.tab[i,i]/sum(m.ct.x.tab[i,]),4)) + a<-table.row.end(a) + } + a<-table.row.start(a) + a<-table.element(a,'Overall',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,'-') + a<-table.element(a,round(m.ct.i.cp,4)) + for (jjj in 1:par3) a<-table.element(a,'-') + a<-table.element(a,round(m.ct.x.cp,4)) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/fisher/rcomp/tmp/10w0v1354811087.tab") + } + } > m Conditional inference tree with 10 terminal nodes Response: time_in_rfc Inputs: logins, compendium_views_info, compendium_views_pr Number of observations: 287 1) compendium_views_info <= 555; criterion = 1, statistic = 229.255 2) compendium_views_info <= 361; criterion = 1, statistic = 119.295 3) compendium_views_info <= 229; criterion = 1, statistic = 50.967 4) compendium_views_info <= 93; criterion = 1, statistic = 19.074 5)* weights = 7 4) compendium_views_info > 93 6) logins <= 20; criterion = 0.979, statistic = 7.256 7)* weights = 18 6) logins > 20 8)* weights = 24 3) compendium_views_info > 229 9) logins <= 28; criterion = 0.976, statistic = 7.008 10)* weights = 11 9) logins > 28 11)* weights = 43 2) compendium_views_info > 361 12) compendium_views_info <= 462; criterion = 0.999, statistic = 13.583 13)* weights = 49 12) compendium_views_info > 462 14)* weights = 39 1) compendium_views_info > 555 15) compendium_views_info <= 967; criterion = 1, statistic = 47.205 16) logins <= 67; criterion = 0.999, statistic = 12.603 17)* weights = 38 16) logins > 67 18)* weights = 41 15) compendium_views_info > 967 19)* weights = 17 > postscript(file="/var/fisher/rcomp/tmp/2e5re1354811087.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(m) > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/3zcls1354811087.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,par1] ~ as.factor(where(m)),main='Response by Terminal Node',xlab='Terminal Node',ylab='Response') > dev.off() null device 1 > if (par2 == 'none') { + forec <- predict(m) + result <- as.data.frame(cbind(x[,par1],forec,x[,par1]-forec)) + colnames(result) <- c('Actuals','Forecasts','Residuals') + print(result) + } Actuals Forecasts Residuals 1 176508 184699.26 -8191.2632 2 179321 225301.78 -45980.7805 3 123185 87083.60 36101.3953 4 52746 53887.54 -1141.5417 5 385534 322592.29 62941.7059 6 33170 41207.00 -8037.0000 7 101645 112958.65 -11313.6531 8 149061 184699.26 -35638.2632 9 165446 146266.90 19179.1026 10 237213 225301.78 11911.2195 11 173326 146266.90 27059.1026 12 133131 146266.90 -13135.8974 13 258873 184699.26 74173.7368 14 180083 146266.90 33816.1026 15 324799 322592.29 2206.7059 16 230964 184699.26 46264.7368 17 236785 225301.78 11483.2195 18 135473 112958.65 22514.3469 19 202925 184699.26 18225.7368 20 215147 184699.26 30447.7368 21 344297 225301.78 118995.2195 22 153935 112958.65 40976.3469 23 132943 112958.65 19984.3469 24 174724 225301.78 -50577.7805 25 174415 225301.78 -50886.7805 26 225548 225301.78 246.2195 27 223632 146266.90 77365.1026 28 124817 146266.90 -21449.8974 29 221698 184699.26 36998.7368 30 210767 184699.26 26067.7368 31 170266 146266.90 23999.1026 32 260561 225301.78 35259.2195 33 84853 87083.60 -2230.6047 34 294424 322592.29 -28168.2941 35 101011 87083.60 13927.3953 36 215641 184699.26 30941.7368 37 325107 225301.78 99805.2195 38 7176 16673.14 -9497.1429 39 167542 146266.90 21275.1026 40 106408 87083.60 19324.3953 41 96560 146266.90 -49706.8974 42 265769 225301.78 40467.2195 43 269651 322592.29 -52941.2941 44 149112 146266.90 2845.1026 45 175824 225301.78 -49477.7805 46 152871 146266.90 6604.1026 47 111665 87083.60 24581.3953 48 116408 184699.26 -68291.2632 49 362301 322592.29 39708.7059 50 78800 87083.60 -8283.6047 51 183167 184699.26 -1532.2632 52 277965 322592.29 -44627.2941 53 150629 184699.26 -34070.2632 54 168809 112958.65 55850.3469 55 24188 53887.54 -29699.5417 56 329267 225301.78 103965.2195 57 65029 63620.64 1408.3636 58 101097 112958.65 -11861.6531 59 218946 184699.26 34246.7368 60 244052 225301.78 18750.2195 61 341570 322592.29 18977.7059 62 103597 112958.65 -9361.6531 63 233328 225301.78 8026.2195 64 256462 225301.78 31160.2195 65 206161 225301.78 -19140.7805 66 311473 322592.29 -11119.2941 67 235800 225301.78 10498.2195 68 177939 225301.78 -47362.7805 69 207176 225301.78 -18125.7805 70 196553 146266.90 50286.1026 71 174184 112958.65 61225.3469 72 143246 146266.90 -3020.8974 73 187559 225301.78 -37742.7805 74 187681 184699.26 2981.7368 75 119016 112958.65 6057.3469 76 182192 184699.26 -2507.2632 77 73566 112958.65 -39392.6531 78 194979 184699.26 10279.7368 79 167488 184699.26 -17211.2632 80 143756 146266.90 -2510.8974 81 275541 184699.26 90841.7368 82 243199 225301.78 17897.2195 83 182999 112958.65 70040.3469 84 135649 112958.65 22690.3469 85 152299 146266.90 6032.1026 86 120221 146266.90 -26045.8974 87 346485 322592.29 23892.7059 88 145790 184699.26 -38909.2632 89 193339 146266.90 47072.1026 90 80953 112958.65 -32005.6531 91 122774 184699.26 -61925.2632 92 130585 87083.60 43501.3953 93 112611 87083.60 25527.3953 94 286468 322592.29 -36124.2941 95 241066 225301.78 15764.2195 96 148446 225301.78 -76855.7805 97 204713 225301.78 -20588.7805 98 182079 146266.90 35812.1026 99 140344 146266.90 -5922.8974 100 220516 184699.26 35816.7368 101 243060 184699.26 58360.7368 102 162765 146266.90 16498.1026 103 182613 146266.90 36346.1026 104 232138 184699.26 47438.7368 105 265318 225301.78 40016.2195 106 85574 87083.60 -1509.6047 107 310839 322592.29 -11753.2941 108 225060 225301.78 -241.7805 109 232317 184699.26 47617.7368 110 144966 112958.65 32007.3469 111 43287 41207.00 2080.0000 112 155754 184699.26 -28945.2632 113 164709 225301.78 -60592.7805 114 201940 184699.26 17240.7368 115 235454 225301.78 10152.2195 116 220801 225301.78 -4500.7805 117 99466 87083.60 12382.3953 118 92661 146266.90 -53605.8974 119 133328 146266.90 -12938.8974 120 61361 112958.65 -51597.6531 121 125930 225301.78 -99371.7805 122 100750 112958.65 -12208.6531 123 224549 146266.90 78282.1026 124 82316 87083.60 -4767.6047 125 102010 112958.65 -10948.6531 126 101523 87083.60 14439.3953 127 243511 225301.78 18209.2195 128 22938 41207.00 -18269.0000 129 41566 53887.54 -12321.5417 130 152474 184699.26 -32225.2632 131 61857 53887.54 7969.4583 132 99923 184699.26 -84776.2632 133 132487 112958.65 19528.3469 134 317394 322592.29 -5198.2941 135 21054 41207.00 -20153.0000 136 209641 184699.26 24941.7368 137 22648 41207.00 -18559.0000 138 31414 41207.00 -9793.0000 139 46698 87083.60 -40385.6047 140 131698 146266.90 -14568.8974 141 91735 112958.65 -21223.6531 142 244749 225301.78 19447.2195 143 184510 146266.90 38243.1026 144 79863 112958.65 -33095.6531 145 128423 112958.65 15464.3469 146 97839 112958.65 -15119.6531 147 38214 87083.60 -48869.6047 148 151101 146266.90 4834.1026 149 272458 184699.26 87758.7368 150 172494 112958.65 59535.3469 151 108043 146266.90 -38223.8974 152 328107 322592.29 5514.7059 153 250579 225301.78 25277.2195 154 351067 322592.29 28474.7059 155 158015 112958.65 45056.3469 156 98866 112958.65 -14092.6531 157 85439 87083.60 -1644.6047 158 229242 225301.78 3940.2195 159 351619 322592.29 29026.7059 160 84207 87083.60 -2876.6047 161 120445 112958.65 7486.3469 162 324598 322592.29 2005.7059 163 131069 184699.26 -53630.2632 164 204271 146266.90 58004.1026 165 165543 184699.26 -19156.2632 166 141722 112958.65 28763.3469 167 116048 87083.60 28964.3953 168 250047 225301.78 24745.2195 169 299775 322592.29 -22817.2941 170 195838 184699.26 11138.7368 171 173260 184699.26 -11439.2632 172 254488 225301.78 29186.2195 173 104389 146266.90 -41877.8974 174 136084 184699.26 -48615.2632 175 199476 225301.78 -25825.7805 176 92499 87083.60 5415.3953 177 224330 225301.78 -971.7805 178 135781 112958.65 22822.3469 179 74408 112958.65 -38550.6531 180 81240 146266.90 -65026.8974 181 14688 16673.14 -1985.1429 182 181633 225301.78 -43668.7805 183 271856 225301.78 46554.2195 184 7199 16673.14 -9474.1429 185 46660 63620.64 -16960.6364 186 17547 16673.14 873.8571 187 133368 146266.90 -12898.8974 188 95227 87083.60 8143.3953 189 152601 112958.65 39642.3469 190 98146 112958.65 -14812.6531 191 79619 112958.65 -33339.6531 192 59194 87083.60 -27889.6047 193 139942 146266.90 -6324.8974 194 118612 112958.65 5653.3469 195 72880 112958.65 -40078.6531 196 65475 41207.00 24268.0000 197 99643 146266.90 -46623.8974 198 71965 87083.60 -15118.6047 199 77272 53887.54 23384.4583 200 49289 41207.00 8082.0000 201 135131 146266.90 -11135.8974 202 108446 112958.65 -4512.6531 203 89746 184699.26 -94953.2632 204 44296 53887.54 -9591.5417 205 77648 87083.60 -9435.6047 206 181528 184699.26 -3171.2632 207 134019 112958.65 21060.3469 208 124064 112958.65 11105.3469 209 92630 112958.65 -20328.6531 210 121848 87083.60 34764.3953 211 52915 41207.00 11708.0000 212 81872 87083.60 -5211.6047 213 58981 112958.65 -53977.6531 214 53515 53887.54 -372.5417 215 60812 112958.65 -52146.6531 216 56375 53887.54 2487.4583 217 65490 53887.54 11602.4583 218 80949 41207.00 39742.0000 219 76302 87083.60 -10781.6047 220 104011 112958.65 -8947.6531 221 98104 184699.26 -86595.2632 222 67989 53887.54 14101.4583 223 30989 16673.14 14315.8571 224 135458 225301.78 -89843.7805 225 73504 87083.60 -13579.6047 226 63123 87083.60 -23960.6047 227 61254 87083.60 -25829.6047 228 74914 112958.65 -38044.6531 229 31774 53887.54 -22113.5417 230 81437 87083.60 -5646.6047 231 87186 146266.90 -59080.8974 232 50090 41207.00 8883.0000 233 65745 87083.60 -21338.6047 234 56653 53887.54 2765.4583 235 158399 112958.65 45440.3469 236 46455 41207.00 5248.0000 237 73624 112958.65 -39334.6531 238 38395 53887.54 -15492.5417 239 91899 87083.60 4815.3953 240 139526 112958.65 26567.3469 241 52164 53887.54 -1723.5417 242 51567 53887.54 -2320.5417 243 70551 87083.60 -16532.6047 244 84856 112958.65 -28102.6531 245 102538 146266.90 -43728.8974 246 86678 87083.60 -405.6047 247 85709 87083.60 -1374.6047 248 34662 63620.64 -28958.6364 249 150580 146266.90 4313.1026 250 99611 87083.60 12527.3953 251 19349 16673.14 2675.8571 252 99373 112958.65 -13585.6531 253 86230 146266.90 -60036.8974 254 30837 41207.00 -10370.0000 255 31706 41207.00 -9501.0000 256 89806 87083.60 2722.3953 257 62088 53887.54 8200.4583 258 40151 53887.54 -13736.5417 259 27634 41207.00 -13573.0000 260 76990 53887.54 23102.4583 261 37460 41207.00 -3747.0000 262 54157 41207.00 12950.0000 263 49862 53887.54 -4025.5417 264 84337 63620.64 20716.3636 265 64175 87083.60 -22908.6047 266 59382 53887.54 5494.4583 267 119308 87083.60 32224.3953 268 76702 87083.60 -10381.6047 269 103425 112958.65 -9533.6531 270 70344 63620.64 6723.3636 271 43410 63620.64 -20210.6364 272 104838 87083.60 17754.3953 273 62215 53887.54 8327.4583 274 69304 87083.60 -17779.6047 275 53117 53887.54 -770.5417 276 19764 16673.14 3090.8571 277 86680 87083.60 -403.6047 278 84105 63620.64 20484.3636 279 77945 63620.64 14324.3636 280 89113 87083.60 2029.3953 281 91005 112958.65 -21953.6531 282 40248 41207.00 -959.0000 283 64187 63620.64 566.3636 284 50857 53887.54 -3030.5417 285 56613 63620.64 -7007.6364 286 62792 53887.54 8904.4583 287 72535 63620.64 8914.3636 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/fisher/rcomp/tmp/49ips1354811087.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > if(par2=='none') { + op <- par(mfrow=c(2,2)) + plot(density(result$Actuals),main='Kernel Density Plot of Actuals') + plot(density(result$Residuals),main='Kernel Density Plot of Residuals') + plot(result$Forecasts,result$Actuals,main='Actuals versus Predictions',xlab='Predictions',ylab='Actuals') + plot(density(result$Forecasts),main='Kernel Density Plot of Predictions') + par(op) + } > if(par2!='none') { + plot(myt,main='Confusion Matrix',xlab='Actual',ylab='Predicted') + } > dev.off() null device 1 > if (par2 == 'none') { + detcoef <- cor(result$Forecasts,result$Actuals) + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goodness of Fit',2,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Correlation',1,TRUE) + a<-table.element(a,round(detcoef,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'R-squared',1,TRUE) + a<-table.element(a,round(detcoef*detcoef,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'RMSE',1,TRUE) + a<-table.element(a,round(sqrt(mean((result$Residuals)^2)),4)) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/fisher/rcomp/tmp/54c061354811087.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Actuals, Predictions, and Residuals',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'#',header=TRUE) + a<-table.element(a,'Actuals',header=TRUE) + a<-table.element(a,'Forecasts',header=TRUE) + a<-table.element(a,'Residuals',header=TRUE) + a<-table.row.end(a) + for (i in 1:length(result$Actuals)) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,result$Actuals[i]) + a<-table.element(a,result$Forecasts[i]) + a<-table.element(a,result$Residuals[i]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/fisher/rcomp/tmp/6vjlp1354811087.tab") + } > if (par2 != 'none') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Confusion Matrix (predicted in columns / actuals in rows)',par3+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'',1,TRUE) + for (i in 1:par3) { + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + } + a<-table.row.end(a) + for (i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + for (j in 1:par3) { + a<-table.element(a,myt[i,j]) + } + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/fisher/rcomp/tmp/7syvh1354811087.tab") + } > > try(system("convert tmp/2e5re1354811087.ps tmp/2e5re1354811087.png",intern=TRUE)) character(0) > try(system("convert tmp/3zcls1354811087.ps tmp/3zcls1354811087.png",intern=TRUE)) character(0) > try(system("convert tmp/49ips1354811087.ps tmp/49ips1354811087.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.990 0.614 7.589