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(41 + ,1785 + ,276257 + ,93 + ,492 + ,140824 + ,165 + ,34 + ,1227 + ,180480 + ,63 + ,436 + ,110459 + ,135 + ,44 + ,1944 + ,229345 + ,62 + ,697 + ,105079 + ,121 + ,38 + ,2683 + ,218443 + ,135 + ,1137 + ,112098 + ,148 + ,27 + ,1247 + ,171533 + ,48 + ,380 + ,43929 + ,73 + ,35 + ,631 + ,70849 + ,46 + ,179 + ,76173 + ,49 + ,33 + ,4845 + ,536497 + ,109 + ,2354 + ,187326 + ,185 + ,18 + ,381 + ,33186 + ,46 + ,111 + ,22807 + ,5 + ,34 + ,2066 + ,217320 + ,75 + ,740 + ,144408 + ,125 + ,33 + ,1759 + ,213274 + ,72 + ,595 + ,66485 + ,93 + ,46 + ,2157 + ,310843 + ,82 + ,809 + ,79089 + ,154 + ,57 + ,2211 + ,242788 + ,63 + ,693 + ,81625 + ,98 + ,37 + ,1967 + ,195022 + ,60 + ,738 + ,68788 + ,70 + ,55 + ,3005 + ,367785 + ,117 + ,1184 + ,103297 + ,148 + ,44 + ,2228 + ,261990 + ,50 + ,713 + ,69446 + ,100 + ,62 + ,5009 + ,392509 + ,132 + ,1729 + ,114948 + ,150 + ,40 + ,2353 + ,335528 + ,63 + ,844 + ,167949 + ,197 + ,39 + ,3278 + ,376673 + ,90 + ,1298 + ,125081 + ,114 + ,32 + ,1473 + ,181980 + ,44 + ,514 + ,125818 + ,169 + ,51 + ,2347 + ,266736 + ,64 + ,689 + ,136588 + ,200 + ,49 + ,2523 + ,278265 + ,103 + ,837 + ,112431 + ,148 + ,39 + ,2987 + ,461287 + ,101 + ,1330 + ,103037 + ,140 + ,25 + ,1523 + ,195786 + ,62 + ,491 + ,82317 + ,74 + ,56 + ,1761 + ,197058 + ,69 + ,622 + ,118906 + ,128 + ,45 + ,3660 + ,250284 + ,159 + ,1332 + ,83515 + ,140 + ,38 + ,2949 + ,250092 + ,74 + ,1046 + ,104581 + ,116 + ,45 + ,2914 + ,274121 + ,101 + ,1082 + ,103129 + ,147 + ,43 + ,2009 + ,278027 + ,73 + ,636 + ,83243 + ,132 + ,32 + ,1555 + ,165597 + ,53 + ,586 + ,37110 + ,70 + ,41 + ,3050 + ,371452 + ,140 + ,1170 + ,113344 + ,144 + ,50 + ,2438 + ,296386 + ,54 + ,976 + ,139165 + ,155 + ,50 + ,2092 + ,248320 + ,84 + ,721 + ,86652 + ,165 + ,51 + ,2404 + ,351980 + ,56 + ,863 + ,112302 + ,161 + ,37 + ,1018 + ,101014 + ,40 + ,343 + ,69652 + ,31 + ,44 + ,3462 + ,412722 + ,87 + ,1278 + ,119442 + ,199 + ,42 + ,2764 + ,273950 + ,87 + ,1186 + ,69867 + ,78 + ,44 + ,3710 + ,425531 + ,77 + ,1334 + ,101629 + ,121 + ,36 + ,1947 + ,231912 + ,67 + ,652 + ,70168 + ,112 + ,17 + ,947 + ,115658 + ,36 + ,284 + ,31081 + ,41 + ,43 + ,3609 + ,376008 + ,51 + ,1273 + ,103925 + ,158 + ,41 + ,3324 + ,335039 + ,44 + ,1518 + ,92622 + ,123 + ,41 + ,1842 + ,194127 + ,75 + ,715 + ,79011 + ,104 + ,38 + ,1869 + ,206947 + ,85 + ,671 + ,93487 + ,94 + ,49 + ,1813 + ,182286 + ,97 + ,486 + ,64520 + ,73 + ,45 + ,2496 + ,153778 + ,82 + ,1022 + ,93473 + ,52 + ,42 + ,5557 + ,457592 + ,860 + ,2084 + ,114360 + ,71 + ,26 + ,918 + ,78800 + ,57 + ,330 + ,33032 + ,21 + ,52 + ,2254 + ,208277 + ,80 + ,658 + ,96125 + ,155 + ,50 + ,4103 + ,359144 + ,120 + ,1385 + ,151911 + ,174 + ,45 + ,2241 + ,184648 + ,68 + ,930 + ,89256 + ,136 + ,40 + ,1943 + ,234078 + ,48 + ,620 + ,95676 + ,128 + ,4 + ,496 + ,24188 + ,20 + ,218 + ,5950 + ,7 + ,44 + ,2594 + ,380576 + ,81 + ,840 + ,149695 + ,165 + ,18 + ,744 + ,65029 + ,21 + ,255 + ,32551 + ,21 + ,14 + ,1161 + ,101097 + ,70 + ,454 + ,31701 + ,35 + ,38 + ,3121 + ,288327 + ,128 + ,1149 + ,100087 + ,137 + ,61 + ,2621 + ,334829 + ,86 + ,684 + ,169707 + ,174 + ,39 + ,3906 + ,359400 + ,222 + ,1190 + ,150491 + ,257 + ,42 + ,2722 + ,369577 + ,63 + ,1079 + ,120192 + ,207 + ,40 + ,2312 + ,269961 + ,86 + ,883 + ,95893 + ,103 + ,51 + ,4061 + ,389738 + ,70 + ,1331 + ,151715 + ,171 + ,28 + ,3195 + ,309474 + ,146 + ,1159 + ,176225 + ,279 + ,43 + ,3041 + ,282769 + ,72 + ,1217 + ,59900 + ,83 + ,42 + ,2644 + ,269324 + ,59 + ,946 + ,104767 + ,130 + ,37 + ,1496 + ,234773 + ,58 + ,579 + ,114799 + ,131 + ,30 + ,1835 + ,237561 + ,58 + ,474 + ,72128 + ,126 + ,39 + ,2090 + ,214916 + ,60 + ,630 + ,143592 + ,158 + ,44 + ,2772 + ,240376 + ,89 + ,843 + ,89626 + ,138 + ,36 + ,2440 + ,247447 + ,78 + ,893 + ,131072 + ,200 + ,28 + ,1718 + ,181550 + ,62 + ,633 + ,126817 + ,104 + ,47 + ,2566 + ,242152 + ,67 + ,873 + ,81351 + ,111 + ,23 + ,893 + ,73566 + ,39 + ,385 + ,22618 + ,26 + ,48 + ,2227 + ,246125 + ,60 + ,729 + ,88977 + ,115 + ,38 + ,1878 + ,199565 + ,94 + ,774 + ,92059 + ,127 + ,42 + ,2177 + ,222676 + ,67 + ,769 + ,81897 + ,140 + ,46 + ,2352 + ,363558 + ,96 + ,996 + ,108146 + ,121 + ,37 + ,2981 + ,365442 + ,51 + ,1194 + ,126372 + ,183 + ,41 + ,1926 + ,217036 + ,50 + ,575 + ,249771 + ,68 + ,42 + ,2400 + ,213466 + ,62 + ,725 + ,71154 + ,112 + ,41 + ,2034 + ,204477 + ,71 + ,706 + ,71571 + ,103 + ,36 + ,1800 + ,169080 + ,49 + ,665 + ,55918 + ,63 + ,45 + ,4168 + ,478396 + ,114 + ,1259 + ,160141 + ,166 + ,26 + ,1369 + ,145943 + ,45 + ,653 + ,38692 + ,38 + ,44 + ,2403 + ,288626 + ,57 + ,694 + ,102812 + ,163 + ,8 + ,870 + ,80953 + ,31 + ,437 + ,56622 + ,59 + ,27 + ,1968 + ,150221 + ,175 + ,822 + ,15986 + ,27 + ,38 + ,1569 + ,179317 + ,70 + ,458 + ,123534 + ,108 + ,38 + ,3962 + ,395368 + ,282 + ,1545 + ,108535 + ,88 + ,57 + ,2928 + ,349460 + ,91 + ,987 + ,93879 + ,92 + ,45 + ,3098 + ,180679 + ,72 + ,1051 + ,144551 + ,170 + ,40 + ,2557 + ,286578 + ,62 + ,838 + ,56750 + ,98 + ,42 + ,2329 + ,274477 + ,75 + ,703 + ,127654 + ,205 + ,31 + ,1858 + ,195623 + ,86 + ,613 + ,65594 + ,96 + ,36 + ,3146 + ,282361 + ,89 + ,1128 + ,59938 + ,107 + ,40 + ,2582 + ,329121 + ,138 + ,967 + ,146975 + ,150 + ,40 + ,1824 + ,198658 + ,68 + ,617 + ,165904 + ,138 + ,35 + ,1938 + ,264817 + ,72 + ,654 + ,169265 + ,177 + ,39 + ,2210 + ,300481 + ,61 + ,805 + ,183500 + ,213 + ,65 + ,4119 + ,403404 + ,130 + ,1355 + ,165986 + ,208 + ,33 + ,3844 + ,406613 + ,85 + ,1456 + ,184923 + ,307 + ,51 + ,2791 + ,294371 + ,83 + ,878 + ,140358 + ,125 + ,42 + ,2425 + ,313267 + ,86 + ,887 + ,149959 + ,208 + ,36 + ,2052 + ,189276 + ,116 + ,663 + ,57224 + ,73 + ,19 + ,602 + ,43287 + ,43 + ,214 + ,43750 + ,49 + ,25 + ,2195 + ,189520 + ,87 + ,733 + ,48029 + ,82 + ,44 + ,2413 + ,250254 + ,80 + ,830 + ,104978 + ,206 + ,40 + ,2632 + ,270832 + ,110 + ,1174 + ,100046 + ,112 + ,44 + ,2759 + ,314153 + ,59 + ,1068 + ,101047 + ,139 + ,30 + ,1268 + ,160308 + ,44 + ,413 + ,197426 + ,60 + ,45 + ,3233 + ,162843 + ,85 + ,946 + ,160902 + ,70 + ,42 + ,2025 + ,344925 + ,60 + ,657 + ,147172 + ,112 + ,45 + ,2310 + ,300526 + ,70 + ,690 + ,109432 + ,142 + ,1 + ,398 + ,23623 + ,9 + ,156 + ,1168 + ,11 + ,40 + ,2205 + ,195817 + ,54 + ,779 + ,83248 + ,130 + ,11 + ,530 + ,61857 + ,25 + ,192 + ,25162 + ,31 + ,45 + ,1611 + ,163931 + ,107 + ,461 + ,45724 + ,132 + ,38 + ,3153 + ,428191 + ,63 + ,1213 + ,110529 + ,219 + ,0 + ,387 + ,21054 + ,2 + ,146 + ,855 + ,4 + ,30 + ,2137 + ,252805 + ,67 + ,866 + ,101382 + ,102 + ,8 + ,492 + ,31961 + ,22 + ,200 + ,14116 + ,39 + ,41 + ,3674 + ,335888 + ,155 + ,1290 + ,89506 + ,125 + ,48 + ,2136 + ,246100 + ,79 + ,715 + ,135356 + ,121 + ,48 + ,1748 + ,180591 + ,112 + ,514 + ,116066 + ,42 + ,32 + ,1790 + ,163400 + ,50 + ,697 + ,144244 + ,111 + ,8 + ,568 + ,38214 + ,52 + ,276 + ,8773 + ,16 + ,43 + ,2191 + ,224597 + ,113 + ,752 + ,102153 + ,70 + ,52 + ,2792 + ,357602 + ,115 + ,1021 + ,117440 + ,162 + ,53 + ,1420 + ,202565 + ,78 + ,494 + ,104128 + ,173 + ,49 + ,3718 + ,424398 + ,135 + ,1626 + ,134238 + ,171 + ,48 + ,2554 + ,348017 + ,120 + ,884 + ,134047 + ,172 + ,56 + ,3460 + ,421610 + ,122 + ,1187 + ,279488 + ,254 + ,40 + ,1284 + ,192170 + ,49 + ,488 + ,79756 + ,90 + ,36 + ,1130 + ,102510 + ,56 + ,403 + ,66089 + ,50 + ,44 + ,2974 + ,302158 + ,155 + ,977 + ,102070 + ,113 + ,46 + ,4346 + ,444599 + ,155 + ,1525 + ,146760 + ,187 + ,43 + ,1785 + ,148707 + ,107 + ,551 + ,154771 + ,16 + ,46 + ,4350 + ,407736 + ,146 + ,1807 + ,165933 + ,175 + ,39 + ,1920 + ,164406 + ,76 + ,723 + ,64593 + ,90 + ,41 + ,1923 + ,278077 + ,83 + ,632 + ,92280 + ,140 + ,46 + ,2541 + ,282461 + ,192 + ,898 + ,67150 + ,145 + ,32 + ,1845 + ,219544 + ,69 + ,621 + ,128692 + ,141 + ,45 + ,4081 + ,384177 + ,131 + ,1606 + ,124089 + ,125 + ,39 + ,2339 + ,246963 + ,67 + ,811 + ,125386 + ,241 + ,21 + ,2035 + ,173260 + ,37 + ,716 + ,37238 + ,16 + ,49 + ,3108 + ,336715 + ,60 + ,1001 + ,140015 + ,175 + ,55 + ,1974 + ,176654 + ,127 + ,732 + ,150047 + ,132 + ,36 + ,2651 + ,253341 + ,52 + ,1024 + ,154451 + ,154 + ,48 + ,2702 + ,307133 + ,71 + ,831 + ,156349 + ,198 + ,0 + ,2 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,207 + ,14688 + ,0 + ,85 + ,6023 + ,5 + ,0 + ,5 + ,98 + ,0 + ,0 + ,0 + ,0 + ,0 + ,8 + ,455 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,43 + ,2255 + ,260901 + ,67 + ,773 + ,84601 + ,125 + ,52 + ,3447 + ,409280 + ,123 + ,1128 + ,68946 + ,174 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,4 + ,203 + ,0 + ,0 + ,0 + ,0 + ,0 + ,151 + ,7199 + ,0 + ,74 + ,1644 + ,6 + ,5 + ,474 + ,46660 + ,7 + ,259 + ,6179 + ,13 + ,1 + ,141 + ,17547 + ,3 + ,69 + ,3926 + ,3 + ,45 + ,1111 + ,118589 + ,102 + ,301 + ,52789 + ,35 + ,0 + ,29 + ,969 + ,0 + ,0 + ,0 + ,0 + ,34 + ,2011 + ,233108 + ,53 + ,668 + ,100350 + ,80) + ,dim=c(7 + ,164) + ,dimnames=list(c('reviews' + ,'pgviews' + ,'timerfc' + ,'prview' + ,'compview' + ,'char' + ,'hyper ') + ,1:164)) > y <- array(NA,dim=c(7,164),dimnames=list(c('reviews','pgviews','timerfc','prview','compview','char','hyper '),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' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. Ian E. Holliday > #To cite this work: Ian E. Holliday, 2009, YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: > #Technical description: > 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] "reviews" > x[,par1] [1] 41 34 44 38 27 35 33 18 34 33 46 57 37 55 44 62 40 39 32 51 49 39 25 56 45 [26] 38 45 43 32 41 50 50 51 37 44 42 44 36 17 43 41 41 38 49 45 42 26 52 50 45 [51] 40 4 44 18 14 38 61 39 42 40 51 28 43 42 37 30 39 44 36 28 47 23 48 38 42 [76] 46 37 41 42 41 36 45 26 44 8 27 38 38 57 45 40 42 31 36 40 40 35 39 65 33 [101] 51 42 36 19 25 44 40 44 30 45 42 45 1 40 11 45 38 0 30 8 41 48 48 32 8 [126] 43 52 53 49 48 56 40 36 44 46 43 46 39 41 46 32 45 39 21 49 55 36 48 0 0 [151] 0 0 0 0 43 52 0 0 0 5 1 45 0 34 > 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 4 5 8 11 14 17 18 19 21 23 25 26 27 28 30 31 32 33 34 35 36 37 38 39 11 2 1 1 3 1 1 1 2 1 1 1 2 2 2 2 3 1 4 3 3 2 7 4 8 7 40 41 42 43 44 45 46 47 48 49 50 51 52 53 55 56 57 61 62 65 9 8 9 6 10 11 5 1 5 4 3 4 3 1 2 2 2 1 1 1 > colnames(x) [1] "reviews" "pgviews" "timerfc" "prview" "compview" "char" "hyper." > colnames(x)[par1] [1] "reviews" > x[,par1] [1] 41 34 44 38 27 35 33 18 34 33 46 57 37 55 44 62 40 39 32 51 49 39 25 56 45 [26] 38 45 43 32 41 50 50 51 37 44 42 44 36 17 43 41 41 38 49 45 42 26 52 50 45 [51] 40 4 44 18 14 38 61 39 42 40 51 28 43 42 37 30 39 44 36 28 47 23 48 38 42 [76] 46 37 41 42 41 36 45 26 44 8 27 38 38 57 45 40 42 31 36 40 40 35 39 65 33 [101] 51 42 36 19 25 44 40 44 30 45 42 45 1 40 11 45 38 0 30 8 41 48 48 32 8 [126] 43 52 53 49 48 56 40 36 44 46 43 46 39 41 46 32 45 39 21 49 55 36 48 0 0 [151] 0 0 0 0 43 52 0 0 0 5 1 45 0 34 > 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/1cmyr1324655728.tab") + } + } > m Conditional inference tree with 6 terminal nodes Response: reviews Inputs: pgviews, timerfc, prview, compview, char, hyper. Number of observations: 164 1) timerfc <= 80953; criterion = 1, statistic = 91.925 2) prview <= 20; criterion = 1, statistic = 17.799 3)* weights = 15 2) prview > 20 4)* weights = 10 1) timerfc > 80953 5) timerfc <= 237561; criterion = 1, statistic = 22.195 6) hyper. <= 41; criterion = 0.983, statistic = 8.863 7)* weights = 8 6) hyper. > 41 8) prview <= 63; criterion = 0.969, statistic = 7.798 9)* weights = 21 8) prview > 63 10)* weights = 28 5) timerfc > 237561 11)* weights = 82 > postscript(file="/var/wessaorg/rcomp/tmp/209yc1324655728.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/35j5y1324655728.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 41 44.2682927 -3.2682927 2 34 35.0476190 -1.0476190 3 44 35.0476190 8.9523810 4 38 41.5357143 -3.5357143 5 27 35.0476190 -8.0476190 6 35 17.4000000 17.6000000 7 33 44.2682927 -11.2682927 8 18 17.4000000 0.6000000 9 34 41.5357143 -7.5357143 10 33 41.5357143 -8.5357143 11 46 44.2682927 1.7317073 12 57 44.2682927 12.7317073 13 37 35.0476190 1.9523810 14 55 44.2682927 10.7317073 15 44 44.2682927 -0.2682927 16 62 44.2682927 17.7317073 17 40 44.2682927 -4.2682927 18 39 44.2682927 -5.2682927 19 32 35.0476190 -3.0476190 20 51 44.2682927 6.7317073 21 49 44.2682927 4.7317073 22 39 44.2682927 -5.2682927 23 25 35.0476190 -10.0476190 24 56 41.5357143 14.4642857 25 45 44.2682927 0.7317073 26 38 44.2682927 -6.2682927 27 45 44.2682927 0.7317073 28 43 44.2682927 -1.2682927 29 32 35.0476190 -3.0476190 30 41 44.2682927 -3.2682927 31 50 44.2682927 5.7317073 32 50 44.2682927 5.7317073 33 51 44.2682927 6.7317073 34 37 28.7500000 8.2500000 35 44 44.2682927 -0.2682927 36 42 44.2682927 -2.2682927 37 44 44.2682927 -0.2682927 38 36 41.5357143 -5.5357143 39 17 28.7500000 -11.7500000 40 43 44.2682927 -1.2682927 41 41 44.2682927 -3.2682927 42 41 41.5357143 -0.5357143 43 38 41.5357143 -3.5357143 44 49 41.5357143 7.4642857 45 45 41.5357143 3.4642857 46 42 44.2682927 -2.2682927 47 26 17.4000000 8.6000000 48 52 41.5357143 10.4642857 49 50 44.2682927 5.7317073 50 45 41.5357143 3.4642857 51 40 35.0476190 4.9523810 52 4 0.7333333 3.2666667 53 44 44.2682927 -0.2682927 54 18 17.4000000 0.6000000 55 14 28.7500000 -14.7500000 56 38 44.2682927 -6.2682927 57 61 44.2682927 16.7317073 58 39 44.2682927 -5.2682927 59 42 44.2682927 -2.2682927 60 40 44.2682927 -4.2682927 61 51 44.2682927 6.7317073 62 28 44.2682927 -16.2682927 63 43 44.2682927 -1.2682927 64 42 44.2682927 -2.2682927 65 37 35.0476190 1.9523810 66 30 35.0476190 -5.0476190 67 39 35.0476190 3.9523810 68 44 44.2682927 -0.2682927 69 36 44.2682927 -8.2682927 70 28 35.0476190 -7.0476190 71 47 44.2682927 2.7317073 72 23 17.4000000 5.6000000 73 48 44.2682927 3.7317073 74 38 41.5357143 -3.5357143 75 42 41.5357143 0.4642857 76 46 44.2682927 1.7317073 77 37 44.2682927 -7.2682927 78 41 35.0476190 5.9523810 79 42 35.0476190 6.9523810 80 41 41.5357143 -0.5357143 81 36 35.0476190 0.9523810 82 45 44.2682927 0.7317073 83 26 28.7500000 -2.7500000 84 44 44.2682927 -0.2682927 85 8 17.4000000 -9.4000000 86 27 28.7500000 -1.7500000 87 38 41.5357143 -3.5357143 88 38 44.2682927 -6.2682927 89 57 44.2682927 12.7317073 90 45 41.5357143 3.4642857 91 40 44.2682927 -4.2682927 92 42 44.2682927 -2.2682927 93 31 41.5357143 -10.5357143 94 36 44.2682927 -8.2682927 95 40 44.2682927 -4.2682927 96 40 41.5357143 -1.5357143 97 35 44.2682927 -9.2682927 98 39 44.2682927 -5.2682927 99 65 44.2682927 20.7317073 100 33 44.2682927 -11.2682927 101 51 44.2682927 6.7317073 102 42 44.2682927 -2.2682927 103 36 41.5357143 -5.5357143 104 19 17.4000000 1.6000000 105 25 41.5357143 -16.5357143 106 44 44.2682927 -0.2682927 107 40 44.2682927 -4.2682927 108 44 44.2682927 -0.2682927 109 30 35.0476190 -5.0476190 110 45 41.5357143 3.4642857 111 42 44.2682927 -2.2682927 112 45 44.2682927 0.7317073 113 1 0.7333333 0.2666667 114 40 35.0476190 4.9523810 115 11 17.4000000 -6.4000000 116 45 41.5357143 3.4642857 117 38 44.2682927 -6.2682927 118 0 0.7333333 -0.7333333 119 30 44.2682927 -14.2682927 120 8 17.4000000 -9.4000000 121 41 44.2682927 -3.2682927 122 48 44.2682927 3.7317073 123 48 41.5357143 6.4642857 124 32 35.0476190 -3.0476190 125 8 17.4000000 -9.4000000 126 43 41.5357143 1.4642857 127 52 44.2682927 7.7317073 128 53 41.5357143 11.4642857 129 49 44.2682927 4.7317073 130 48 44.2682927 3.7317073 131 56 44.2682927 11.7317073 132 40 35.0476190 4.9523810 133 36 35.0476190 0.9523810 134 44 44.2682927 -0.2682927 135 46 44.2682927 1.7317073 136 43 28.7500000 14.2500000 137 46 44.2682927 1.7317073 138 39 41.5357143 -2.5357143 139 41 44.2682927 -3.2682927 140 46 44.2682927 1.7317073 141 32 41.5357143 -9.5357143 142 45 44.2682927 0.7317073 143 39 44.2682927 -5.2682927 144 21 28.7500000 -7.7500000 145 49 44.2682927 4.7317073 146 55 41.5357143 13.4642857 147 36 44.2682927 -8.2682927 148 48 44.2682927 3.7317073 149 0 0.7333333 -0.7333333 150 0 0.7333333 -0.7333333 151 0 0.7333333 -0.7333333 152 0 0.7333333 -0.7333333 153 0 0.7333333 -0.7333333 154 0 0.7333333 -0.7333333 155 43 44.2682927 -1.2682927 156 52 44.2682927 7.7317073 157 0 0.7333333 -0.7333333 158 0 0.7333333 -0.7333333 159 0 0.7333333 -0.7333333 160 5 0.7333333 4.2666667 161 1 0.7333333 0.2666667 162 45 28.7500000 16.2500000 163 0 0.7333333 -0.7333333 164 34 35.0476190 -1.0476190 > 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/414kf1324655728.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/5pjtv1324655728.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/6veva1324655728.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/7m6u21324655728.tab") + } > > try(system("convert tmp/209yc1324655728.ps tmp/209yc1324655728.png",intern=TRUE)) character(0) > try(system("convert tmp/35j5y1324655728.ps tmp/35j5y1324655728.png",intern=TRUE)) character(0) > try(system("convert tmp/414kf1324655728.ps tmp/414kf1324655728.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.679 0.290 3.968