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(210907 + ,1 + ,1 + ,24188 + ,145 + ,120982 + ,1 + ,1 + ,18273 + ,101 + ,176508 + ,1 + ,1 + ,14130 + ,98 + ,179321 + ,1 + ,0 + ,32287 + ,132 + ,123185 + ,1 + ,1 + ,8654 + ,60 + ,52746 + ,1 + ,1 + ,9245 + ,38 + ,385534 + ,1 + ,1 + ,33251 + ,144 + ,33170 + ,1 + ,1 + ,1271 + ,5 + ,101645 + ,1 + ,1 + ,5279 + ,28 + ,149061 + ,1 + ,1 + ,27101 + ,84 + ,165446 + ,1 + ,0 + ,16373 + ,79 + ,237213 + ,1 + ,1 + ,19716 + ,127 + ,173326 + ,1 + ,0 + ,17753 + ,78 + ,133131 + ,1 + ,1 + ,9028 + ,60 + ,258873 + ,1 + ,1 + ,18653 + ,131 + ,180083 + ,1 + ,0 + ,8828 + ,84 + ,324799 + ,1 + ,0 + ,29498 + ,133 + ,230964 + ,1 + ,1 + ,27563 + ,150 + ,236785 + ,1 + ,0 + ,18293 + ,91 + ,135473 + ,1 + ,1 + ,22530 + ,132 + ,202925 + ,1 + ,0 + ,15977 + ,136 + ,215147 + ,1 + ,1 + ,35082 + ,124 + ,344297 + ,1 + ,1 + ,16116 + ,118 + ,153935 + ,1 + ,1 + ,15849 + ,70 + ,132943 + ,1 + ,0 + ,16026 + ,107 + ,174724 + ,1 + ,1 + ,26569 + ,119 + ,174415 + ,1 + ,0 + ,24785 + ,89 + ,225548 + ,1 + ,1 + ,17569 + ,112 + ,223632 + ,1 + ,1 + ,23825 + ,108 + ,124817 + ,1 + ,0 + ,7869 + ,52 + ,221698 + ,1 + ,1 + ,14975 + ,112 + ,210767 + ,1 + ,0 + ,37791 + ,116 + ,170266 + ,1 + ,1 + ,9605 + ,123 + ,260561 + ,1 + ,1 + ,27295 + ,125 + ,84853 + ,1 + ,0 + ,2746 + ,27 + ,294424 + ,1 + ,0 + ,34461 + ,162 + ,101011 + ,1 + ,0 + ,8098 + ,32 + ,215641 + ,1 + ,0 + ,4787 + ,64 + ,325107 + ,1 + ,1 + ,24919 + ,92 + ,7176 + ,1 + ,0 + ,603 + ,0 + ,167542 + ,1 + ,0 + ,16329 + ,83 + ,106408 + ,1 + ,1 + ,12558 + ,41 + ,96560 + ,1 + ,0 + ,7784 + ,47 + ,265769 + ,1 + ,0 + ,28522 + ,120 + ,269651 + ,1 + ,1 + ,22265 + ,105 + ,149112 + ,1 + ,1 + ,14459 + ,79 + ,175824 + ,1 + ,1 + ,14526 + ,65 + ,152871 + ,1 + ,1 + ,22240 + ,70 + ,111665 + ,1 + ,1 + ,11802 + ,55 + ,116408 + ,1 + ,0 + ,7623 + ,39 + ,362301 + ,1 + ,1 + ,11912 + ,67 + ,78800 + ,1 + ,0 + ,7935 + ,21 + ,183167 + ,1 + ,0 + ,18220 + ,127 + ,277965 + ,1 + ,1 + ,19199 + ,152 + ,150629 + ,1 + ,0 + ,19918 + ,113 + ,168809 + ,1 + ,1 + ,21884 + ,99 + ,24188 + ,1 + ,1 + ,2694 + ,7 + ,329267 + ,1 + ,1 + ,15808 + ,141 + ,65029 + ,1 + ,0 + ,3597 + ,21 + ,101097 + ,1 + ,1 + ,5296 + ,35 + ,218946 + ,1 + ,0 + ,25239 + ,109 + ,244052 + ,1 + ,0 + ,29801 + ,133 + ,341570 + ,1 + ,1 + ,18450 + ,123 + ,103597 + ,1 + ,1 + ,7132 + ,26 + ,233328 + ,1 + ,1 + ,34861 + ,230 + ,256462 + ,1 + ,0 + ,35940 + ,166 + ,206161 + ,1 + ,1 + ,16688 + ,68 + ,311473 + ,1 + ,0 + ,24683 + ,147 + ,235800 + ,1 + ,1 + ,46230 + ,179 + ,177939 + ,1 + ,0 + ,10387 + ,61 + ,207176 + ,1 + ,0 + ,21436 + ,101 + ,196553 + ,1 + ,1 + ,30546 + ,108 + ,174184 + ,1 + ,1 + ,19746 + ,90 + ,143246 + ,1 + ,0 + ,15977 + ,114 + ,187559 + ,1 + ,0 + ,22583 + ,103 + ,187681 + ,1 + ,1 + ,17274 + ,142 + ,119016 + ,1 + ,1 + ,16469 + ,79 + ,182192 + ,1 + ,1 + ,14251 + ,88 + ,73566 + ,1 + ,0 + ,3007 + ,25 + ,194979 + ,1 + ,0 + ,16851 + ,83 + ,167488 + ,1 + ,0 + ,21113 + ,113 + ,143756 + ,1 + ,1 + ,17401 + ,118 + ,275541 + ,1 + ,0 + ,23958 + ,110 + ,243199 + ,1 + ,1 + ,23567 + ,129 + ,182999 + ,1 + ,1 + ,13065 + ,51 + ,135649 + ,1 + ,0 + ,15358 + ,93 + ,152299 + ,1 + ,1 + ,14587 + ,76 + ,120221 + ,1 + ,1 + ,12770 + ,49 + ,346485 + ,1 + ,1 + ,24021 + ,118 + ,145790 + ,1 + ,1 + ,9648 + ,38 + ,193339 + ,1 + ,1 + ,20537 + ,141 + ,80953 + ,1 + ,1 + ,7905 + ,58 + ,122774 + ,1 + ,1 + ,4527 + ,27 + ,130585 + ,1 + ,1 + ,30495 + ,91 + ,112611 + ,1 + ,1 + ,7117 + ,48 + ,286468 + ,1 + ,1 + ,17719 + ,63 + ,241066 + ,1 + ,1 + ,27056 + ,56 + ,148446 + ,1 + ,0 + ,33473 + ,144 + ,204713 + ,1 + ,0 + ,9758 + ,73 + ,182079 + ,1 + ,1 + ,21115 + ,168 + ,140344 + ,1 + ,0 + ,7236 + ,64 + ,220516 + ,1 + ,1 + ,13790 + ,97 + ,243060 + ,1 + ,0 + ,32902 + ,117 + ,162765 + ,1 + ,1 + ,25131 + ,100 + ,182613 + ,1 + ,0 + ,30910 + ,149 + ,232138 + ,1 + ,1 + ,35947 + ,187 + ,265318 + ,1 + ,0 + ,29848 + ,127 + ,85574 + ,1 + ,0 + ,6943 + ,37 + ,310839 + ,1 + ,1 + ,42705 + ,245 + ,225060 + ,1 + ,1 + ,31808 + ,87 + ,232317 + ,1 + ,1 + ,26675 + ,177 + ,144966 + ,1 + ,1 + ,8435 + ,49 + ,43287 + ,1 + ,1 + ,7409 + ,49 + ,155754 + ,1 + ,0 + ,14993 + ,73 + ,164709 + ,1 + ,1 + ,36867 + ,177 + ,201940 + ,1 + ,1 + ,33835 + ,94 + ,235454 + ,1 + ,1 + ,24164 + ,117 + ,220801 + ,1 + ,1 + ,12607 + ,60 + ,99466 + ,1 + ,0 + ,22609 + ,55 + ,92661 + ,1 + ,1 + ,5892 + ,39 + ,133328 + ,1 + ,1 + ,17014 + ,64 + ,61361 + ,1 + ,1 + ,5394 + ,26 + ,125930 + ,1 + ,1 + ,9178 + ,64 + ,100750 + ,1 + ,1 + ,6440 + ,58 + ,224549 + ,1 + ,0 + ,21916 + ,95 + ,82316 + ,1 + ,1 + ,4011 + ,25 + ,102010 + ,1 + ,1 + ,5818 + ,26 + ,101523 + ,1 + ,1 + ,18647 + ,76 + ,243511 + ,1 + ,0 + ,20556 + ,129 + ,22938 + ,1 + ,0 + ,238 + ,11 + ,41566 + ,1 + ,1 + ,70 + ,2 + ,152474 + ,1 + ,0 + ,22392 + ,101 + ,61857 + ,1 + ,0 + ,3913 + ,28 + ,99923 + ,1 + ,1 + ,12237 + ,36 + ,132487 + ,1 + ,0 + ,8388 + ,89 + ,317394 + ,1 + ,0 + ,22120 + ,193 + ,21054 + ,1 + ,1 + ,338 + ,4 + ,209641 + ,1 + ,1 + ,11727 + ,84 + ,22648 + ,1 + ,0 + ,3704 + ,23 + ,31414 + ,1 + ,1 + ,3988 + ,39 + ,46698 + ,1 + ,0 + ,3030 + ,14 + ,131698 + ,1 + ,1 + ,13520 + ,78 + ,91735 + ,1 + ,0 + ,1421 + ,14 + ,244749 + ,1 + ,1 + ,20923 + ,101 + ,184510 + ,1 + ,1 + ,20237 + ,82 + ,79863 + ,1 + ,0 + ,3219 + ,24 + ,128423 + ,1 + ,0 + ,3769 + ,36 + ,97839 + ,1 + ,0 + ,12252 + ,75 + ,38214 + ,1 + ,1 + ,1888 + ,16 + ,151101 + ,1 + ,1 + ,14497 + ,55 + ,272458 + ,1 + ,0 + ,28864 + ,131 + ,172494 + ,1 + ,1 + ,21721 + ,131 + ,108043 + ,1 + ,1 + ,4821 + ,39 + ,328107 + ,1 + ,1 + ,33644 + ,144 + ,250579 + ,1 + ,1 + ,15923 + ,139 + ,351067 + ,1 + ,1 + ,42935 + ,211 + ,158015 + ,1 + ,1 + ,18864 + ,78 + ,98866 + ,1 + ,1 + ,4977 + ,50 + ,85439 + ,0 + ,0 + ,7785 + ,39 + ,229242 + ,0 + ,0 + ,17939 + ,90 + ,351619 + ,0 + ,0 + ,23436 + ,166 + ,84207 + ,0 + ,1 + ,325 + ,12 + ,120445 + ,0 + ,0 + ,13539 + ,57 + ,324598 + ,0 + ,0 + ,34538 + ,133 + ,131069 + ,0 + ,1 + ,12198 + ,69 + ,204271 + ,0 + ,1 + ,26924 + ,119 + ,165543 + ,0 + ,0 + ,12716 + ,119 + ,141722 + ,0 + ,0 + ,8172 + ,65 + ,116048 + ,0 + ,1 + ,10855 + ,61 + ,250047 + ,0 + ,0 + ,11932 + ,49 + ,299775 + ,0 + ,1 + ,14300 + ,101 + ,195838 + ,0 + ,1 + ,25515 + ,196 + ,173260 + ,0 + ,0 + ,2805 + ,15 + ,254488 + ,0 + ,1 + ,29402 + ,136 + ,104389 + ,0 + ,0 + ,16440 + ,89 + ,136084 + ,0 + ,1 + ,11221 + ,40 + ,199476 + ,0 + ,1 + ,28732 + ,123 + ,92499 + ,0 + ,1 + ,5250 + ,21 + ,224330 + ,0 + ,0 + ,28608 + ,163 + ,135781 + ,0 + ,0 + ,8092 + ,29 + ,74408 + ,0 + ,0 + ,4473 + ,35 + ,81240 + ,0 + ,1 + ,1572 + ,13 + ,14688 + ,0 + ,1 + ,2065 + ,5 + ,181633 + ,0 + ,0 + ,14817 + ,96 + ,271856 + ,0 + ,1 + ,16714 + ,151 + ,7199 + ,0 + ,0 + ,556 + ,6 + ,46660 + ,0 + ,0 + ,2089 + ,13 + ,17547 + ,0 + ,1 + ,2658 + ,3 + ,133368 + ,0 + ,1 + ,10695 + ,56 + ,95227 + ,0 + ,1 + ,1669 + ,23 + ,152601 + ,0 + ,1 + ,16267 + ,57 + ,98146 + ,0 + ,1 + ,7768 + ,14 + ,79619 + ,0 + ,0 + ,7252 + ,43 + ,59194 + ,0 + ,1 + ,6387 + ,20 + ,139942 + ,0 + ,1 + ,18715 + ,72 + ,118612 + ,0 + ,0 + ,7936 + ,87 + ,72880 + ,0 + ,0 + ,8643 + ,21 + ,65475 + ,0 + ,0 + ,7294 + ,56 + ,99643 + ,0 + ,0 + ,4570 + ,59 + ,71965 + ,0 + ,0 + ,7185 + ,82 + ,77272 + ,0 + ,1 + ,10058 + ,43 + ,49289 + ,0 + ,1 + ,2342 + ,25 + ,135131 + ,0 + ,1 + ,8509 + ,38 + ,108446 + ,0 + ,0 + ,13275 + ,25 + ,89746 + ,0 + ,0 + ,6816 + ,38 + ,44296 + ,0 + ,0 + ,1930 + ,12 + ,77648 + ,0 + ,1 + ,8086 + ,29 + ,181528 + ,0 + ,0 + ,10737 + ,47 + ,134019 + ,0 + ,0 + ,8033 + ,45 + ,124064 + ,0 + ,0 + ,7058 + ,40 + ,92630 + ,0 + ,1 + ,6782 + ,30 + ,121848 + ,0 + ,0 + ,5401 + ,41 + ,52915 + ,0 + ,1 + ,6521 + ,25 + ,81872 + ,0 + ,1 + ,10856 + ,23 + ,58981 + ,0 + ,0 + ,2154 + ,14 + ,53515 + ,0 + ,1 + ,6117 + ,16 + ,60812 + ,0 + ,0 + ,5238 + ,26 + ,56375 + ,0 + ,0 + ,4820 + ,21 + ,65490 + ,0 + ,1 + ,5615 + ,27 + ,80949 + ,0 + ,0 + ,4272 + ,9 + ,76302 + ,0 + ,1 + ,8702 + ,33 + ,104011 + ,0 + ,0 + ,15340 + ,42 + ,98104 + ,0 + ,0 + ,8030 + ,68 + ,67989 + ,0 + ,0 + ,9526 + ,32 + ,30989 + ,0 + ,0 + ,1278 + ,6 + ,135458 + ,0 + ,1 + ,4236 + ,67 + ,73504 + ,0 + ,0 + ,3023 + ,33 + ,63123 + ,0 + ,0 + ,7196 + ,77 + ,61254 + ,0 + ,1 + ,3394 + ,46 + ,74914 + ,0 + ,1 + ,6371 + ,30 + ,31774 + ,0 + ,0 + ,1574 + ,0 + ,81437 + ,0 + ,0 + ,9620 + ,36 + ,87186 + ,0 + ,0 + ,6978 + ,46 + ,50090 + ,0 + ,1 + ,4911 + ,18 + ,65745 + ,0 + ,0 + ,8645 + ,48 + ,56653 + ,0 + ,0 + ,8987 + ,29 + ,158399 + ,0 + ,0 + ,5544 + ,28 + ,46455 + ,0 + ,0 + ,3083 + ,34 + ,73624 + ,0 + ,0 + ,6909 + ,33 + ,38395 + ,0 + ,0 + ,3189 + ,34 + ,91899 + ,0 + ,0 + ,6745 + ,33 + ,139526 + ,0 + ,1 + ,16724 + ,80 + ,52164 + ,0 + ,1 + ,4850 + ,32 + ,51567 + ,0 + ,1 + ,7025 + ,30 + ,70551 + ,0 + ,0 + ,6047 + ,41 + ,84856 + ,0 + ,0 + ,7377 + ,41 + ,102538 + ,0 + ,1 + ,9078 + ,51 + ,86678 + ,0 + ,1 + ,4605 + ,18 + ,85709 + ,0 + ,0 + ,3238 + ,34 + ,34662 + ,0 + ,0 + ,8100 + ,31 + ,150580 + ,0 + ,0 + ,9653 + ,39 + ,99611 + ,0 + ,1 + ,8914 + ,54 + ,19349 + ,0 + ,1 + ,786 + ,14 + ,99373 + ,0 + ,1 + ,6700 + ,24 + ,86230 + ,0 + ,1 + ,5788 + ,24 + ,30837 + ,0 + ,0 + ,593 + ,8 + ,31706 + ,0 + ,0 + ,4506 + ,26 + ,89806 + ,0 + ,0 + ,6382 + ,19 + ,62088 + ,0 + ,0 + ,5621 + ,11 + ,40151 + ,0 + ,1 + ,3997 + ,14 + ,27634 + ,0 + ,0 + ,520 + ,1 + ,76990 + ,0 + ,0 + ,8891 + ,39 + ,37460 + ,0 + ,1 + ,999 + ,5 + ,54157 + ,0 + ,0 + ,7067 + ,37 + ,49862 + ,0 + ,0 + ,4639 + ,32 + ,84337 + ,0 + ,1 + ,5654 + ,38 + ,64175 + ,0 + ,1 + ,6928 + ,47 + ,59382 + ,0 + ,0 + ,1514 + ,47 + ,119308 + ,0 + ,1 + ,9238 + ,37 + ,76702 + ,0 + ,0 + ,8204 + ,51 + ,103425 + ,0 + ,0 + ,5926 + ,45 + ,70344 + ,0 + ,1 + ,5785 + ,21 + ,43410 + ,0 + ,0 + ,4 + ,1 + ,104838 + ,0 + ,1 + ,5930 + ,42 + ,62215 + ,0 + ,0 + ,3710 + ,26 + ,69304 + ,0 + ,0 + ,705 + ,21 + ,53117 + ,0 + ,0 + ,443 + ,4 + ,19764 + ,0 + ,0 + ,2416 + ,10 + ,86680 + ,0 + ,1 + ,7747 + ,43 + ,84105 + ,0 + ,0 + ,5432 + ,34 + ,77945 + ,0 + ,0 + ,4913 + ,31 + ,89113 + ,0 + ,1 + ,2650 + ,19 + ,91005 + ,0 + ,0 + ,2370 + ,34 + ,40248 + ,0 + ,1 + ,775 + ,6 + ,64187 + ,0 + ,0 + ,5576 + ,11 + ,50857 + ,0 + ,0 + ,1352 + ,24 + ,56613 + ,0 + ,1 + ,3080 + ,16 + ,62792 + ,0 + ,1 + ,10205 + ,72) + ,dim=c(5 + ,288) + ,dimnames=list(c('time' + ,'pop' + ,'gender' + ,'reviews' + ,'blogs') + ,1:288)) > y <- array(NA,dim=c(5,288),dimnames=list(c('time','pop','gender','reviews','blogs'),1:288)) > 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 = '5' > 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] "blogs" > x[,par1] [1] 145 101 98 132 60 38 144 5 28 84 79 127 78 60 131 84 133 150 [19] 91 132 136 124 118 70 107 119 89 112 108 52 112 116 123 125 27 162 [37] 32 64 92 0 83 41 47 120 105 79 65 70 55 39 67 21 127 152 [55] 113 99 7 141 21 35 109 133 123 26 230 166 68 147 179 61 101 108 [73] 90 114 103 142 79 88 25 83 113 118 110 129 51 93 76 49 118 38 [91] 141 58 27 91 48 63 56 144 73 168 64 97 117 100 149 187 127 37 [109] 245 87 177 49 49 73 177 94 117 60 55 39 64 26 64 58 95 25 [127] 26 76 129 11 2 101 28 36 89 193 4 84 23 39 14 78 14 101 [145] 82 24 36 75 16 55 131 131 39 144 139 211 78 50 39 90 166 12 [163] 57 133 69 119 119 65 61 49 101 196 15 136 89 40 123 21 163 29 [181] 35 13 5 96 151 6 13 3 56 23 57 14 43 20 72 87 21 56 [199] 59 82 43 25 38 25 38 12 29 47 45 40 30 41 25 23 14 16 [217] 26 21 27 9 33 42 68 32 6 67 33 77 46 30 0 36 46 18 [235] 48 29 28 34 33 34 33 80 32 30 41 41 51 18 34 31 39 54 [253] 14 24 24 8 26 19 11 14 1 39 5 37 32 38 47 47 37 51 [271] 45 21 1 42 26 21 4 10 43 34 31 19 34 6 11 24 16 72 > 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]) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 2 2 1 1 2 3 3 1 1 1 1 3 2 2 6 1 3 2 2 1 21 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 7 3 4 5 6 3 3 3 3 2 4 4 5 2 3 3 5 7 2 4 42 43 45 46 47 48 49 50 51 52 54 55 56 57 58 59 60 61 63 64 2 3 2 2 4 2 4 1 3 1 1 3 3 2 2 1 3 2 1 4 65 67 68 69 70 72 73 75 76 77 78 79 80 82 83 84 87 88 89 90 2 2 2 1 2 2 2 1 2 1 3 3 1 2 2 3 2 1 3 2 91 92 93 94 95 96 97 98 99 100 101 103 105 107 108 109 110 112 113 114 2 1 1 1 1 1 1 1 1 1 5 1 1 1 2 1 1 2 2 1 116 117 118 119 120 123 124 125 127 129 131 132 133 136 139 141 142 144 145 147 1 2 3 3 1 3 1 1 3 2 3 2 3 2 1 2 1 3 1 1 149 150 151 152 162 163 166 168 177 179 187 193 196 211 230 245 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 > colnames(x) [1] "time" "pop" "gender" "reviews" "blogs" > colnames(x)[par1] [1] "blogs" > x[,par1] [1] 145 101 98 132 60 38 144 5 28 84 79 127 78 60 131 84 133 150 [19] 91 132 136 124 118 70 107 119 89 112 108 52 112 116 123 125 27 162 [37] 32 64 92 0 83 41 47 120 105 79 65 70 55 39 67 21 127 152 [55] 113 99 7 141 21 35 109 133 123 26 230 166 68 147 179 61 101 108 [73] 90 114 103 142 79 88 25 83 113 118 110 129 51 93 76 49 118 38 [91] 141 58 27 91 48 63 56 144 73 168 64 97 117 100 149 187 127 37 [109] 245 87 177 49 49 73 177 94 117 60 55 39 64 26 64 58 95 25 [127] 26 76 129 11 2 101 28 36 89 193 4 84 23 39 14 78 14 101 [145] 82 24 36 75 16 55 131 131 39 144 139 211 78 50 39 90 166 12 [163] 57 133 69 119 119 65 61 49 101 196 15 136 89 40 123 21 163 29 [181] 35 13 5 96 151 6 13 3 56 23 57 14 43 20 72 87 21 56 [199] 59 82 43 25 38 25 38 12 29 47 45 40 30 41 25 23 14 16 [217] 26 21 27 9 33 42 68 32 6 67 33 77 46 30 0 36 46 18 [235] 48 29 28 34 33 34 33 80 32 30 41 41 51 18 34 31 39 54 [253] 14 24 24 8 26 19 11 14 1 39 5 37 32 38 47 47 37 51 [271] 45 21 1 42 26 21 4 10 43 34 31 19 34 6 11 24 16 72 > 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/1rvyw1354891484.tab") + } + } > m Conditional inference tree with 10 terminal nodes Response: blogs Inputs: time, pop, gender, reviews Number of observations: 288 1) reviews <= 13539; criterion = 1, statistic = 220.105 2) reviews <= 6909; criterion = 1, statistic = 80.021 3) time <= 59194; criterion = 1, statistic = 37.457 4) reviews <= 3080; criterion = 1, statistic = 17.653 5)* weights = 27 4) reviews > 3080 6)* weights = 13 3) time > 59194 7) time <= 95227; criterion = 0.974, statistic = 7.4 8)* weights = 40 7) time > 95227 9)* weights = 17 2) reviews > 6909 10) time <= 150580; criterion = 0.998, statistic = 11.949 11)* weights = 66 10) time > 150580 12)* weights = 11 1) reviews > 13539 13) reviews <= 33835; criterion = 1, statistic = 40.693 14) time <= 176508; criterion = 1, statistic = 25.268 15) reviews <= 19746; criterion = 0.989, statistic = 8.878 16)* weights = 25 15) reviews > 19746 17)* weights = 14 14) time > 176508 18)* weights = 64 13) reviews > 33835 19)* weights = 11 > postscript(file="/var/fisher/rcomp/tmp/2a77b1354891484.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/39h8b1354891484.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 145 122.046875 22.95312500 2 101 80.640000 20.36000000 3 98 80.640000 17.36000000 4 132 122.046875 9.95312500 5 60 47.090909 12.90909091 6 38 47.090909 -9.09090909 7 144 122.046875 21.95312500 8 5 8.592593 -3.59259259 9 28 40.235294 -12.23529412 10 84 102.928571 -18.92857143 11 79 80.640000 -1.64000000 12 127 122.046875 4.95312500 13 78 80.640000 -2.64000000 14 60 47.090909 12.90909091 15 131 122.046875 8.95312500 16 84 74.363636 9.63636364 17 133 122.046875 10.95312500 18 150 122.046875 27.95312500 19 91 122.046875 -31.04687500 20 132 102.928571 29.07142857 21 136 122.046875 13.95312500 22 124 175.454545 -51.45454545 23 118 122.046875 -4.04687500 24 70 80.640000 -10.64000000 25 107 80.640000 26.36000000 26 119 102.928571 16.07142857 27 89 102.928571 -13.92857143 28 112 122.046875 -10.04687500 29 108 122.046875 -14.04687500 30 52 47.090909 4.90909091 31 112 122.046875 -10.04687500 32 116 175.454545 -59.45454545 33 123 74.363636 48.63636364 34 125 122.046875 2.95312500 35 27 26.675000 0.32500000 36 162 175.454545 -13.45454545 37 32 47.090909 -15.09090909 38 64 40.235294 23.76470588 39 92 122.046875 -30.04687500 40 0 8.592593 -8.59259259 41 83 80.640000 2.36000000 42 41 47.090909 -6.09090909 43 47 47.090909 -0.09090909 44 120 122.046875 -2.04687500 45 105 122.046875 -17.04687500 46 79 80.640000 -1.64000000 47 65 80.640000 -15.64000000 48 70 102.928571 -32.92857143 49 55 47.090909 7.90909091 50 39 47.090909 -8.09090909 51 67 74.363636 -7.36363636 52 21 47.090909 -26.09090909 53 127 122.046875 4.95312500 54 152 122.046875 29.95312500 55 113 102.928571 10.07142857 56 99 102.928571 -3.92857143 57 7 8.592593 -1.59259259 58 141 122.046875 18.95312500 59 21 26.675000 -5.67500000 60 35 40.235294 -5.23529412 61 109 122.046875 -13.04687500 62 133 122.046875 10.95312500 63 123 122.046875 0.95312500 64 26 47.090909 -21.09090909 65 230 175.454545 54.54545455 66 166 175.454545 -9.45454545 67 68 122.046875 -54.04687500 68 147 122.046875 24.95312500 69 179 175.454545 3.54545455 70 61 74.363636 -13.36363636 71 101 122.046875 -21.04687500 72 108 122.046875 -14.04687500 73 90 80.640000 9.36000000 74 114 80.640000 33.36000000 75 103 122.046875 -19.04687500 76 142 122.046875 19.95312500 77 79 80.640000 -1.64000000 78 88 122.046875 -34.04687500 79 25 26.675000 -1.67500000 80 83 122.046875 -39.04687500 81 113 102.928571 10.07142857 82 118 80.640000 37.36000000 83 110 122.046875 -12.04687500 84 129 122.046875 6.95312500 85 51 74.363636 -23.36363636 86 93 80.640000 12.36000000 87 76 80.640000 -4.64000000 88 49 47.090909 1.90909091 89 118 122.046875 -4.04687500 90 38 47.090909 -9.09090909 91 141 122.046875 18.95312500 92 58 47.090909 10.90909091 93 27 40.235294 -13.23529412 94 91 102.928571 -11.92857143 95 48 47.090909 0.90909091 96 63 122.046875 -59.04687500 97 56 122.046875 -66.04687500 98 144 102.928571 41.07142857 99 73 74.363636 -1.36363636 100 168 122.046875 45.95312500 101 64 47.090909 16.90909091 102 97 122.046875 -25.04687500 103 117 122.046875 -5.04687500 104 100 102.928571 -2.92857143 105 149 122.046875 26.95312500 106 187 175.454545 11.54545455 107 127 122.046875 4.95312500 108 37 47.090909 -10.09090909 109 245 175.454545 69.54545455 110 87 122.046875 -35.04687500 111 177 122.046875 54.95312500 112 49 47.090909 1.90909091 113 49 47.090909 1.90909091 114 73 80.640000 -7.64000000 115 177 175.454545 1.54545455 116 94 122.046875 -28.04687500 117 117 122.046875 -5.04687500 118 60 74.363636 -14.36363636 119 55 102.928571 -47.92857143 120 39 26.675000 12.32500000 121 64 80.640000 -16.64000000 122 26 26.675000 -0.67500000 123 64 47.090909 16.90909091 124 58 40.235294 17.76470588 125 95 122.046875 -27.04687500 126 25 26.675000 -1.67500000 127 26 40.235294 -14.23529412 128 76 80.640000 -4.64000000 129 129 122.046875 6.95312500 130 11 8.592593 2.40740741 131 2 8.592593 -6.59259259 132 101 102.928571 -1.92857143 133 28 26.675000 1.32500000 134 36 47.090909 -11.09090909 135 89 47.090909 41.90909091 136 193 122.046875 70.95312500 137 4 8.592593 -4.59259259 138 84 74.363636 9.63636364 139 23 25.692308 -2.69230769 140 39 25.692308 13.30769231 141 14 8.592593 5.40740741 142 78 47.090909 30.90909091 143 14 26.675000 -12.67500000 144 101 122.046875 -21.04687500 145 82 122.046875 -40.04687500 146 24 26.675000 -2.67500000 147 36 40.235294 -4.23529412 148 75 47.090909 27.90909091 149 16 8.592593 7.40740741 150 55 80.640000 -25.64000000 151 131 122.046875 8.95312500 152 131 102.928571 28.07142857 153 39 40.235294 -1.23529412 154 144 122.046875 21.95312500 155 139 122.046875 16.95312500 156 211 175.454545 35.54545455 157 78 80.640000 -2.64000000 158 50 40.235294 9.76470588 159 39 47.090909 -8.09090909 160 90 122.046875 -32.04687500 161 166 122.046875 43.95312500 162 12 26.675000 -14.67500000 163 57 47.090909 9.90909091 164 133 175.454545 -42.45454545 165 69 47.090909 21.90909091 166 119 122.046875 -3.04687500 167 119 74.363636 44.63636364 168 65 47.090909 17.90909091 169 61 47.090909 13.90909091 170 49 74.363636 -25.36363636 171 101 122.046875 -21.04687500 172 196 122.046875 73.95312500 173 15 40.235294 -25.23529412 174 136 122.046875 13.95312500 175 89 80.640000 8.36000000 176 40 47.090909 -7.09090909 177 123 122.046875 0.95312500 178 21 26.675000 -5.67500000 179 163 122.046875 40.95312500 180 29 47.090909 -18.09090909 181 35 26.675000 8.32500000 182 13 26.675000 -13.67500000 183 5 8.592593 -3.59259259 184 96 122.046875 -26.04687500 185 151 122.046875 28.95312500 186 6 8.592593 -2.59259259 187 13 8.592593 4.40740741 188 3 8.592593 -5.59259259 189 56 47.090909 8.90909091 190 23 26.675000 -3.67500000 191 57 80.640000 -23.64000000 192 14 47.090909 -33.09090909 193 43 47.090909 -4.09090909 194 20 25.692308 -5.69230769 195 72 80.640000 -8.64000000 196 87 47.090909 39.90909091 197 21 47.090909 -26.09090909 198 56 47.090909 8.90909091 199 59 40.235294 18.76470588 200 82 47.090909 34.90909091 201 43 47.090909 -4.09090909 202 25 8.592593 16.40740741 203 38 47.090909 -9.09090909 204 25 47.090909 -22.09090909 205 38 26.675000 11.32500000 206 12 8.592593 3.40740741 207 29 47.090909 -18.09090909 208 47 74.363636 -27.36363636 209 45 47.090909 -2.09090909 210 40 47.090909 -7.09090909 211 30 26.675000 3.32500000 212 41 40.235294 0.76470588 213 25 25.692308 -0.69230769 214 23 47.090909 -24.09090909 215 14 8.592593 5.40740741 216 16 25.692308 -9.69230769 217 26 26.675000 -0.67500000 218 21 25.692308 -4.69230769 219 27 26.675000 0.32500000 220 9 26.675000 -17.67500000 221 33 47.090909 -14.09090909 222 42 80.640000 -38.64000000 223 68 47.090909 20.90909091 224 32 47.090909 -15.09090909 225 6 8.592593 -2.59259259 226 67 40.235294 26.76470588 227 33 26.675000 6.32500000 228 77 47.090909 29.90909091 229 46 26.675000 19.32500000 230 30 26.675000 3.32500000 231 0 8.592593 -8.59259259 232 36 47.090909 -11.09090909 233 46 47.090909 -1.09090909 234 18 25.692308 -7.69230769 235 48 47.090909 0.90909091 236 29 47.090909 -18.09090909 237 28 40.235294 -12.23529412 238 34 25.692308 8.30769231 239 33 26.675000 6.32500000 240 34 25.692308 8.30769231 241 33 26.675000 6.32500000 242 80 80.640000 -0.64000000 243 32 25.692308 6.30769231 244 30 47.090909 -17.09090909 245 41 26.675000 14.32500000 246 41 47.090909 -6.09090909 247 51 47.090909 3.90909091 248 18 26.675000 -8.67500000 249 34 26.675000 7.32500000 250 31 47.090909 -16.09090909 251 39 47.090909 -8.09090909 252 54 47.090909 6.90909091 253 14 8.592593 5.40740741 254 24 40.235294 -16.23529412 255 24 26.675000 -2.67500000 256 8 8.592593 -0.59259259 257 26 25.692308 0.30769231 258 19 26.675000 -7.67500000 259 11 26.675000 -15.67500000 260 14 25.692308 -11.69230769 261 1 8.592593 -7.59259259 262 39 47.090909 -8.09090909 263 5 8.592593 -3.59259259 264 37 47.090909 -10.09090909 265 32 25.692308 6.30769231 266 38 26.675000 11.32500000 267 47 47.090909 -0.09090909 268 47 26.675000 20.32500000 269 37 47.090909 -10.09090909 270 51 47.090909 3.90909091 271 45 40.235294 4.76470588 272 21 26.675000 -5.67500000 273 1 8.592593 -7.59259259 274 42 40.235294 1.76470588 275 26 26.675000 -0.67500000 276 21 26.675000 -5.67500000 277 4 8.592593 -4.59259259 278 10 8.592593 1.40740741 279 43 47.090909 -4.09090909 280 34 26.675000 7.32500000 281 31 26.675000 4.32500000 282 19 26.675000 -7.67500000 283 34 26.675000 7.32500000 284 6 8.592593 -2.59259259 285 11 26.675000 -15.67500000 286 24 8.592593 15.40740741 287 16 8.592593 7.40740741 288 72 47.090909 24.90909091 > 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/4b8s41354891484.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/5lmkh1354891484.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/64yhy1354891484.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/7pzc51354891484.tab") + } > > try(system("convert tmp/2a77b1354891484.ps tmp/2a77b1354891484.png",intern=TRUE)) character(0) > try(system("convert tmp/39h8b1354891484.ps tmp/39h8b1354891484.png",intern=TRUE)) character(0) > try(system("convert tmp/4b8s41354891484.ps tmp/4b8s41354891484.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.032 0.587 7.604