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(1418 + ,210907 + ,56 + ,396 + ,3 + ,115 + ,112285 + ,869 + ,120982 + ,56 + ,297 + ,4 + ,109 + ,84786 + ,1530 + ,176508 + ,54 + ,559 + ,12 + ,146 + ,83123 + ,2172 + ,179321 + ,89 + ,967 + ,2 + ,116 + ,101193 + ,901 + ,123185 + ,40 + ,270 + ,1 + ,68 + ,38361 + ,463 + ,52746 + ,25 + ,143 + ,3 + ,101 + ,68504 + ,3201 + ,385534 + ,92 + ,1562 + ,0 + ,96 + ,119182 + ,371 + ,33170 + ,18 + ,109 + ,0 + ,67 + ,22807 + ,1583 + ,149061 + ,44 + ,656 + ,5 + ,100 + ,116174 + ,1439 + ,165446 + ,33 + ,511 + ,0 + ,93 + ,57635 + ,1764 + ,237213 + ,84 + ,655 + ,0 + ,140 + ,66198 + ,1495 + ,173326 + ,88 + ,465 + ,7 + ,166 + ,71701 + ,1373 + ,133131 + ,55 + ,525 + ,7 + ,99 + ,57793 + ,2187 + ,258873 + ,60 + ,885 + ,3 + ,139 + ,80444 + ,1491 + ,180083 + ,66 + ,497 + ,9 + ,130 + ,53855 + ,4041 + ,324799 + ,154 + ,1436 + ,0 + ,181 + ,97668 + ,1706 + ,230964 + ,53 + ,612 + ,4 + ,116 + ,133824 + ,2152 + ,236785 + ,119 + ,865 + ,3 + ,116 + ,101481 + ,1036 + ,135473 + ,41 + ,385 + ,0 + ,88 + ,99645 + ,1882 + ,202925 + ,61 + ,567 + ,7 + ,139 + ,114789 + ,1929 + ,215147 + ,58 + ,639 + ,0 + ,135 + ,99052 + ,2242 + ,344297 + ,75 + ,963 + ,1 + ,108 + ,67654 + ,1220 + ,153935 + ,33 + ,398 + ,5 + ,89 + ,65553 + ,1289 + ,132943 + ,40 + ,410 + ,7 + ,156 + ,97500 + ,2515 + ,174724 + ,92 + ,966 + ,0 + ,129 + ,69112 + ,2147 + ,174415 + ,100 + ,801 + ,0 + ,118 + ,82753 + ,2352 + ,225548 + ,112 + ,892 + ,5 + ,118 + ,85323 + ,1638 + ,223632 + ,73 + ,513 + ,0 + ,125 + ,72654 + ,1222 + ,124817 + ,40 + ,469 + ,0 + ,95 + ,30727 + ,1812 + ,221698 + ,45 + ,683 + ,0 + ,126 + ,77873 + ,1677 + ,210767 + ,60 + ,643 + ,3 + ,135 + ,117478 + ,1579 + ,170266 + ,62 + ,535 + ,4 + ,154 + ,74007 + ,1731 + ,260561 + ,75 + ,625 + ,1 + ,165 + ,90183 + ,807 + ,84853 + ,31 + ,264 + ,4 + ,113 + ,61542 + ,2452 + ,294424 + ,77 + ,992 + ,2 + ,127 + ,101494 + ,1940 + ,215641 + ,46 + ,818 + ,0 + ,121 + ,55813 + ,2662 + ,325107 + ,99 + ,937 + ,0 + ,136 + ,79215 + ,1499 + ,167542 + ,66 + ,507 + ,2 + ,108 + ,55461 + ,865 + ,106408 + ,30 + ,260 + ,1 + ,46 + ,31081 + ,2527 + ,265769 + ,146 + ,927 + ,2 + ,124 + ,83122 + ,2747 + ,269651 + ,67 + ,1269 + ,10 + ,115 + ,70106 + ,1324 + ,149112 + ,56 + ,537 + ,6 + ,128 + ,60578 + ,1383 + ,152871 + ,58 + ,532 + ,5 + ,97 + ,79892 + ,1179 + ,111665 + ,34 + ,345 + ,4 + ,104 + ,49810 + ,2099 + ,116408 + ,61 + ,918 + ,1 + ,59 + ,71570 + ,4308 + ,362301 + ,119 + ,1635 + ,2 + ,125 + ,100708 + ,918 + ,78800 + ,42 + ,330 + ,2 + ,82 + ,33032 + ,1831 + ,183167 + ,66 + ,557 + ,0 + ,149 + ,82875 + ,3373 + ,277965 + ,89 + ,1178 + ,8 + ,149 + ,139077 + ,1713 + ,150629 + ,44 + ,740 + ,3 + ,122 + ,71595 + ,1438 + ,168809 + ,66 + ,452 + ,0 + ,118 + ,72260 + ,496 + ,24188 + ,24 + ,218 + ,0 + ,12 + ,5950 + ,2253 + ,329267 + ,259 + ,764 + ,8 + ,144 + ,115762 + ,744 + ,65029 + ,17 + ,255 + ,5 + ,67 + ,32551 + ,1161 + ,101097 + ,64 + ,454 + ,3 + ,52 + ,31701 + ,2352 + ,218946 + ,41 + ,866 + ,1 + ,108 + ,80670 + ,2144 + ,244052 + ,68 + ,574 + ,5 + ,166 + ,143558 + ,2694 + ,233328 + ,132 + ,825 + ,5 + ,107 + ,120733 + ,1973 + ,256462 + ,105 + ,798 + ,0 + ,127 + ,105195 + ,1769 + ,206161 + ,71 + ,663 + ,12 + ,107 + ,73107 + ,3148 + ,311473 + ,112 + ,1069 + ,8 + ,146 + ,132068 + ,2474 + ,235800 + ,94 + ,921 + ,8 + ,84 + ,149193 + ,2084 + ,177939 + ,82 + ,858 + ,8 + ,141 + ,46821 + ,1954 + ,207176 + ,70 + ,711 + ,8 + ,123 + ,87011 + ,1226 + ,196553 + ,57 + ,503 + ,2 + ,111 + ,95260 + ,1389 + ,174184 + ,53 + ,382 + ,0 + ,98 + ,55183 + ,1496 + ,143246 + ,103 + ,464 + ,5 + ,105 + ,106671 + ,2269 + ,187559 + ,121 + ,717 + ,8 + ,135 + ,73511 + ,1833 + ,187681 + ,62 + ,690 + ,2 + ,107 + ,92945 + ,1268 + ,119016 + ,52 + ,462 + ,5 + ,85 + ,78664 + ,1943 + ,182192 + ,52 + ,657 + ,12 + ,155 + ,70054 + ,893 + ,73566 + ,32 + ,385 + ,6 + ,88 + ,22618 + ,1762 + ,194979 + ,62 + ,577 + ,7 + ,155 + ,74011 + ,1403 + ,167488 + ,45 + ,619 + ,2 + ,104 + ,83737 + ,1425 + ,143756 + ,46 + ,479 + ,0 + ,132 + ,69094 + ,1857 + ,275541 + ,63 + ,817 + ,4 + ,127 + ,93133 + ,1840 + ,243199 + ,75 + ,752 + ,3 + ,108 + ,95536 + ,1502 + ,182999 + ,88 + ,430 + ,6 + ,129 + ,225920 + ,1441 + ,135649 + ,46 + ,451 + ,2 + ,116 + ,62133 + ,1420 + ,152299 + ,53 + ,537 + ,0 + ,122 + ,61370 + ,1416 + ,120221 + ,37 + ,519 + ,1 + ,85 + ,43836 + ,2970 + ,346485 + ,90 + ,1000 + ,0 + ,147 + ,106117 + ,1317 + ,145790 + ,63 + ,637 + ,5 + ,99 + ,38692 + ,1644 + ,193339 + ,78 + ,465 + ,2 + ,87 + ,84651 + ,870 + ,80953 + ,25 + ,437 + ,0 + ,28 + ,56622 + ,1654 + ,122774 + ,45 + ,711 + ,0 + ,90 + ,15986 + ,1054 + ,130585 + ,46 + ,299 + ,5 + ,109 + ,95364 + ,3004 + ,286468 + ,144 + ,1162 + ,1 + ,111 + ,89691 + ,2008 + ,241066 + ,82 + ,714 + ,0 + ,158 + ,67267 + ,2547 + ,148446 + ,91 + ,905 + ,1 + ,141 + ,126846 + ,1885 + ,204713 + ,71 + ,649 + ,1 + ,122 + ,41140 + ,1626 + ,182079 + ,63 + ,512 + ,2 + ,124 + ,102860 + ,1468 + ,140344 + ,53 + ,472 + ,6 + ,93 + ,51715 + ,2445 + ,220516 + ,62 + ,905 + ,1 + ,124 + ,55801 + ,1964 + ,243060 + ,63 + ,786 + ,4 + ,112 + ,111813 + ,1381 + ,162765 + ,32 + ,489 + ,2 + ,108 + ,120293 + ,1369 + ,182613 + ,39 + ,479 + ,3 + ,99 + ,138599 + ,1659 + ,232138 + ,62 + ,617 + ,0 + ,117 + ,161647 + ,2888 + ,265318 + ,117 + ,925 + ,10 + ,199 + ,115929 + ,2845 + ,310839 + ,92 + ,1144 + ,9 + ,91 + ,162901 + ,1982 + ,225060 + ,93 + ,669 + ,7 + ,158 + ,109825 + ,1904 + ,232317 + ,54 + ,707 + ,0 + ,126 + ,129838 + ,1391 + ,144966 + ,144 + ,458 + ,0 + ,122 + ,37510 + ,602 + ,43287 + ,14 + ,214 + ,4 + ,71 + ,43750 + ,1743 + ,155754 + ,61 + ,599 + ,4 + ,75 + ,40652 + ,1559 + ,164709 + ,109 + ,572 + ,0 + ,115 + ,87771 + ,2014 + ,201940 + ,38 + ,897 + ,0 + ,119 + ,85872 + ,2143 + ,235454 + ,73 + ,819 + ,0 + ,124 + ,89275 + ,874 + ,99466 + ,50 + ,273 + ,0 + ,91 + ,192565 + ,1281 + ,100750 + ,72 + ,407 + ,0 + ,119 + ,140867 + ,1401 + ,224549 + ,50 + ,465 + ,4 + ,117 + ,120662 + ,1944 + ,243511 + ,71 + ,603 + ,0 + ,155 + ,101338 + ,391 + ,22938 + ,10 + ,154 + ,0 + ,0 + ,1168 + ,1605 + ,152474 + ,65 + ,577 + ,0 + ,123 + ,65567 + ,530 + ,61857 + ,25 + ,192 + ,4 + ,32 + ,25162 + ,1386 + ,132487 + ,41 + ,411 + ,0 + ,136 + ,40735 + ,2395 + ,317394 + ,86 + ,975 + ,1 + ,117 + ,91413 + ,387 + ,21054 + ,16 + ,146 + ,0 + ,0 + ,855 + ,1742 + ,209641 + ,42 + ,705 + ,5 + ,88 + ,97068 + ,449 + ,31414 + ,19 + ,200 + ,0 + ,25 + ,14116 + ,2699 + ,244749 + ,95 + ,964 + ,2 + ,124 + ,76643 + ,1606 + ,184510 + ,49 + ,537 + ,7 + ,151 + ,110681 + ,1204 + ,128423 + ,64 + ,369 + ,8 + ,145 + ,92696 + ,1138 + ,97839 + ,38 + ,417 + ,2 + ,87 + ,94785 + ,568 + ,38214 + ,34 + ,276 + ,0 + ,27 + ,8773 + ,1459 + ,151101 + ,32 + ,514 + ,2 + ,131 + ,83209 + ,2158 + ,272458 + ,65 + ,822 + ,0 + ,162 + ,93815 + ,1111 + ,172494 + ,52 + ,389 + ,0 + ,165 + ,86687 + ,2833 + ,328107 + ,65 + ,1255 + ,3 + ,159 + ,105547 + ,1955 + ,250579 + ,83 + ,694 + ,0 + ,147 + ,103487 + ,2922 + ,351067 + ,95 + ,1024 + ,3 + ,170 + ,213688 + ,1002 + ,158015 + ,29 + ,400 + ,0 + ,119 + ,71220 + ,956 + ,85439 + ,33 + ,350 + ,0 + ,104 + ,56926 + ,2186 + ,229242 + ,247 + ,719 + ,4 + ,120 + ,91721 + ,3604 + ,351619 + ,139 + ,1277 + ,4 + ,150 + ,115168 + ,1035 + ,84207 + ,29 + ,356 + ,11 + ,112 + ,111194 + ,3261 + ,324598 + ,110 + ,1402 + ,0 + ,136 + ,135777 + ,1587 + ,131069 + ,67 + ,600 + ,4 + ,107 + ,51513 + ,1424 + ,204271 + ,42 + ,480 + ,0 + ,130 + ,74163 + ,1701 + ,165543 + ,65 + ,595 + ,1 + ,115 + ,51633 + ,1249 + ,141722 + ,94 + ,436 + ,0 + ,107 + ,75345 + ,3352 + ,299775 + ,95 + ,1367 + ,9 + ,120 + ,98952 + ,1641 + ,195838 + ,67 + ,564 + ,1 + ,116 + ,102372 + ,2035 + ,173260 + ,63 + ,716 + ,3 + ,79 + ,37238 + ,2312 + ,254488 + ,83 + ,747 + ,10 + ,150 + ,103772 + ,1369 + ,104389 + ,45 + ,467 + ,5 + ,156 + ,123969 + ,2201 + ,199476 + ,70 + ,861 + ,2 + ,118 + ,135400 + ,1900 + ,224330 + ,83 + ,612 + ,1 + ,144 + ,130115 + ,207 + ,14688 + ,10 + ,85 + ,0 + ,0 + ,6023 + ,1645 + ,181633 + ,70 + ,564 + ,2 + ,110 + ,64466 + ,2429 + ,271856 + ,103 + ,824 + ,1 + ,147 + ,54990 + ,151 + ,7199 + ,5 + ,74 + ,0 + ,0 + ,1644 + ,474 + ,46660 + ,20 + ,259 + ,0 + ,15 + ,6179 + ,141 + ,17547 + ,5 + ,69 + ,0 + ,4 + ,3926 + ,872 + ,95227 + ,34 + ,239 + ,0 + ,111 + ,34777 + ,1318 + ,152601 + ,48 + ,438 + ,2 + ,85 + ,73224 + ,1192 + ,101645 + ,63 + ,371 + ,0 + ,44 + ,17140 + ,829 + ,101011 + ,34 + ,238 + ,0 + ,52 + ,27570 + ,186 + ,7176 + ,17 + ,70 + ,0 + ,0 + ,1423 + ,1793 + ,96560 + ,76 + ,503 + ,0 + ,54 + ,22996 + ,2702 + ,175824 + ,107 + ,910 + ,0 + ,80 + ,39992 + ,4691 + ,341570 + ,168 + ,1276 + ,1 + ,80 + ,117105 + ,1112 + ,103597 + ,43 + ,379 + ,1 + ,60 + ,23789 + ,937 + ,112611 + ,41 + ,248 + ,0 + ,78 + ,26706 + ,1290 + ,85574 + ,34 + ,351 + ,0 + ,78 + ,24266 + ,2146 + ,220801 + ,75 + ,720 + ,1 + ,72 + ,44418 + ,1590 + ,92661 + ,61 + ,508 + ,1 + ,45 + ,35232 + ,1590 + ,133328 + ,55 + ,506 + ,0 + ,78 + ,40909 + ,1210 + ,61361 + ,77 + ,451 + ,0 + ,39 + ,13294 + ,2072 + ,125930 + ,75 + ,699 + ,4 + ,68 + ,32387 + ,834 + ,82316 + ,32 + ,245 + ,4 + ,39 + ,21233 + ,1105 + ,102010 + ,53 + ,370 + ,3 + ,50 + ,44332 + ,1272 + ,101523 + ,42 + ,316 + ,0 + ,88 + ,61056 + ,761 + ,41566 + ,35 + ,229 + ,5 + ,36 + ,13497 + ,1988 + ,99923 + ,66 + ,617 + ,0 + ,99 + ,32334 + ,620 + ,22648 + ,19 + ,184 + ,0 + ,39 + ,44339 + ,800 + ,46698 + ,45 + ,274 + ,0 + ,52 + ,10288 + ,1684 + ,131698 + ,65 + ,502 + ,0 + ,75 + ,65622 + ,1050 + ,91735 + ,35 + ,382 + ,0 + ,71 + ,16563 + ,1502 + ,79863 + ,37 + ,438 + ,1 + ,71 + ,29011 + ,1421 + ,108043 + ,62 + ,466 + ,1 + ,54 + ,34553 + ,1060 + ,98866 + ,18 + ,397 + ,0 + ,49 + ,23517 + ,1417 + ,120445 + ,118 + ,457 + ,0 + ,59 + ,51009 + ,946 + ,116048 + ,64 + ,230 + ,0 + ,75 + ,33416 + ,1926 + ,250047 + ,81 + ,651 + ,0 + ,71 + ,83305 + ,1577 + ,136084 + ,30 + ,671 + ,0 + ,51 + ,27142 + ,961 + ,92499 + ,32 + ,319 + ,0 + ,71 + ,21399 + ,1254 + ,135781 + ,31 + ,433 + ,2 + ,47 + ,24874 + ,1335 + ,74408 + ,67 + ,434 + ,4 + ,28 + ,34988 + ,1597 + ,81240 + ,66 + ,503 + ,0 + ,68 + ,45549 + ,1639 + ,133368 + ,36 + ,535 + ,1 + ,64 + ,32755 + ,1018 + ,98146 + ,40 + ,459 + ,0 + ,68 + ,27114 + ,1383 + ,79619 + ,43 + ,426 + ,3 + ,40 + ,20760 + ,1314 + ,59194 + ,31 + ,288 + ,6 + ,80 + ,37636 + ,1335 + ,139942 + ,42 + ,498 + ,0 + ,88 + ,65461 + ,1403 + ,118612 + ,46 + ,454 + ,2 + ,48 + ,30080 + ,910 + ,72880 + ,33 + ,376 + ,0 + ,76 + ,24094) + ,dim=c(7 + ,197) + ,dimnames=list(c('pageviews' + ,'time_in_rfc' + ,'logins' + ,'compendium_views_info' + ,'shared_compendiums' + ,'feedback_messages_p1' + ,'totsize') + ,1:197)) > y <- array(NA,dim=c(7,197),dimnames=list(c('pageviews','time_in_rfc','logins','compendium_views_info','shared_compendiums','feedback_messages_p1','totsize'),1:197)) > 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] "time_in_rfc" > x[,par1] [1] 210907 120982 176508 179321 123185 52746 385534 33170 149061 165446 [11] 237213 173326 133131 258873 180083 324799 230964 236785 135473 202925 [21] 215147 344297 153935 132943 174724 174415 225548 223632 124817 221698 [31] 210767 170266 260561 84853 294424 215641 325107 167542 106408 265769 [41] 269651 149112 152871 111665 116408 362301 78800 183167 277965 150629 [51] 168809 24188 329267 65029 101097 218946 244052 233328 256462 206161 [61] 311473 235800 177939 207176 196553 174184 143246 187559 187681 119016 [71] 182192 73566 194979 167488 143756 275541 243199 182999 135649 152299 [81] 120221 346485 145790 193339 80953 122774 130585 286468 241066 148446 [91] 204713 182079 140344 220516 243060 162765 182613 232138 265318 310839 [101] 225060 232317 144966 43287 155754 164709 201940 235454 99466 100750 [111] 224549 243511 22938 152474 61857 132487 317394 21054 209641 31414 [121] 244749 184510 128423 97839 38214 151101 272458 172494 328107 250579 [131] 351067 158015 85439 229242 351619 84207 324598 131069 204271 165543 [141] 141722 299775 195838 173260 254488 104389 199476 224330 14688 181633 [151] 271856 7199 46660 17547 95227 152601 101645 101011 7176 96560 [161] 175824 341570 103597 112611 85574 220801 92661 133328 61361 125930 [171] 82316 102010 101523 41566 99923 22648 46698 131698 91735 79863 [181] 108043 98866 120445 116048 250047 136084 92499 135781 74408 81240 [191] 133368 98146 79619 59194 139942 118612 72880 > 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 21054 22648 22938 24188 31414 33170 38214 1 1 1 1 1 1 1 1 1 1 1 41566 43287 46660 46698 52746 59194 61361 61857 65029 72880 73566 1 1 1 1 1 1 1 1 1 1 1 74408 78800 79619 79863 80953 81240 82316 84207 84853 85439 85574 1 1 1 1 1 1 1 1 1 1 1 91735 92499 92661 95227 96560 97839 98146 98866 99466 99923 100750 1 1 1 1 1 1 1 1 1 1 1 101011 101097 101523 101645 102010 103597 104389 106408 108043 111665 112611 1 1 1 1 1 1 1 1 1 1 1 116048 116408 118612 119016 120221 120445 120982 122774 123185 124817 125930 1 1 1 1 1 1 1 1 1 1 1 128423 130585 131069 131698 132487 132943 133131 133328 133368 135473 135649 1 1 1 1 1 1 1 1 1 1 1 135781 136084 139942 140344 141722 143246 143756 144966 145790 148446 149061 1 1 1 1 1 1 1 1 1 1 1 149112 150629 151101 152299 152474 152601 152871 153935 155754 158015 162765 1 1 1 1 1 1 1 1 1 1 1 164709 165446 165543 167488 167542 168809 170266 172494 173260 173326 174184 1 1 1 1 1 1 1 1 1 1 1 174415 174724 175824 176508 177939 179321 180083 181633 182079 182192 182613 1 1 1 1 1 1 1 1 1 1 1 182999 183167 184510 187559 187681 193339 194979 195838 196553 199476 201940 1 1 1 1 1 1 1 1 1 1 1 202925 204271 204713 206161 207176 209641 210767 210907 215147 215641 218946 1 1 1 1 1 1 1 1 1 1 1 220516 220801 221698 223632 224330 224549 225060 225548 229242 230964 232138 1 1 1 1 1 1 1 1 1 1 1 232317 233328 235454 235800 236785 237213 241066 243060 243199 243511 244052 1 1 1 1 1 1 1 1 1 1 1 244749 250047 250579 254488 256462 258873 260561 265318 265769 269651 271856 1 1 1 1 1 1 1 1 1 1 1 272458 275541 277965 286468 294424 299775 310839 311473 317394 324598 324799 1 1 1 1 1 1 1 1 1 1 1 325107 328107 329267 341570 344297 346485 351067 351619 362301 385534 1 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "pageviews" "time_in_rfc" "logins" [4] "compendium_views_info" "shared_compendiums" "feedback_messages_p1" [7] "totsize" > colnames(x)[par1] [1] "time_in_rfc" > x[,par1] [1] 210907 120982 176508 179321 123185 52746 385534 33170 149061 165446 [11] 237213 173326 133131 258873 180083 324799 230964 236785 135473 202925 [21] 215147 344297 153935 132943 174724 174415 225548 223632 124817 221698 [31] 210767 170266 260561 84853 294424 215641 325107 167542 106408 265769 [41] 269651 149112 152871 111665 116408 362301 78800 183167 277965 150629 [51] 168809 24188 329267 65029 101097 218946 244052 233328 256462 206161 [61] 311473 235800 177939 207176 196553 174184 143246 187559 187681 119016 [71] 182192 73566 194979 167488 143756 275541 243199 182999 135649 152299 [81] 120221 346485 145790 193339 80953 122774 130585 286468 241066 148446 [91] 204713 182079 140344 220516 243060 162765 182613 232138 265318 310839 [101] 225060 232317 144966 43287 155754 164709 201940 235454 99466 100750 [111] 224549 243511 22938 152474 61857 132487 317394 21054 209641 31414 [121] 244749 184510 128423 97839 38214 151101 272458 172494 328107 250579 [131] 351067 158015 85439 229242 351619 84207 324598 131069 204271 165543 [141] 141722 299775 195838 173260 254488 104389 199476 224330 14688 181633 [151] 271856 7199 46660 17547 95227 152601 101645 101011 7176 96560 [161] 175824 341570 103597 112611 85574 220801 92661 133328 61361 125930 [171] 82316 102010 101523 41566 99923 22648 46698 131698 91735 79863 [181] 108043 98866 120445 116048 250047 136084 92499 135781 74408 81240 [191] 133368 98146 79619 59194 139942 118612 72880 > 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/14fh71354799176.tab") + } + } > m Conditional inference tree with 9 terminal nodes Response: time_in_rfc Inputs: pageviews, logins, compendium_views_info, shared_compendiums, feedback_messages_p1, totsize Number of observations: 197 1) pageviews <= 1605; criterion = 1, statistic = 148.734 2) pageviews <= 800; criterion = 1, statistic = 65.763 3)* weights = 18 2) pageviews > 800 4) feedback_messages_p1 <= 88; criterion = 1, statistic = 31.315 5) totsize <= 24266; criterion = 0.955, statistic = 7.119 6)* weights = 11 5) totsize > 24266 7)* weights = 28 4) feedback_messages_p1 > 88 8) pageviews <= 1054; criterion = 1, statistic = 16.456 9)* weights = 8 8) pageviews > 1054 10)* weights = 41 1) pageviews > 1605 11) compendium_views_info <= 967; criterion = 1, statistic = 43.487 12) feedback_messages_p1 <= 99; criterion = 1, statistic = 18.273 13)* weights = 15 12) feedback_messages_p1 > 99 14) logins <= 93; criterion = 0.96, statistic = 7.323 15)* weights = 46 14) logins > 93 16)* weights = 13 11) compendium_views_info > 967 17)* weights = 17 > postscript(file="/var/fisher/rcomp/tmp/2dswa1354799176.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/3rph31354799176.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 210907 156134.44 54772.56098 2 120982 107346.75 13635.25000 3 176508 156134.44 20373.56098 4 179321 217099.57 -37778.56522 5 123185 108090.82 15094.17857 6 52746 33226.61 19519.38889 7 385534 322592.29 62941.70588 8 33170 33226.61 -56.61111 9 149061 156134.44 -7073.43902 10 165446 156134.44 9311.56098 11 237213 217099.57 20113.43478 12 173326 156134.44 17191.56098 13 133131 156134.44 -23003.43902 14 258873 217099.57 41773.43478 15 180083 156134.44 23948.56098 16 324799 322592.29 2206.70588 17 230964 217099.57 13864.43478 18 236785 249646.54 -12861.53846 19 135473 108090.82 27382.17857 20 202925 217099.57 -14174.56522 21 215147 217099.57 -1952.56522 22 344297 217099.57 127197.43478 23 153935 156134.44 -2199.43902 24 132943 156134.44 -23191.43902 25 174724 217099.57 -42375.56522 26 174415 249646.54 -75231.53846 27 225548 249646.54 -24098.53846 28 223632 217099.57 6532.43478 29 124817 156134.44 -31317.43902 30 221698 217099.57 4598.43478 31 210767 217099.57 -6332.56522 32 170266 156134.44 14131.56098 33 260561 217099.57 43461.43478 34 84853 107346.75 -22493.75000 35 294424 322592.29 -28168.29412 36 215641 217099.57 -1458.56522 37 325107 249646.54 75460.46154 38 167542 156134.44 11407.56098 39 106408 108090.82 -1682.82143 40 265769 249646.54 16122.46154 41 269651 322592.29 -52941.29412 42 149112 156134.44 -7022.43902 43 152871 156134.44 -3263.43902 44 111665 156134.44 -44469.43902 45 116408 162741.80 -46333.80000 46 362301 322592.29 39708.70588 47 78800 108090.82 -29290.82143 48 183167 217099.57 -33932.56522 49 277965 322592.29 -44627.29412 50 150629 217099.57 -66470.56522 51 168809 156134.44 12674.56098 52 24188 33226.61 -9038.61111 53 329267 249646.54 79620.46154 54 65029 33226.61 31802.38889 55 101097 108090.82 -6993.82143 56 218946 217099.57 1846.43478 57 244052 217099.57 26952.43478 58 233328 249646.54 -16318.53846 59 256462 249646.54 6815.46154 60 206161 217099.57 -10938.56522 61 311473 322592.29 -11119.29412 62 235800 162741.80 73058.20000 63 177939 217099.57 -39160.56522 64 207176 217099.57 -9923.56522 65 196553 156134.44 40418.56098 66 174184 156134.44 18049.56098 67 143246 156134.44 -12888.43902 68 187559 249646.54 -62087.53846 69 187681 217099.57 -29418.56522 70 119016 108090.82 10925.17857 71 182192 217099.57 -34907.56522 72 73566 85787.09 -12221.09091 73 194979 217099.57 -22120.56522 74 167488 156134.44 11353.56098 75 143756 156134.44 -12378.43902 76 275541 217099.57 58441.43478 77 243199 217099.57 26099.43478 78 182999 156134.44 26864.56098 79 135649 156134.44 -20485.43902 80 152299 156134.44 -3835.43902 81 120221 108090.82 12130.17857 82 346485 322592.29 23892.70588 83 145790 156134.44 -10344.43902 84 193339 162741.80 30597.20000 85 80953 108090.82 -27137.82143 86 122774 162741.80 -39967.80000 87 130585 107346.75 23238.25000 88 286468 322592.29 -36124.29412 89 241066 217099.57 23966.43478 90 148446 217099.57 -68653.56522 91 204713 217099.57 -12386.56522 92 182079 217099.57 -35020.56522 93 140344 156134.44 -15790.43902 94 220516 217099.57 3416.43478 95 243060 217099.57 25960.43478 96 162765 156134.44 6630.56098 97 182613 156134.44 26478.56098 98 232138 217099.57 15038.43478 99 265318 249646.54 15671.46154 100 310839 322592.29 -11753.29412 101 225060 217099.57 7960.43478 102 232317 217099.57 15217.43478 103 144966 156134.44 -11168.43902 104 43287 33226.61 10060.38889 105 155754 162741.80 -6987.80000 106 164709 156134.44 8574.56098 107 201940 217099.57 -15159.56522 108 235454 217099.57 18354.43478 109 99466 107346.75 -7880.75000 110 100750 156134.44 -55384.43902 111 224549 156134.44 68414.56098 112 243511 217099.57 26411.43478 113 22938 33226.61 -10288.61111 114 152474 156134.44 -3660.43902 115 61857 33226.61 28630.38889 116 132487 156134.44 -23647.43902 117 317394 322592.29 -5198.29412 118 21054 33226.61 -12172.61111 119 209641 162741.80 46899.20000 120 31414 33226.61 -1812.61111 121 244749 249646.54 -4897.53846 122 184510 217099.57 -32589.56522 123 128423 156134.44 -27711.43902 124 97839 108090.82 -10251.82143 125 38214 33226.61 4987.38889 126 151101 156134.44 -5033.43902 127 272458 217099.57 55358.43478 128 172494 156134.44 16359.56098 129 328107 322592.29 5514.70588 130 250579 217099.57 33479.43478 131 351067 322592.29 28474.70588 132 158015 107346.75 50668.25000 133 85439 107346.75 -21907.75000 134 229242 249646.54 -20404.53846 135 351619 322592.29 29026.70588 136 84207 107346.75 -23139.75000 137 324598 322592.29 2005.70588 138 131069 156134.44 -25065.43902 139 204271 156134.44 48136.56098 140 165543 217099.57 -51556.56522 141 141722 156134.44 -14412.43902 142 299775 322592.29 -22817.29412 143 195838 217099.57 -21261.56522 144 173260 162741.80 10518.20000 145 254488 217099.57 37388.43478 146 104389 156134.44 -51745.43902 147 199476 217099.57 -17623.56522 148 224330 217099.57 7230.43478 149 14688 33226.61 -18538.61111 150 181633 217099.57 -35466.56522 151 271856 249646.54 22209.46154 152 7199 33226.61 -26027.61111 153 46660 33226.61 13433.38889 154 17547 33226.61 -15679.61111 155 95227 107346.75 -12119.75000 156 152601 108090.82 44510.17857 157 101645 85787.09 15857.90909 158 101011 108090.82 -7079.82143 159 7176 33226.61 -26050.61111 160 96560 162741.80 -66181.80000 161 175824 162741.80 13082.20000 162 341570 322592.29 18977.70588 163 103597 85787.09 17809.90909 164 112611 108090.82 4520.17857 165 85574 85787.09 -213.09091 166 220801 162741.80 58059.20000 167 92661 108090.82 -15429.82143 168 133328 108090.82 25237.17857 169 61361 85787.09 -24426.09091 170 125930 162741.80 -36811.80000 171 82316 85787.09 -3471.09091 172 102010 108090.82 -6080.82143 173 101523 108090.82 -6567.82143 174 41566 33226.61 8339.38889 175 99923 162741.80 -62818.80000 176 22648 33226.61 -10578.61111 177 46698 33226.61 13471.38889 178 131698 162741.80 -31043.80000 179 91735 85787.09 5947.90909 180 79863 108090.82 -28227.82143 181 108043 108090.82 -47.82143 182 98866 85787.09 13078.90909 183 120445 108090.82 12354.17857 184 116048 108090.82 7957.17857 185 250047 162741.80 87305.20000 186 136084 108090.82 27993.17857 187 92499 85787.09 6711.90909 188 135781 108090.82 27690.17857 189 74408 108090.82 -33682.82143 190 81240 108090.82 -26850.82143 191 133368 162741.80 -29373.80000 192 98146 108090.82 -9944.82143 193 79619 85787.09 -6168.09091 194 59194 108090.82 -48896.82143 195 139942 108090.82 31851.17857 196 118612 108090.82 10521.17857 197 72880 85787.09 -12907.09091 > 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/4che01354799176.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/5wzi41354799176.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/663f91354799176.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/7zfke1354799176.tab") + } > > try(system("convert tmp/2dswa1354799176.ps tmp/2dswa1354799176.png",intern=TRUE)) character(0) > try(system("convert tmp/3rph31354799176.ps tmp/3rph31354799176.png",intern=TRUE)) character(0) > try(system("convert tmp/4che01354799176.ps tmp/4che01354799176.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.955 0.633 6.570