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 = '2' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '2' > #'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] "logins" > x[,par1] [1] 54 89 40 25 92 18 63 44 33 84 88 55 60 66 154 53 119 41 [19] 61 58 75 33 40 92 100 112 73 40 45 60 62 75 31 77 34 46 [37] 99 17 66 30 76 146 67 56 107 58 34 61 119 42 66 89 44 66 [55] 24 259 17 64 41 68 168 43 132 105 71 112 94 82 70 57 53 103 [73] 121 62 52 52 32 62 45 46 63 75 88 46 53 37 90 63 78 25 [91] 45 46 41 144 82 91 71 63 53 62 63 32 39 62 117 34 92 93 [109] 54 144 14 61 109 38 73 75 50 61 55 77 75 72 50 32 53 42 [127] 71 10 35 65 25 66 41 86 16 42 19 19 45 65 35 95 49 37 [145] 64 38 34 32 65 52 62 65 83 95 29 18 33 247 139 29 118 110 [163] 67 42 65 94 64 81 95 67 63 83 45 30 70 32 83 31 67 66 [181] 10 70 103 5 20 5 36 34 48 40 43 31 42 46 33 18 55 35 [199] 59 19 66 60 36 25 47 54 53 40 40 39 14 45 36 28 44 30 [217] 22 17 31 55 54 21 14 81 35 43 46 30 23 38 54 20 53 45 [235] 39 20 24 31 35 151 52 30 31 29 57 40 44 25 77 35 11 63 [253] 44 19 13 42 38 29 20 27 20 19 37 26 42 49 30 49 67 28 [271] 19 49 27 30 22 12 31 20 20 39 29 16 27 21 19 35 14 > 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]) 5 10 11 12 13 14 16 17 18 19 20 21 22 23 24 25 26 27 28 29 2 2 1 1 1 4 2 3 3 7 7 2 2 1 2 5 1 3 2 5 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 7 7 5 4 5 7 3 3 4 4 7 4 7 3 5 7 6 1 1 4 50 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 70 71 2 4 7 5 4 1 2 2 1 3 4 6 7 3 5 7 5 1 3 3 72 73 75 76 77 78 81 82 83 84 86 88 89 90 91 92 93 94 95 99 1 2 5 1 3 1 2 2 3 1 1 2 2 1 1 3 1 2 3 1 100 103 105 107 109 110 112 117 118 119 121 132 139 144 146 151 154 168 247 259 1 2 1 1 1 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 > colnames(x) [1] "time_in_rfc" "logins" "compendium_views_info" [4] "compendium_views_pr" > colnames(x)[par1] [1] "logins" > x[,par1] [1] 54 89 40 25 92 18 63 44 33 84 88 55 60 66 154 53 119 41 [19] 61 58 75 33 40 92 100 112 73 40 45 60 62 75 31 77 34 46 [37] 99 17 66 30 76 146 67 56 107 58 34 61 119 42 66 89 44 66 [55] 24 259 17 64 41 68 168 43 132 105 71 112 94 82 70 57 53 103 [73] 121 62 52 52 32 62 45 46 63 75 88 46 53 37 90 63 78 25 [91] 45 46 41 144 82 91 71 63 53 62 63 32 39 62 117 34 92 93 [109] 54 144 14 61 109 38 73 75 50 61 55 77 75 72 50 32 53 42 [127] 71 10 35 65 25 66 41 86 16 42 19 19 45 65 35 95 49 37 [145] 64 38 34 32 65 52 62 65 83 95 29 18 33 247 139 29 118 110 [163] 67 42 65 94 64 81 95 67 63 83 45 30 70 32 83 31 67 66 [181] 10 70 103 5 20 5 36 34 48 40 43 31 42 46 33 18 55 35 [199] 59 19 66 60 36 25 47 54 53 40 40 39 14 45 36 28 44 30 [217] 22 17 31 55 54 21 14 81 35 43 46 30 23 38 54 20 53 45 [235] 39 20 24 31 35 151 52 30 31 29 57 40 44 25 77 35 11 63 [253] 44 19 13 42 38 29 20 27 20 19 37 26 42 49 30 49 67 28 [271] 19 49 27 30 22 12 31 20 20 39 29 16 27 21 19 35 14 > 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/1tb9a1354810630.tab") + } + } > m Conditional inference tree with 6 terminal nodes Response: logins Inputs: time_in_rfc, compendium_views_info, compendium_views_pr Number of observations: 287 1) time_in_rfc <= 136084; criterion = 1, statistic = 146.996 2) compendium_views_info <= 367; criterion = 1, statistic = 71.047 3) time_in_rfc <= 56613; criterion = 1, statistic = 39.957 4) time_in_rfc <= 31706; criterion = 0.999, statistic = 12.689 5)* weights = 15 4) time_in_rfc > 31706 6)* weights = 28 3) time_in_rfc > 56613 7)* weights = 61 2) compendium_views_info > 367 8)* weights = 62 1) time_in_rfc > 136084 9) time_in_rfc <= 224549; criterion = 1, statistic = 23.355 10)* weights = 73 9) time_in_rfc > 224549 11)* weights = 48 > postscript(file="/var/fisher/rcomp/tmp/2pchl1354810630.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/3pfy81354810630.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 54 64.87671 -10.8767123 2 89 64.87671 24.1232877 3 40 35.19672 4.8032787 4 25 25.35714 -0.3571429 5 92 99.68750 -7.6875000 6 18 25.35714 -7.3571429 7 63 50.87097 12.1290323 8 44 64.87671 -20.8767123 9 33 64.87671 -31.8767123 10 84 99.68750 -15.6875000 11 88 64.87671 23.1232877 12 55 50.87097 4.1290323 13 60 99.68750 -39.6875000 14 66 64.87671 1.1232877 15 154 99.68750 54.3125000 16 53 99.68750 -46.6875000 17 119 99.68750 19.3125000 18 41 50.87097 -9.8709677 19 61 64.87671 -3.8767123 20 58 64.87671 -6.8767123 21 75 99.68750 -24.6875000 22 33 64.87671 -31.8767123 23 40 50.87097 -10.8709677 24 92 64.87671 27.1232877 25 100 64.87671 35.1232877 26 112 99.68750 12.3125000 27 73 64.87671 8.1232877 28 40 50.87097 -10.8709677 29 45 64.87671 -19.8767123 30 60 64.87671 -4.8767123 31 62 64.87671 -2.8767123 32 75 99.68750 -24.6875000 33 31 35.19672 -4.1967213 34 77 99.68750 -22.6875000 35 34 35.19672 -1.1967213 36 46 64.87671 -18.8767123 37 99 99.68750 -0.6875000 38 17 14.26667 2.7333333 39 66 64.87671 1.1232877 40 30 35.19672 -5.1967213 41 76 50.87097 25.1290323 42 146 99.68750 46.3125000 43 67 99.68750 -32.6875000 44 56 64.87671 -8.8767123 45 107 64.87671 42.1232877 46 58 64.87671 -6.8767123 47 34 35.19672 -1.1967213 48 61 50.87097 10.1290323 49 119 99.68750 19.3125000 50 42 35.19672 6.8032787 51 66 64.87671 1.1232877 52 89 99.68750 -10.6875000 53 44 64.87671 -20.8767123 54 66 64.87671 1.1232877 55 24 14.26667 9.7333333 56 259 99.68750 159.3125000 57 17 35.19672 -18.1967213 58 64 50.87097 13.1290323 59 41 64.87671 -23.8767123 60 68 99.68750 -31.6875000 61 168 99.68750 68.3125000 62 43 50.87097 -7.8709677 63 132 99.68750 32.3125000 64 105 99.68750 5.3125000 65 71 64.87671 6.1232877 66 112 99.68750 12.3125000 67 94 99.68750 -5.6875000 68 82 64.87671 17.1232877 69 70 64.87671 5.1232877 70 57 64.87671 -7.8767123 71 53 64.87671 -11.8767123 72 103 64.87671 38.1232877 73 121 64.87671 56.1232877 74 62 64.87671 -2.8767123 75 52 50.87097 1.1290323 76 52 64.87671 -12.8767123 77 32 50.87097 -18.8709677 78 62 64.87671 -2.8767123 79 45 64.87671 -19.8767123 80 46 64.87671 -18.8767123 81 63 99.68750 -36.6875000 82 75 99.68750 -24.6875000 83 88 64.87671 23.1232877 84 46 50.87097 -4.8709677 85 53 64.87671 -11.8767123 86 37 50.87097 -13.8709677 87 90 99.68750 -9.6875000 88 63 64.87671 -1.8767123 89 78 64.87671 13.1232877 90 25 50.87097 -25.8709677 91 45 50.87097 -5.8709677 92 46 35.19672 10.8032787 93 41 35.19672 5.8032787 94 144 99.68750 44.3125000 95 82 99.68750 -17.6875000 96 91 64.87671 26.1232877 97 71 64.87671 6.1232877 98 63 64.87671 -1.8767123 99 53 64.87671 -11.8767123 100 62 64.87671 -2.8767123 101 63 99.68750 -36.6875000 102 32 64.87671 -32.8767123 103 39 64.87671 -25.8767123 104 62 99.68750 -37.6875000 105 117 99.68750 17.3125000 106 34 35.19672 -1.1967213 107 92 99.68750 -7.6875000 108 93 99.68750 -6.6875000 109 54 99.68750 -45.6875000 110 144 64.87671 79.1232877 111 14 25.35714 -11.3571429 112 61 64.87671 -3.8767123 113 109 64.87671 44.1232877 114 38 64.87671 -26.8767123 115 73 99.68750 -26.6875000 116 75 64.87671 10.1232877 117 50 35.19672 14.8032787 118 61 50.87097 10.1290323 119 55 50.87097 4.1290323 120 77 50.87097 26.1290323 121 75 50.87097 24.1290323 122 72 50.87097 21.1290323 123 50 64.87671 -14.8767123 124 32 35.19672 -3.1967213 125 53 50.87097 2.1290323 126 42 35.19672 6.8032787 127 71 99.68750 -28.6875000 128 10 14.26667 -4.2666667 129 35 25.35714 9.6428571 130 65 64.87671 0.1232877 131 25 35.19672 -10.1967213 132 66 50.87097 15.1290323 133 41 50.87097 -9.8709677 134 86 99.68750 -13.6875000 135 16 14.26667 1.7333333 136 42 64.87671 -22.8767123 137 19 14.26667 4.7333333 138 19 14.26667 4.7333333 139 45 25.35714 19.6428571 140 65 50.87097 14.1290323 141 35 50.87097 -15.8709677 142 95 99.68750 -4.6875000 143 49 64.87671 -15.8767123 144 37 50.87097 -13.8709677 145 64 50.87097 13.1290323 146 38 50.87097 -12.8709677 147 34 25.35714 8.6428571 148 32 64.87671 -32.8767123 149 65 99.68750 -34.6875000 150 52 64.87671 -12.8767123 151 62 50.87097 11.1290323 152 65 99.68750 -34.6875000 153 83 99.68750 -16.6875000 154 95 99.68750 -4.6875000 155 29 64.87671 -35.8767123 156 18 50.87097 -32.8709677 157 33 35.19672 -2.1967213 158 247 99.68750 147.3125000 159 139 99.68750 39.3125000 160 29 35.19672 -6.1967213 161 118 50.87097 67.1290323 162 110 99.68750 10.3125000 163 67 50.87097 16.1290323 164 42 64.87671 -22.8767123 165 65 64.87671 0.1232877 166 94 64.87671 29.1232877 167 64 35.19672 28.8032787 168 81 99.68750 -18.6875000 169 95 99.68750 -4.6875000 170 67 64.87671 2.1232877 171 63 64.87671 -1.8767123 172 83 99.68750 -16.6875000 173 45 50.87097 -5.8709677 174 30 50.87097 -20.8709677 175 70 64.87671 5.1232877 176 32 35.19672 -3.1967213 177 83 64.87671 18.1232877 178 31 50.87097 -19.8709677 179 67 50.87097 16.1290323 180 66 50.87097 15.1290323 181 10 14.26667 -4.2666667 182 70 64.87671 5.1232877 183 103 99.68750 3.3125000 184 5 14.26667 -9.2666667 185 20 25.35714 -5.3571429 186 5 14.26667 -9.2666667 187 36 50.87097 -14.8709677 188 34 35.19672 -1.1967213 189 48 64.87671 -16.8767123 190 40 50.87097 -10.8709677 191 43 50.87097 -7.8709677 192 31 35.19672 -4.1967213 193 42 64.87671 -22.8767123 194 46 50.87097 -4.8709677 195 33 50.87097 -17.8709677 196 18 35.19672 -17.1967213 197 55 50.87097 4.1290323 198 35 35.19672 -0.1967213 199 59 35.19672 23.8032787 200 19 25.35714 -6.3571429 201 66 50.87097 15.1290323 202 60 50.87097 9.1290323 203 36 50.87097 -14.8709677 204 25 25.35714 -0.3571429 205 47 35.19672 11.8032787 206 54 64.87671 -10.8767123 207 53 50.87097 2.1290323 208 40 50.87097 -10.8709677 209 40 50.87097 -10.8709677 210 39 35.19672 3.8032787 211 14 25.35714 -11.3571429 212 45 35.19672 9.8032787 213 36 50.87097 -14.8709677 214 28 25.35714 2.6428571 215 44 50.87097 -6.8709677 216 30 25.35714 4.6428571 217 22 35.19672 -13.1967213 218 17 35.19672 -18.1967213 219 31 35.19672 -4.1967213 220 55 50.87097 4.1290323 221 54 50.87097 3.1290323 222 21 35.19672 -14.1967213 223 14 14.26667 -0.2666667 224 81 50.87097 30.1290323 225 35 35.19672 -0.1967213 226 43 35.19672 7.8032787 227 46 35.19672 10.8032787 228 30 50.87097 -20.8709677 229 23 25.35714 -2.3571429 230 38 35.19672 2.8032787 231 54 50.87097 3.1290323 232 20 25.35714 -5.3571429 233 53 35.19672 17.8032787 234 45 35.19672 9.8032787 235 39 64.87671 -25.8767123 236 20 25.35714 -5.3571429 237 24 35.19672 -11.1967213 238 31 25.35714 5.6428571 239 35 35.19672 -0.1967213 240 151 64.87671 86.1232877 241 52 25.35714 26.6428571 242 30 25.35714 4.6428571 243 31 35.19672 -4.1967213 244 29 50.87097 -21.8709677 245 57 50.87097 6.1290323 246 40 35.19672 4.8032787 247 44 35.19672 8.8032787 248 25 25.35714 -0.3571429 249 77 64.87671 12.1232877 250 35 35.19672 -0.1967213 251 11 14.26667 -3.2666667 252 63 50.87097 12.1290323 253 44 50.87097 -6.8709677 254 19 14.26667 4.7333333 255 13 14.26667 -1.2666667 256 42 35.19672 6.8032787 257 38 35.19672 2.8032787 258 29 25.35714 3.6428571 259 20 14.26667 5.7333333 260 27 35.19672 -8.1967213 261 20 25.35714 -5.3571429 262 19 25.35714 -6.3571429 263 37 25.35714 11.6428571 264 26 35.19672 -9.1967213 265 42 35.19672 6.8032787 266 49 35.19672 13.8032787 267 30 35.19672 -5.1967213 268 49 35.19672 13.8032787 269 67 50.87097 16.1290323 270 28 35.19672 -7.1967213 271 19 25.35714 -6.3571429 272 49 35.19672 13.8032787 273 27 35.19672 -8.1967213 274 30 35.19672 -5.1967213 275 22 25.35714 -3.3571429 276 12 14.26667 -2.2666667 277 31 35.19672 -4.1967213 278 20 35.19672 -15.1967213 279 20 35.19672 -15.1967213 280 39 35.19672 3.8032787 281 29 50.87097 -21.8709677 282 16 25.35714 -9.3571429 283 27 35.19672 -8.1967213 284 21 25.35714 -4.3571429 285 19 25.35714 -6.3571429 286 35 35.19672 -0.1967213 287 14 35.19672 -21.1967213 > 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/41lxi1354810630.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/5om021354810630.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/64w651354810631.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/78ezu1354810631.tab") + } > > try(system("convert tmp/2pchl1354810630.ps tmp/2pchl1354810630.png",intern=TRUE)) character(0) > try(system("convert tmp/3pfy81354810630.ps tmp/3pfy81354810630.png",intern=TRUE)) character(0) > try(system("convert tmp/41lxi1354810630.ps tmp/41lxi1354810630.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.565 0.623 7.182