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(140824 + ,186099 + ,32033 + ,165 + ,165 + ,130 + ,279055 + ,110459 + ,113854 + ,20654 + ,135 + ,132 + ,143 + ,212408 + ,105079 + ,99776 + ,16346 + ,121 + ,121 + ,118 + ,233939 + ,112098 + ,106194 + ,35926 + ,148 + ,145 + ,146 + ,222117 + ,43929 + ,100792 + ,10621 + ,73 + ,71 + ,73 + ,179751 + ,76173 + ,47552 + ,10024 + ,49 + ,47 + ,89 + ,70849 + ,187326 + ,250931 + ,43068 + ,185 + ,177 + ,146 + ,599777 + ,22807 + ,6853 + ,1271 + ,5 + ,5 + ,22 + ,33186 + ,144408 + ,115466 + ,34416 + ,125 + ,124 + ,132 + ,227332 + ,66485 + ,110896 + ,20318 + ,93 + ,92 + ,92 + ,258874 + ,79089 + ,169351 + ,24409 + ,154 + ,149 + ,147 + ,359064 + ,81625 + ,94853 + ,20648 + ,98 + ,93 + ,203 + ,264989 + ,68788 + ,72591 + ,12347 + ,70 + ,70 + ,113 + ,209202 + ,103297 + ,101345 + ,21857 + ,148 + ,148 + ,171 + ,368577 + ,69446 + ,113713 + ,11034 + ,100 + ,100 + ,87 + ,269455 + ,114948 + ,165354 + ,33433 + ,150 + ,142 + ,208 + ,397286 + ,167949 + ,164263 + ,35902 + ,197 + ,194 + ,153 + ,335567 + ,125081 + ,135213 + ,22355 + ,114 + ,113 + ,97 + ,428322 + ,125818 + ,111669 + ,31219 + ,169 + ,162 + ,95 + ,182016 + ,136588 + ,134163 + ,21983 + ,200 + ,186 + ,197 + ,267365 + ,112431 + ,140303 + ,40085 + ,148 + ,147 + ,160 + ,279428 + ,103037 + ,150773 + ,18507 + ,140 + ,137 + ,148 + ,508849 + ,82317 + ,111848 + ,16278 + ,74 + ,71 + ,84 + ,206722 + ,118906 + ,102509 + ,24662 + ,128 + ,123 + ,227 + ,200004 + ,83515 + ,96785 + ,31452 + ,140 + ,134 + ,154 + ,257139 + ,104581 + ,116136 + ,32580 + ,116 + ,115 + ,151 + ,270941 + ,103129 + ,158376 + ,22883 + ,147 + ,138 + ,142 + ,296850 + ,83243 + ,153990 + ,27652 + ,132 + ,125 + ,148 + ,329962 + ,37110 + ,64057 + ,9845 + ,70 + ,66 + ,110 + ,187155 + ,113344 + ,230054 + ,20190 + ,144 + ,137 + ,149 + ,393860 + ,139165 + ,184531 + ,46201 + ,155 + ,152 + ,179 + ,327660 + ,86652 + ,114198 + ,10971 + ,165 + ,159 + ,149 + ,269239 + ,112302 + ,198299 + ,34811 + ,161 + ,159 + ,187 + ,386982 + ,69652 + ,33750 + ,3029 + ,31 + ,31 + ,153 + ,130446 + ,119442 + ,189723 + ,38941 + ,199 + ,185 + ,163 + ,430118 + ,69867 + ,100826 + ,4958 + ,78 + ,78 + ,127 + ,273950 + ,101629 + ,188355 + ,32344 + ,121 + ,117 + ,151 + ,428077 + ,70168 + ,104470 + ,19433 + ,112 + ,109 + ,100 + ,254312 + ,31081 + ,58391 + ,12558 + ,41 + ,41 + ,46 + ,120351 + ,103925 + ,164808 + ,36524 + ,158 + ,149 + ,156 + ,395643 + ,92622 + ,134097 + ,26041 + ,123 + ,123 + ,128 + ,345875 + ,79011 + ,80238 + ,16637 + ,104 + ,103 + ,111 + ,212715 + ,93487 + ,133252 + ,28395 + ,94 + ,87 + ,119 + ,224524 + ,64520 + ,54518 + ,16747 + ,73 + ,71 + ,148 + ,182485 + ,93473 + ,121850 + ,9105 + ,52 + ,51 + ,65 + ,157164 + ,114360 + ,79367 + ,11941 + ,71 + ,70 + ,134 + ,459455 + ,33032 + ,56968 + ,7935 + ,21 + ,21 + ,66 + ,78800 + ,96125 + ,106314 + ,19499 + ,155 + ,155 + ,201 + ,217932 + ,151911 + ,191889 + ,22938 + ,174 + ,172 + ,177 + ,368086 + ,89256 + ,104864 + ,25314 + ,136 + ,133 + ,156 + ,228688 + ,95676 + ,160792 + ,28527 + ,128 + ,125 + ,158 + ,244765 + ,5950 + ,15049 + ,2694 + ,7 + ,7 + ,7 + ,24188 + ,149695 + ,191179 + ,20867 + ,165 + ,158 + ,175 + ,400109 + ,32551 + ,25109 + ,3597 + ,21 + ,21 + ,61 + ,65029 + ,31701 + ,45824 + ,5296 + ,35 + ,35 + ,41 + ,101097 + ,100087 + ,129711 + ,32982 + ,137 + ,133 + ,133 + ,305666 + ,169707 + ,210012 + ,38975 + ,174 + ,169 + ,228 + ,369627 + ,150491 + ,194679 + ,42721 + ,257 + ,256 + ,140 + ,367127 + ,120192 + ,197680 + ,41455 + ,207 + ,190 + ,155 + ,377704 + ,95893 + ,81180 + ,23923 + ,103 + ,100 + ,141 + ,280106 + ,151715 + ,197765 + ,26719 + ,171 + ,171 + ,181 + ,400971 + ,176225 + ,214738 + ,53405 + ,279 + ,267 + ,75 + ,315924 + ,59900 + ,96252 + ,12526 + ,83 + ,80 + ,97 + ,291391 + ,104767 + ,124527 + ,26584 + ,130 + ,126 + ,142 + ,295075 + ,114799 + ,153242 + ,37062 + ,131 + ,132 + ,136 + ,280018 + ,72128 + ,145707 + ,25696 + ,126 + ,121 + ,87 + ,267432 + ,143592 + ,113963 + ,24634 + ,158 + ,156 + ,140 + ,217181 + ,89626 + ,134904 + ,27269 + ,138 + ,133 + ,169 + ,258166 + ,131072 + ,114268 + ,25270 + ,200 + ,199 + ,129 + ,260919 + ,126817 + ,94333 + ,24634 + ,104 + ,98 + ,92 + ,182961 + ,81351 + ,102204 + ,17828 + ,111 + ,109 + ,160 + ,256967 + ,22618 + ,23824 + ,3007 + ,26 + ,25 + ,67 + ,73566 + ,88977 + ,111563 + ,20065 + ,115 + ,113 + ,179 + ,272362 + ,92059 + ,91313 + ,24648 + ,127 + ,126 + ,90 + ,229056 + ,81897 + ,89770 + ,21588 + ,140 + ,137 + ,144 + ,229851 + ,108146 + ,100125 + ,25217 + ,121 + ,121 + ,144 + ,371391 + ,126372 + ,165278 + ,30927 + ,183 + ,178 + ,144 + ,398210 + ,249771 + ,181712 + ,18487 + ,68 + ,63 + ,134 + ,220419 + ,71154 + ,80906 + ,18050 + ,112 + ,109 + ,146 + ,231884 + ,71571 + ,75881 + ,17696 + ,103 + ,101 + ,121 + ,217714 + ,55918 + ,83963 + ,17326 + ,63 + ,61 + ,112 + ,200046 + ,160141 + ,175721 + ,39361 + ,166 + ,157 + ,145 + ,483074 + ,38692 + ,68580 + ,9648 + ,38 + ,38 + ,99 + ,145943 + ,102812 + ,136323 + ,26759 + ,163 + ,159 + ,96 + ,295224 + ,56622 + ,55792 + ,7905 + ,59 + ,58 + ,27 + ,80953 + ,15986 + ,25157 + ,4527 + ,27 + ,27 + ,77 + ,217384 + ,123534 + ,100922 + ,41517 + ,108 + ,108 + ,137 + ,179344 + ,108535 + ,118845 + ,21261 + ,88 + ,83 + ,151 + ,415550 + ,93879 + ,170492 + ,36099 + ,92 + ,88 + ,126 + ,389059 + ,144551 + ,81716 + ,39039 + ,170 + ,164 + ,159 + ,180679 + ,56750 + ,115750 + ,13841 + ,98 + ,96 + ,101 + ,299505 + ,127654 + ,105590 + ,23841 + ,205 + ,192 + ,144 + ,292260 + ,65594 + ,92795 + ,8589 + ,96 + ,94 + ,102 + ,199481 + ,59938 + ,82390 + ,15049 + ,107 + ,107 + ,135 + ,282361 + ,146975 + ,135599 + ,39038 + ,150 + ,144 + ,147 + ,329281 + ,165904 + ,127667 + ,36774 + ,138 + ,136 + ,155 + ,234577 + ,169265 + ,163073 + ,40076 + ,177 + ,171 + ,138 + ,297995 + ,183500 + ,211381 + ,43840 + ,213 + ,210 + ,113 + ,329583 + ,165986 + ,189944 + ,43146 + ,208 + ,193 + ,248 + ,416463 + ,184923 + ,226168 + ,50099 + ,307 + ,297 + ,116 + ,415683 + ,140358 + ,117495 + ,40312 + ,125 + ,125 + ,176 + ,297080 + ,149959 + ,195894 + ,32616 + ,208 + ,204 + ,140 + ,318283 + ,57224 + ,80684 + ,11338 + ,73 + ,70 + ,59 + ,224033 + ,43750 + ,19630 + ,7409 + ,49 + ,49 + ,64 + ,43287 + ,48029 + ,88634 + ,18213 + ,82 + ,82 + ,40 + ,238089 + ,104978 + ,139292 + ,45873 + ,206 + ,205 + ,98 + ,263322 + ,100046 + ,128602 + ,39844 + ,112 + ,111 + ,139 + ,299566 + ,101047 + ,135848 + ,28317 + ,139 + ,135 + ,135 + ,321797 + ,197426 + ,178377 + ,24797 + ,60 + ,59 + ,97 + ,193926 + ,160902 + ,106330 + ,7471 + ,70 + ,70 + ,142 + ,170491 + ,147172 + ,178303 + ,27259 + ,112 + ,108 + ,155 + ,354041 + ,109432 + ,116938 + ,23201 + ,142 + ,141 + ,115 + ,303273 + ,1168 + ,5841 + ,238 + ,11 + ,11 + ,0 + ,23668 + ,83248 + ,106020 + ,28830 + ,130 + ,130 + ,103 + ,196743 + ,25162 + ,24610 + ,3913 + ,31 + ,28 + ,30 + ,61857 + ,45724 + ,74151 + ,9935 + ,132 + ,101 + ,130 + ,217543 + ,110529 + ,232241 + ,27738 + ,219 + ,216 + ,102 + ,440711 + ,855 + ,6622 + ,338 + ,4 + ,4 + ,0 + ,21054 + ,101382 + ,127097 + ,13326 + ,102 + ,97 + ,77 + ,252805 + ,14116 + ,13155 + ,3988 + ,39 + ,39 + ,9 + ,31961 + ,89506 + ,160501 + ,24347 + ,125 + ,119 + ,150 + ,360436 + ,135356 + ,91502 + ,27111 + ,121 + ,118 + ,163 + ,251948 + ,116066 + ,24469 + ,3938 + ,42 + ,41 + ,148 + ,187003 + ,144244 + ,88229 + ,17416 + ,111 + ,107 + ,94 + ,180842 + ,8773 + ,13983 + ,1888 + ,16 + ,16 + ,21 + ,38214 + ,102153 + ,80716 + ,18700 + ,70 + ,69 + ,151 + ,278173 + ,117440 + ,157384 + ,36809 + ,162 + ,160 + ,187 + ,358276 + ,104128 + ,122975 + ,24959 + ,173 + ,158 + ,171 + ,211775 + ,134238 + ,191469 + ,37343 + ,171 + ,161 + ,170 + ,445926 + ,134047 + ,231257 + ,21849 + ,172 + ,165 + ,145 + ,348017 + ,279488 + ,258287 + ,49809 + ,254 + ,246 + ,198 + ,441946 + ,79756 + ,122531 + ,21654 + ,90 + ,89 + ,152 + ,215177 + ,66089 + ,61394 + ,8728 + ,50 + ,49 + ,112 + ,126320 + ,102070 + ,86480 + ,20920 + ,113 + ,107 + ,173 + ,316128 + ,146760 + ,195791 + ,27195 + ,187 + ,182 + ,177 + ,466139 + ,154771 + ,18284 + ,1037 + ,16 + ,16 + ,153 + ,162279 + ,165933 + ,147581 + ,42570 + ,175 + ,173 + ,161 + ,416643 + ,64593 + ,72558 + ,17672 + ,90 + ,90 + ,115 + ,178322 + ,92280 + ,147341 + ,34245 + ,140 + ,140 + ,147 + ,292443 + ,67150 + ,114651 + ,16786 + ,145 + ,142 + ,124 + ,283913 + ,128692 + ,100187 + ,20954 + ,141 + ,126 + ,57 + ,244802 + ,124089 + ,130332 + ,16378 + ,125 + ,123 + ,144 + ,387072 + ,125386 + ,134218 + ,31852 + ,241 + ,239 + ,126 + ,246963 + ,37238 + ,10901 + ,2805 + ,16 + ,15 + ,78 + ,173260 + ,140015 + ,145758 + ,38086 + ,175 + ,170 + ,153 + ,346748 + ,150047 + ,75767 + ,21166 + ,132 + ,123 + ,196 + ,176654 + ,154451 + ,134969 + ,34672 + ,154 + ,151 + ,130 + ,267742 + ,156349 + ,169216 + ,36171 + ,198 + ,194 + ,159 + ,314070) + ,dim=c(7 + ,148) + ,dimnames=list(c('Y1' + ,'X1' + ,'X2' + ,'X3' + ,'X4' + ,'X5' + ,'X6') + ,1:148)) > y <- array(NA,dim=c(7,148),dimnames=list(c('Y1','X1','X2','X3','X4','X5','X6'),1:148)) > 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 = 'equal' > 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] "Y1" > x[,par1] [1] 140824 110459 105079 112098 43929 76173 187326 22807 144408 66485 [11] 79089 81625 68788 103297 69446 114948 167949 125081 125818 136588 [21] 112431 103037 82317 118906 83515 104581 103129 83243 37110 113344 [31] 139165 86652 112302 69652 119442 69867 101629 70168 31081 103925 [41] 92622 79011 93487 64520 93473 114360 33032 96125 151911 89256 [51] 95676 5950 149695 32551 31701 100087 169707 150491 120192 95893 [61] 151715 176225 59900 104767 114799 72128 143592 89626 131072 126817 [71] 81351 22618 88977 92059 81897 108146 126372 249771 71154 71571 [81] 55918 160141 38692 102812 56622 15986 123534 108535 93879 144551 [91] 56750 127654 65594 59938 146975 165904 169265 183500 165986 184923 [101] 140358 149959 57224 43750 48029 104978 100046 101047 197426 160902 [111] 147172 109432 1168 83248 25162 45724 110529 855 101382 14116 [121] 89506 135356 116066 144244 8773 102153 117440 104128 134238 134047 [131] 279488 79756 66089 102070 146760 154771 165933 64593 92280 67150 [141] 128692 124089 125386 37238 140015 150047 154451 156349 > 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]) C1 C2 C3 61 83 4 > colnames(x) [1] "Y1" "X1" "X2" "X3" "X4" "X5" "X6" > colnames(x)[par1] [1] "Y1" > x[,par1] [1] C2 C2 C2 C2 C1 C1 C3 C1 C2 C1 C1 C1 C1 C2 C1 C2 C2 C2 C2 C2 C2 C2 C1 C2 C1 [26] C2 C2 C1 C1 C2 C2 C1 C2 C1 C2 C1 C2 C1 C1 C2 C1 C1 C1 C1 C1 C2 C1 C2 C2 C1 [51] C2 C1 C2 C1 C1 C2 C2 C2 C2 C2 C2 C2 C1 C2 C2 C1 C2 C1 C2 C2 C1 C1 C1 C1 C1 [76] C2 C2 C3 C1 C1 C1 C2 C1 C2 C1 C1 C2 C2 C2 C2 C1 C2 C1 C1 C2 C2 C2 C2 C2 C2 [101] C2 C2 C1 C1 C1 C2 C2 C2 C3 C2 C2 C2 C1 C1 C1 C1 C2 C1 C2 C1 C1 C2 C2 C2 C1 [126] C2 C2 C2 C2 C2 C3 C1 C1 C2 C2 C2 C2 C1 C1 C1 C2 C2 C2 C1 C2 C2 C2 C2 Levels: C1 C2 C3 > 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/11rz11324650421.tab") + } + } > m Conditional inference tree with 4 terminal nodes Response: as.factor(Y1) Inputs: X1, X2, X3, X4, X5, X6 Number of observations: 148 1) X2 <= 18213; criterion = 1, statistic = 57.008 2)* weights = 51 1) X2 > 18213 3) X1 <= 178303; criterion = 0.998, statistic = 16.586 4) X3 <= 140; criterion = 0.958, statistic = 7.261 5)* weights = 42 4) X3 > 140 6)* weights = 30 3) X1 > 178303 7)* weights = 25 > postscript(file="/var/wessaorg/rcomp/tmp/2qun11324650421.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/3p1881324650421.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) + } > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } [,1] [,2] [1,] 2 2 [2,] 2 2 [3,] 2 1 [4,] 2 2 [5,] 1 1 [6,] 1 1 [7,] 3 2 [8,] 1 1 [9,] 2 2 [10,] 1 2 [11,] 1 2 [12,] 1 2 [13,] 1 1 [14,] 2 2 [15,] 1 1 [16,] 2 2 [17,] 2 2 [18,] 2 2 [19,] 2 2 [20,] 2 2 [21,] 2 2 [22,] 2 2 [23,] 1 1 [24,] 2 2 [25,] 1 2 [26,] 2 2 [27,] 2 2 [28,] 1 2 [29,] 1 1 [30,] 2 2 [31,] 2 2 [32,] 1 1 [33,] 2 2 [34,] 1 1 [35,] 2 2 [36,] 1 1 [37,] 2 2 [38,] 1 2 [39,] 1 1 [40,] 2 2 [41,] 1 2 [42,] 1 1 [43,] 1 2 [44,] 1 1 [45,] 1 1 [46,] 2 1 [47,] 1 1 [48,] 2 2 [49,] 2 2 [50,] 1 2 [51,] 2 2 [52,] 1 1 [53,] 2 2 [54,] 1 1 [55,] 1 1 [56,] 2 2 [57,] 2 2 [58,] 2 2 [59,] 2 2 [60,] 2 2 [61,] 2 2 [62,] 2 2 [63,] 1 1 [64,] 2 2 [65,] 2 2 [66,] 1 2 [67,] 2 2 [68,] 1 2 [69,] 2 2 [70,] 2 2 [71,] 1 1 [72,] 1 1 [73,] 1 2 [74,] 1 2 [75,] 1 2 [76,] 2 2 [77,] 2 2 [78,] 3 2 [79,] 1 1 [80,] 1 1 [81,] 1 1 [82,] 2 2 [83,] 1 1 [84,] 2 2 [85,] 1 1 [86,] 1 1 [87,] 2 2 [88,] 2 2 [89,] 2 2 [90,] 2 2 [91,] 1 1 [92,] 2 2 [93,] 1 1 [94,] 1 1 [95,] 2 2 [96,] 2 2 [97,] 2 2 [98,] 2 2 [99,] 2 2 [100,] 2 2 [101,] 2 2 [102,] 2 2 [103,] 1 1 [104,] 1 1 [105,] 1 1 [106,] 2 2 [107,] 2 2 [108,] 2 2 [109,] 3 2 [110,] 2 1 [111,] 2 2 [112,] 2 2 [113,] 1 1 [114,] 1 2 [115,] 1 1 [116,] 1 1 [117,] 2 2 [118,] 1 1 [119,] 2 1 [120,] 1 1 [121,] 1 2 [122,] 2 2 [123,] 2 1 [124,] 2 1 [125,] 1 1 [126,] 2 2 [127,] 2 2 [128,] 2 2 [129,] 2 2 [130,] 2 2 [131,] 3 2 [132,] 1 2 [133,] 1 1 [134,] 2 2 [135,] 2 2 [136,] 2 1 [137,] 2 2 [138,] 1 1 [139,] 1 2 [140,] 1 1 [141,] 2 2 [142,] 2 1 [143,] 2 2 [144,] 1 1 [145,] 2 2 [146,] 2 2 [147,] 2 2 [148,] 2 2 C1 C2 C3 C1 43 18 0 C2 8 75 0 C3 0 4 0 > postscript(file="/var/wessaorg/rcomp/tmp/4n5ns1324650421.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/56ypz1324650421.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/691nv1324650421.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/728z41324650421.tab") + } > > try(system("convert tmp/2qun11324650421.ps tmp/2qun11324650421.png",intern=TRUE)) character(0) > try(system("convert tmp/3p1881324650421.ps tmp/3p1881324650421.png",intern=TRUE)) character(0) > try(system("convert tmp/4n5ns1324650421.ps tmp/4n5ns1324650421.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.903 0.297 3.264