R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(252101 + ,62 + ,438 + ,92 + ,34 + ,104 + ,165119 + ,134577 + ,59 + ,330 + ,58 + ,30 + ,111 + ,107269 + ,198520 + ,62 + ,609 + ,62 + ,38 + ,93 + ,93497 + ,189326 + ,94 + ,1015 + ,108 + ,34 + ,119 + ,100269 + ,137449 + ,43 + ,294 + ,55 + ,25 + ,57 + ,91627 + ,65295 + ,27 + ,164 + ,8 + ,31 + ,80 + ,47552 + ,439387 + ,103 + ,1912 + ,134 + ,29 + ,107 + ,233933 + ,33186 + ,19 + ,111 + ,1 + ,18 + ,22 + ,6853 + ,178368 + ,51 + ,698 + ,64 + ,30 + ,103 + ,104380 + ,186657 + ,38 + ,556 + ,77 + ,29 + ,72 + ,98431 + ,261949 + ,96 + ,711 + ,86 + ,38 + ,123 + ,156949 + ,191051 + ,95 + ,495 + ,93 + ,49 + ,164 + ,81817 + ,138866 + ,57 + ,544 + ,44 + ,33 + ,100 + ,59238 + ,296878 + ,66 + ,959 + ,106 + ,46 + ,143 + ,101138 + ,192648 + ,72 + ,540 + ,63 + ,38 + ,79 + ,107158 + ,333462 + ,162 + ,1486 + ,160 + ,52 + ,183 + ,155499 + ,243571 + ,58 + ,635 + ,104 + ,32 + ,123 + ,156274 + ,263451 + ,130 + ,940 + ,86 + ,35 + ,81 + ,121777 + ,155679 + ,48 + ,452 + ,93 + ,25 + ,74 + ,105037 + ,227053 + ,70 + ,617 + ,119 + ,42 + ,158 + ,118661 + ,240028 + ,63 + ,695 + ,107 + ,40 + ,133 + ,131187 + ,388549 + ,90 + ,1046 + ,86 + ,35 + ,128 + ,145026 + ,156540 + ,34 + ,405 + ,50 + ,25 + ,84 + ,107016 + ,148421 + ,43 + ,477 + ,92 + ,46 + ,184 + ,87242 + ,177732 + ,97 + ,1012 + ,123 + ,36 + ,127 + ,91699 + ,191441 + ,105 + ,842 + ,81 + ,35 + ,128 + ,110087 + ,249893 + ,122 + ,994 + ,93 + ,38 + ,118 + ,145447 + ,236812 + ,76 + ,530 + ,113 + ,35 + ,125 + ,143307 + ,142329 + ,45 + ,515 + ,52 + ,28 + ,89 + ,61678 + ,259667 + ,53 + ,766 + ,113 + ,37 + ,122 + ,210080 + ,231625 + ,65 + ,734 + ,112 + ,40 + ,151 + ,165005 + ,176062 + ,67 + ,551 + ,44 + ,42 + ,122 + ,97806 + ,286683 + ,79 + ,718 + ,123 + ,44 + ,162 + ,184471 + ,87485 + ,33 + ,280 + ,38 + ,33 + ,121 + ,27786 + ,322865 + ,83 + ,1055 + ,111 + ,35 + ,132 + ,184458 + ,247082 + ,51 + ,950 + ,77 + ,37 + ,110 + ,98765 + ,344092 + ,104 + ,1035 + ,92 + ,39 + ,135 + ,178441 + ,191653 + ,74 + ,552 + ,74 + ,32 + ,80 + ,100619 + ,114673 + ,31 + ,275 + ,33 + ,17 + ,46 + ,58391 + ,284224 + ,161 + ,986 + ,105 + ,34 + ,127 + ,151672 + ,284195 + ,72 + ,1336 + ,108 + ,33 + ,103 + ,124437 + ,155363 + ,59 + ,565 + ,66 + ,35 + ,95 + ,79929 + ,177306 + ,67 + ,571 + ,69 + ,32 + ,100 + ,123064 + ,144571 + ,49 + ,404 + ,62 + ,35 + ,102 + ,50466 + ,140319 + ,73 + ,985 + ,50 + ,45 + ,45 + ,100991 + ,405267 + ,135 + ,1851 + ,91 + ,38 + ,122 + ,79367 + ,78800 + ,42 + ,330 + ,20 + ,26 + ,66 + ,56968 + ,201970 + ,69 + ,611 + ,101 + ,45 + ,159 + ,106257 + ,302674 + ,99 + ,1249 + ,129 + ,44 + ,153 + ,178412 + ,164733 + ,50 + ,812 + ,93 + ,40 + ,131 + ,98520 + ,194221 + ,68 + ,501 + ,89 + ,33 + ,113 + ,153670 + ,24188 + ,24 + ,218 + ,8 + ,4 + ,7 + ,15049 + ,342263 + ,279 + ,785 + ,79 + ,41 + ,147 + ,174478 + ,65029 + ,17 + ,255 + ,21 + ,18 + ,61 + ,25109 + ,101097 + ,64 + ,454 + ,30 + ,14 + ,41 + ,45824 + ,246088 + ,46 + ,944 + ,86 + ,33 + ,108 + ,116772 + ,273108 + ,75 + ,600 + ,116 + ,49 + ,184 + ,189150 + ,282220 + ,160 + ,977 + ,106 + ,32 + ,115 + ,194404 + ,273495 + ,119 + ,863 + ,127 + ,37 + ,132 + ,185881 + ,214872 + ,74 + ,690 + ,75 + ,32 + ,113 + ,67508 + ,335121 + ,123 + ,1176 + ,138 + ,41 + ,141 + ,188597 + ,267171 + ,106 + ,1013 + ,114 + ,25 + ,65 + ,203618 + ,187938 + ,88 + ,890 + ,55 + ,40 + ,87 + ,87232 + ,229512 + ,78 + ,777 + ,67 + ,35 + ,121 + ,110875 + ,209798 + ,61 + ,521 + ,45 + ,33 + ,112 + ,144756 + ,201345 + ,60 + ,409 + ,88 + ,28 + ,81 + ,129825 + ,163833 + ,113 + ,493 + ,67 + ,31 + ,116 + ,92189 + ,204250 + ,129 + ,757 + ,75 + ,40 + ,132 + ,121158 + ,197813 + ,67 + ,736 + ,114 + ,32 + ,104 + ,96219 + ,132955 + ,60 + ,511 + ,123 + ,25 + ,80 + ,84128 + ,216092 + ,59 + ,789 + ,86 + ,42 + ,145 + ,97960 + ,73566 + ,32 + ,385 + ,22 + ,23 + ,67 + ,23824 + ,213198 + ,67 + ,644 + ,67 + ,42 + ,159 + ,103515 + ,181713 + ,49 + ,664 + ,77 + ,38 + ,90 + ,91313 + ,148698 + ,49 + ,505 + ,105 + ,34 + ,120 + ,85407 + ,300103 + ,70 + ,878 + ,119 + ,38 + ,126 + ,95871 + ,251437 + ,78 + ,769 + ,88 + ,32 + ,118 + ,143846 + ,197295 + ,101 + ,499 + ,78 + ,37 + ,112 + ,155387 + ,158163 + ,55 + ,546 + ,112 + ,34 + ,123 + ,74429 + ,155529 + ,57 + ,551 + ,66 + ,33 + ,98 + ,74004 + ,132672 + ,41 + ,565 + ,58 + ,25 + ,78 + ,71987 + ,377205 + ,100 + ,1086 + ,132 + ,40 + ,119 + ,150629 + ,145905 + ,66 + ,649 + ,30 + ,26 + ,99 + ,68580 + ,223701 + ,86 + ,540 + ,100 + ,40 + ,81 + ,119855 + ,80953 + ,25 + ,437 + ,49 + ,8 + ,27 + ,55792 + ,130805 + ,47 + ,732 + ,26 + ,27 + ,77 + ,25157 + ,135082 + ,48 + ,308 + ,67 + ,32 + ,118 + ,90895 + ,300170 + ,154 + ,1236 + ,57 + ,33 + ,122 + ,117510 + ,271806 + ,95 + ,783 + ,95 + ,50 + ,103 + ,144774 + ,150949 + ,96 + ,933 + ,139 + ,37 + ,129 + ,77529 + ,225805 + ,79 + ,710 + ,73 + ,33 + ,69 + ,103123 + ,197389 + ,67 + ,563 + ,134 + ,34 + ,121 + ,104669 + ,156583 + ,56 + ,508 + ,37 + ,28 + ,81 + ,82414 + ,222599 + ,66 + ,936 + ,98 + ,32 + ,119 + ,82390 + ,261601 + ,70 + ,838 + ,58 + ,32 + ,116 + ,128446 + ,178489 + ,35 + ,523 + ,78 + ,32 + ,123 + ,111542 + ,200657 + ,43 + ,500 + ,88 + ,31 + ,111 + ,136048 + ,259084 + ,67 + ,691 + ,142 + ,35 + ,100 + ,197257 + ,313075 + ,130 + ,1060 + ,127 + ,58 + ,221 + ,162079 + ,346933 + ,100 + ,1232 + ,139 + ,27 + ,95 + ,206286 + ,246440 + ,104 + ,735 + ,108 + ,45 + ,153 + ,109858 + ,252444 + ,58 + ,757 + ,128 + ,37 + ,118 + ,182125 + ,159965 + ,159 + ,574 + ,62 + ,32 + ,50 + ,74168 + ,43287 + ,14 + ,214 + ,13 + ,19 + ,64 + ,19630 + ,172239 + ,68 + ,661 + ,89 + ,22 + ,34 + ,88634 + ,181897 + ,119 + ,630 + ,83 + ,35 + ,76 + ,128321 + ,227681 + ,43 + ,1015 + ,116 + ,36 + ,112 + ,118936 + ,260464 + ,81 + ,893 + ,157 + ,36 + ,115 + ,127044 + ,106288 + ,54 + ,293 + ,28 + ,23 + ,69 + ,178377 + ,109632 + ,76 + ,446 + ,83 + ,36 + ,108 + ,69581 + ,268905 + ,58 + ,538 + ,72 + ,36 + ,130 + ,168019 + ,266805 + ,78 + ,627 + ,134 + ,42 + ,110 + ,113598 + ,23623 + ,11 + ,156 + ,12 + ,1 + ,0 + ,5841 + ,152474 + ,65 + ,577 + ,106 + ,32 + ,83 + ,93116 + ,61857 + ,25 + ,192 + ,23 + ,11 + ,30 + ,24610 + ,144889 + ,43 + ,437 + ,83 + ,40 + ,106 + ,60611 + ,346600 + ,99 + ,1054 + ,126 + ,34 + ,91 + ,226620 + ,21054 + ,16 + ,146 + ,4 + ,0 + ,0 + ,6622 + ,224051 + ,45 + ,751 + ,71 + ,27 + ,69 + ,121996 + ,31414 + ,19 + ,200 + ,18 + ,8 + ,9 + ,13155 + ,261043 + ,105 + ,1050 + ,98 + ,35 + ,123 + ,154158 + ,197819 + ,57 + ,590 + ,66 + ,41 + ,143 + ,78489 + ,154984 + ,73 + ,430 + ,44 + ,40 + ,125 + ,22007 + ,112933 + ,45 + ,467 + ,29 + ,28 + ,81 + ,72530 + ,38214 + ,34 + ,276 + ,16 + ,8 + ,21 + ,13983 + ,158671 + ,33 + ,528 + ,56 + ,35 + ,124 + ,73397 + ,302148 + ,70 + ,898 + ,112 + ,47 + ,168 + ,143878 + ,177918 + ,55 + ,411 + ,46 + ,46 + ,149 + ,119956 + ,350552 + ,70 + ,1362 + ,129 + ,42 + ,147 + ,181558 + ,275578 + ,91 + ,743 + ,139 + ,48 + ,145 + ,208236 + ,366217 + ,105 + ,1068 + ,136 + ,49 + ,172 + ,237085 + ,172464 + ,31 + ,431 + ,66 + ,35 + ,126 + ,110297 + ,94381 + ,35 + ,380 + ,42 + ,32 + ,89 + ,61394 + ,243875 + ,278 + ,788 + ,70 + ,36 + ,137 + ,81420 + ,382487 + ,153 + ,1367 + ,97 + ,42 + ,149 + ,191154 + ,114525 + ,40 + ,449 + ,49 + ,35 + ,121 + ,11798 + ,335681 + ,119 + ,1461 + ,113 + ,37 + ,133 + ,135724 + ,147989 + ,72 + ,651 + ,55 + ,34 + ,93 + ,68614 + ,216638 + ,44 + ,494 + ,100 + ,36 + ,119 + ,139926 + ,192862 + ,72 + ,667 + ,80 + ,36 + ,102 + ,105203 + ,184818 + ,107 + ,510 + ,29 + ,32 + ,45 + ,80338 + ,336707 + ,105 + ,1472 + ,95 + ,33 + ,104 + ,121376 + ,215836 + ,76 + ,675 + ,114 + ,35 + ,111 + ,124922 + ,173260 + ,63 + ,716 + ,41 + ,21 + ,78 + ,10901 + ,271773 + ,89 + ,814 + ,128 + ,40 + ,120 + ,135471 + ,130908 + ,52 + ,556 + ,142 + ,49 + ,176 + ,66395 + ,204009 + ,75 + ,887 + ,88 + ,33 + ,109 + ,134041 + ,245514 + ,92 + ,663 + ,147 + ,39 + ,132 + ,153554 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,14688 + ,10 + ,85 + ,4 + ,0 + ,0 + ,7953 + ,98 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,455 + ,2 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,195765 + ,75 + ,607 + ,56 + ,33 + ,78 + ,98922 + ,326038 + ,121 + ,934 + ,121 + ,42 + ,104 + ,165395 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,203 + ,4 + ,0 + ,0 + ,0 + ,0 + ,0 + ,7199 + ,5 + ,74 + ,7 + ,0 + ,0 + ,4245 + ,46660 + ,20 + ,259 + ,12 + ,5 + ,13 + ,21509 + ,17547 + ,5 + ,69 + ,0 + ,1 + ,4 + ,7670 + ,107465 + ,38 + ,267 + ,37 + ,38 + ,65 + ,15167 + ,969 + ,2 + ,0 + ,0 + ,0 + ,0 + ,0 + ,173102 + ,58 + ,517 + ,47 + ,28 + ,55 + ,63891) + ,dim=c(7 + ,164) + ,dimnames=list(c('Time' + ,'Logins' + ,'Views' + ,'Blogs' + ,'Reviews' + ,'LFM' + ,'Compendia_time ') + ,1:164)) > y <- array(NA,dim=c(7,164),dimnames=list(c('Time','Logins','Views','Blogs','Reviews','LFM','Compendia_time '),1:164)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '1' > 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 Loading required package: sandwich Loading required package: strucchange Loading required package: vcd Loading required package: MASS Loading required package: colorspace > library(Hmisc) 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" > x[,par1] [1] 252101 134577 198520 189326 137449 65295 439387 33186 178368 186657 [11] 261949 191051 138866 296878 192648 333462 243571 263451 155679 227053 [21] 240028 388549 156540 148421 177732 191441 249893 236812 142329 259667 [31] 231625 176062 286683 87485 322865 247082 344092 191653 114673 284224 [41] 284195 155363 177306 144571 140319 405267 78800 201970 302674 164733 [51] 194221 24188 342263 65029 101097 246088 273108 282220 273495 214872 [61] 335121 267171 187938 229512 209798 201345 163833 204250 197813 132955 [71] 216092 73566 213198 181713 148698 300103 251437 197295 158163 155529 [81] 132672 377205 145905 223701 80953 130805 135082 300170 271806 150949 [91] 225805 197389 156583 222599 261601 178489 200657 259084 313075 346933 [101] 246440 252444 159965 43287 172239 181897 227681 260464 106288 109632 [111] 268905 266805 23623 152474 61857 144889 346600 21054 224051 31414 [121] 261043 197819 154984 112933 38214 158671 302148 177918 350552 275578 [131] 366217 172464 94381 243875 382487 114525 335681 147989 216638 192862 [141] 184818 336707 215836 173260 271773 130908 204009 245514 1 14688 [151] 98 455 0 0 195765 326038 0 203 7199 46660 [161] 17547 107465 969 173102 > 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 98 203 455 969 7199 14688 17547 21054 23623 3 1 1 1 1 1 1 1 1 1 1 24188 31414 33186 38214 43287 46660 61857 65029 65295 73566 78800 1 1 1 1 1 1 1 1 1 1 1 80953 87485 94381 101097 106288 107465 109632 112933 114525 114673 130805 1 1 1 1 1 1 1 1 1 1 1 130908 132672 132955 134577 135082 137449 138866 140319 142329 144571 144889 1 1 1 1 1 1 1 1 1 1 1 145905 147989 148421 148698 150949 152474 154984 155363 155529 155679 156540 1 1 1 1 1 1 1 1 1 1 1 156583 158163 158671 159965 163833 164733 172239 172464 173102 173260 176062 1 1 1 1 1 1 1 1 1 1 1 177306 177732 177918 178368 178489 181713 181897 184818 186657 187938 189326 1 1 1 1 1 1 1 1 1 1 1 191051 191441 191653 192648 192862 194221 195765 197295 197389 197813 197819 1 1 1 1 1 1 1 1 1 1 1 198520 200657 201345 201970 204009 204250 209798 213198 214872 215836 216092 1 1 1 1 1 1 1 1 1 1 1 216638 222599 223701 224051 225805 227053 227681 229512 231625 236812 240028 1 1 1 1 1 1 1 1 1 1 1 243571 243875 245514 246088 246440 247082 249893 251437 252101 252444 259084 1 1 1 1 1 1 1 1 1 1 1 259667 260464 261043 261601 261949 263451 266805 267171 268905 271773 271806 1 1 1 1 1 1 1 1 1 1 1 273108 273495 275578 282220 284195 284224 286683 296878 300103 300170 302148 1 1 1 1 1 1 1 1 1 1 1 302674 313075 322865 326038 333462 335121 335681 336707 342263 344092 346600 1 1 1 1 1 1 1 1 1 1 1 346933 350552 366217 377205 382487 388549 405267 439387 1 1 1 1 1 1 1 1 > colnames(x) [1] "Time" "Logins" "Views" "Blogs" [5] "Reviews" "LFM" "Compendia_time." > colnames(x)[par1] [1] "Time" > x[,par1] [1] 252101 134577 198520 189326 137449 65295 439387 33186 178368 186657 [11] 261949 191051 138866 296878 192648 333462 243571 263451 155679 227053 [21] 240028 388549 156540 148421 177732 191441 249893 236812 142329 259667 [31] 231625 176062 286683 87485 322865 247082 344092 191653 114673 284224 [41] 284195 155363 177306 144571 140319 405267 78800 201970 302674 164733 [51] 194221 24188 342263 65029 101097 246088 273108 282220 273495 214872 [61] 335121 267171 187938 229512 209798 201345 163833 204250 197813 132955 [71] 216092 73566 213198 181713 148698 300103 251437 197295 158163 155529 [81] 132672 377205 145905 223701 80953 130805 135082 300170 271806 150949 [91] 225805 197389 156583 222599 261601 178489 200657 259084 313075 346933 [101] 246440 252444 159965 43287 172239 181897 227681 260464 106288 109632 [111] 268905 266805 23623 152474 61857 144889 346600 21054 224051 31414 [121] 261043 197819 154984 112933 38214 158671 302148 177918 350552 275578 [131] 366217 172464 94381 243875 382487 114525 335681 147989 216638 192862 [141] 184818 336707 215836 173260 271773 130908 204009 245514 1 14688 [151] 98 455 0 0 195765 326038 0 203 7199 46660 [161] 17547 107465 969 173102 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/1j4ry1324646975.tab") + } + } > m Conditional inference tree with 10 terminal nodes Response: Time Inputs: Logins, Views, Blogs, Reviews, LFM, Compendia_time. Number of observations: 164 1) Views <= 385; criterion = 1, statistic = 127.646 2) Blogs <= 18; criterion = 1, statistic = 27.342 3) Compendia_time. <= 4245; criterion = 1, statistic = 16.012 4)* weights = 9 3) Compendia_time. > 4245 5)* weights = 11 2) Blogs > 18 6)* weights = 12 1) Views > 385 7) Views <= 1015; criterion = 1, statistic = 80.823 8) Compendia_time. <= 111542; criterion = 1, statistic = 64.315 9) Views <= 577; criterion = 1, statistic = 20.985 10) Compendia_time. <= 72530; criterion = 0.998, statistic = 12.766 11)* weights = 13 10) Compendia_time. > 72530 12)* weights = 22 9) Views > 577 13)* weights = 31 8) Compendia_time. > 111542 14) Views <= 675; criterion = 0.999, statistic = 13.458 15)* weights = 19 14) Views > 675 16) Logins <= 78; criterion = 0.985, statistic = 9.16 17)* weights = 12 16) Logins > 78 18)* weights = 15 7) Views > 1015 19)* weights = 20 > postscript(file="/var/wessaorg/rcomp/tmp/26e1l1324646975.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/wessaorg/rcomp/tmp/328041324646975.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 252101 221604.2632 30496.73684 2 134577 99721.0000 34856.00000 3 198520 199158.7742 -638.77419 4 189326 199158.7742 -9832.77419 5 137449 99721.0000 37728.00000 6 65295 32650.5455 32644.45455 7 439387 343614.1000 95772.90000 8 33186 32650.5455 535.45455 9 178368 199158.7742 -20790.77419 10 186657 167004.7727 19652.22727 11 261949 274750.5333 -12801.53333 12 191051 167004.7727 24046.22727 13 138866 129343.1538 9522.84615 14 296878 199158.7742 97719.22581 15 192648 167004.7727 25643.22727 16 333462 343614.1000 -10152.10000 17 243571 221604.2632 21966.73684 18 263451 274750.5333 -11299.53333 19 155679 167004.7727 -11325.77273 20 227053 221604.2632 5448.73684 21 240028 246655.2500 -6627.25000 22 388549 343614.1000 44934.90000 23 156540 167004.7727 -10464.77273 24 148421 167004.7727 -18583.77273 25 177732 199158.7742 -21426.77419 26 191441 199158.7742 -7717.77419 27 249893 274750.5333 -24857.53333 28 236812 221604.2632 15207.73684 29 142329 129343.1538 12985.84615 30 259667 246655.2500 13011.75000 31 231625 246655.2500 -15030.25000 32 176062 167004.7727 9057.22727 33 286683 274750.5333 11932.46667 34 87485 99721.0000 -12236.00000 35 322865 343614.1000 -20749.10000 36 247082 199158.7742 47923.22581 37 344092 343614.1000 477.90000 38 191653 167004.7727 24648.22727 39 114673 99721.0000 14952.00000 40 284224 274750.5333 9473.46667 41 284195 343614.1000 -59419.10000 42 155363 167004.7727 -11641.77273 43 177306 221604.2632 -44298.26316 44 144571 129343.1538 15227.84615 45 140319 199158.7742 -58839.77419 46 405267 343614.1000 61652.90000 47 78800 99721.0000 -20921.00000 48 201970 199158.7742 2811.22581 49 302674 343614.1000 -40940.10000 50 164733 199158.7742 -34425.77419 51 194221 221604.2632 -27383.26316 52 24188 32650.5455 -8462.54545 53 342263 274750.5333 67512.46667 54 65029 99721.0000 -34692.00000 55 101097 129343.1538 -28246.15385 56 246088 246655.2500 -567.25000 57 273108 221604.2632 51503.73684 58 282220 274750.5333 7469.46667 59 273495 274750.5333 -1255.53333 60 214872 199158.7742 15713.22581 61 335121 343614.1000 -8493.10000 62 267171 274750.5333 -7579.53333 63 187938 199158.7742 -11220.77419 64 229512 199158.7742 30353.22581 65 209798 221604.2632 -11806.26316 66 201345 221604.2632 -20259.26316 67 163833 167004.7727 -3171.77273 68 204250 274750.5333 -70500.53333 69 197813 199158.7742 -1345.77419 70 132955 167004.7727 -34049.77273 71 216092 199158.7742 16933.22581 72 73566 99721.0000 -26155.00000 73 213198 199158.7742 14039.22581 74 181713 199158.7742 -17445.77419 75 148698 167004.7727 -18306.77273 76 300103 199158.7742 100944.22581 77 251437 246655.2500 4781.75000 78 197295 221604.2632 -24309.26316 79 158163 167004.7727 -8841.77273 80 155529 167004.7727 -11475.77273 81 132672 129343.1538 3328.84615 82 377205 343614.1000 33590.90000 83 145905 199158.7742 -53253.77419 84 223701 221604.2632 2096.73684 85 80953 129343.1538 -48390.15385 86 130805 199158.7742 -68353.77419 87 135082 99721.0000 35361.00000 88 300170 343614.1000 -43444.10000 89 271806 274750.5333 -2944.53333 90 150949 199158.7742 -48209.77419 91 225805 199158.7742 26646.22581 92 197389 167004.7727 30384.22727 93 156583 167004.7727 -10421.77273 94 222599 199158.7742 23440.22581 95 261601 246655.2500 14945.75000 96 178489 167004.7727 11484.22727 97 200657 221604.2632 -20947.26316 98 259084 246655.2500 12428.75000 99 313075 343614.1000 -30539.10000 100 346933 343614.1000 3318.90000 101 246440 199158.7742 47281.22581 102 252444 246655.2500 5788.75000 103 159965 167004.7727 -7039.77273 104 43287 32650.5455 10636.45455 105 172239 199158.7742 -26919.77419 106 181897 221604.2632 -39707.26316 107 227681 246655.2500 -18974.25000 108 260464 274750.5333 -14286.53333 109 106288 99721.0000 6567.00000 110 109632 129343.1538 -19711.15385 111 268905 221604.2632 47300.73684 112 266805 221604.2632 45200.73684 113 23623 32650.5455 -9027.54545 114 152474 167004.7727 -14530.77273 115 61857 99721.0000 -37864.00000 116 144889 129343.1538 15545.84615 117 346600 343614.1000 2985.90000 118 21054 32650.5455 -11596.54545 119 224051 246655.2500 -22604.25000 120 31414 32650.5455 -1236.54545 121 261043 343614.1000 -82571.10000 122 197819 199158.7742 -1339.77419 123 154984 129343.1538 25640.84615 124 112933 129343.1538 -16410.15385 125 38214 32650.5455 5563.45455 126 158671 167004.7727 -8333.77273 127 302148 246655.2500 55492.75000 128 177918 221604.2632 -43686.26316 129 350552 343614.1000 6937.90000 130 275578 274750.5333 827.46667 131 366217 343614.1000 22602.90000 132 172464 167004.7727 5459.22727 133 94381 99721.0000 -5340.00000 134 243875 199158.7742 44716.22581 135 382487 343614.1000 38872.90000 136 114525 129343.1538 -14818.15385 137 335681 343614.1000 -7933.10000 138 147989 199158.7742 -51169.77419 139 216638 221604.2632 -4966.26316 140 192862 199158.7742 -6296.77419 141 184818 167004.7727 17813.22727 142 336707 343614.1000 -6907.10000 143 215836 221604.2632 -5768.26316 144 173260 199158.7742 -25898.77419 145 271773 274750.5333 -2977.53333 146 130908 129343.1538 1564.84615 147 204009 246655.2500 -42646.25000 148 245514 221604.2632 23909.73684 149 1 991.6667 -990.66667 150 14688 32650.5455 -17962.54545 151 98 991.6667 -893.66667 152 455 991.6667 -536.66667 153 0 991.6667 -991.66667 154 0 991.6667 -991.66667 155 195765 199158.7742 -3393.77419 156 326038 274750.5333 51287.46667 157 0 991.6667 -991.66667 158 203 991.6667 -788.66667 159 7199 991.6667 6207.33333 160 46660 32650.5455 14009.45455 161 17547 32650.5455 -15103.54545 162 107465 99721.0000 7744.00000 163 969 991.6667 -22.66667 164 173102 129343.1538 43758.84615 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/wessaorg/rcomp/tmp/4opu51324646975.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/wessaorg/rcomp/tmp/57dzg1324646975.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/wessaorg/rcomp/tmp/6g95o1324646975.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/wessaorg/rcomp/tmp/7wq4d1324646975.tab") + } > > try(system("convert tmp/26e1l1324646975.ps tmp/26e1l1324646975.png",intern=TRUE)) character(0) > try(system("convert tmp/328041324646975.ps tmp/328041324646975.png",intern=TRUE)) character(0) > try(system("convert tmp/4opu51324646975.ps tmp/4opu51324646975.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.764 0.316 4.073