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(293403 + ,111 + ,74 + ,91256 + ,123 + ,119 + ,277108 + ,70 + ,69 + ,86997 + ,64 + ,64 + ,264020 + ,76 + ,76 + ,55709 + ,101 + ,100 + ,260646 + ,109 + ,60 + ,75741 + ,104 + ,104 + ,246100 + ,81 + ,89 + ,92046 + ,135 + ,135 + ,244051 + ,67 + ,111 + ,84607 + ,130 + ,124 + ,241329 + ,54 + ,57 + ,73586 + ,93 + ,93 + ,234730 + ,106 + ,116 + ,162365 + ,159 + ,155 + ,234509 + ,125 + ,122 + ,70817 + ,125 + ,120 + ,233482 + ,68 + ,90 + ,59635 + ,81 + ,78 + ,233406 + ,96 + ,85 + ,109104 + ,117 + ,117 + ,228548 + ,106 + ,65 + ,120087 + ,205 + ,198 + ,223914 + ,104 + ,89 + ,72631 + ,115 + ,110 + ,223696 + ,88 + ,82 + ,104911 + ,115 + ,114 + ,223004 + ,87 + ,84 + ,85224 + ,147 + ,137 + ,213765 + ,84 + ,56 + ,58233 + ,150 + ,150 + ,210554 + ,81 + ,73 + ,117986 + ,126 + ,124 + ,202204 + ,44 + ,79 + ,67271 + ,61 + ,56 + ,199512 + ,75 + ,59 + ,55071 + ,82 + ,82 + ,195304 + ,93 + ,47 + ,114425 + ,152 + ,145 + ,191467 + ,76 + ,75 + ,79194 + ,109 + ,104 + ,191381 + ,87 + ,71 + ,101653 + ,210 + ,212 + ,191276 + ,112 + ,90 + ,81493 + ,151 + ,141 + ,190410 + ,84 + ,107 + ,64664 + ,96 + ,94 + ,188967 + ,86 + ,75 + ,63717 + ,98 + ,94 + ,188780 + ,98 + ,85 + ,72369 + ,98 + ,98 + ,185139 + ,121 + ,83 + ,86281 + ,128 + ,126 + ,185039 + ,94 + ,73 + ,63958 + ,100 + ,98 + ,184217 + ,69 + ,45 + ,73795 + ,74 + ,74 + ,181853 + ,87 + ,93 + ,96750 + ,92 + ,91 + ,181379 + ,92 + ,123 + ,83038 + ,101 + ,96 + ,181344 + ,75 + ,114 + ,65196 + ,109 + ,108 + ,179562 + ,76 + ,89 + ,62932 + ,116 + ,116 + ,178863 + ,86 + ,78 + ,57637 + ,88 + ,87 + ,178140 + ,56 + ,91 + ,70111 + ,83 + ,78 + ,176789 + ,115 + ,66 + ,123328 + ,149 + ,149 + ,176460 + ,97 + ,55 + ,38885 + ,122 + ,122 + ,175877 + ,95 + ,81 + ,54628 + ,96 + ,95 + ,175568 + ,106 + ,80 + ,74482 + ,105 + ,102 + ,174107 + ,49 + ,71 + ,76168 + ,95 + ,91 + ,173587 + ,70 + ,70 + ,71170 + ,97 + ,95 + ,173260 + ,41 + ,78 + ,37238 + ,16 + ,15 + ,172684 + ,87 + ,112 + ,101773 + ,103 + ,102 + ,167845 + ,105 + ,77 + ,103646 + ,145 + ,145 + ,167131 + ,71 + ,69 + ,37048 + ,56 + ,56 + ,167105 + ,56 + ,32 + ,85903 + ,75 + ,71 + ,166790 + ,49 + ,59 + ,43460 + ,46 + ,46 + ,164767 + ,51 + ,87 + ,90257 + ,81 + ,80 + ,162810 + ,49 + ,76 + ,70027 + ,83 + ,80 + ,162336 + ,111 + ,84 + ,111436 + ,153 + ,151 + ,161678 + ,75 + ,59 + ,65911 + ,87 + ,83 + ,158980 + ,84 + ,75 + ,105965 + ,123 + ,122 + ,157250 + ,84 + ,106 + ,61704 + ,104 + ,104 + ,156833 + ,79 + ,73 + ,48204 + ,85 + ,85 + ,155383 + ,83 + ,75 + ,60029 + ,99 + ,99 + ,154991 + ,63 + ,87 + ,52295 + ,99 + ,98 + ,154730 + ,78 + ,82 + ,82204 + ,98 + ,98 + ,151503 + ,93 + ,83 + ,56316 + ,99 + ,98 + ,146455 + ,65 + ,68 + ,95556 + ,127 + ,128 + ,143937 + ,98 + ,66 + ,78792 + ,140 + ,139 + ,142339 + ,75 + ,67 + ,125410 + ,144 + ,142 + ,142146 + ,108 + ,88 + ,76013 + ,152 + ,139 + ,142141 + ,73 + ,87 + ,91939 + ,61 + ,61 + ,142069 + ,66 + ,88 + ,57231 + ,83 + ,82 + ,141933 + ,90 + ,75 + ,51370 + ,100 + ,99 + ,139350 + ,70 + ,79 + ,99518 + ,89 + ,88 + ,139144 + ,57 + ,76 + ,56530 + ,75 + ,75 + ,137793 + ,70 + ,78 + ,56699 + ,77 + ,77 + ,136911 + ,95 + ,86 + ,74349 + ,117 + ,103 + ,136548 + ,89 + ,62 + ,83042 + ,158 + ,157 + ,135171 + ,80 + ,61 + ,71181 + ,82 + ,82 + ,134043 + ,54 + ,69 + ,55901 + ,57 + ,54 + ,131876 + ,27 + ,83 + ,38417 + ,36 + ,36 + ,131122 + ,56 + ,50 + ,65724 + ,89 + ,89 + ,130539 + ,60 + ,47 + ,48821 + ,66 + ,66 + ,130533 + ,64 + ,76 + ,85168 + ,78 + ,79 + ,130232 + ,102 + ,83 + ,55027 + ,107 + ,105 + ,129100 + ,38 + ,60 + ,73713 + ,87 + ,87 + ,128655 + ,75 + ,70 + ,79774 + ,111 + ,108 + ,128066 + ,42 + ,48 + ,42564 + ,80 + ,80 + ,127619 + ,49 + ,50 + ,36311 + ,52 + ,50 + ,127324 + ,79 + ,87 + ,56733 + ,104 + ,101 + ,126683 + ,71 + ,123 + ,63262 + ,72 + ,71 + ,126681 + ,39 + ,90 + ,94137 + ,67 + ,66 + ,125971 + ,61 + ,45 + ,38439 + ,71 + ,71 + ,125366 + ,69 + ,22 + ,34497 + ,68 + ,68 + ,122433 + ,51 + ,91 + ,58425 + ,66 + ,66 + ,121135 + ,50 + ,51 + ,42051 + ,69 + ,68 + ,119291 + ,83 + ,38 + ,64102 + ,123 + ,120 + ,118958 + ,52 + ,68 + ,54506 + ,61 + ,58 + ,118807 + ,56 + ,81 + ,55827 + ,70 + ,70 + ,118372 + ,72 + ,35 + ,66477 + ,142 + ,145 + ,116900 + ,42 + ,36 + ,28340 + ,58 + ,57 + ,116775 + ,30 + ,83 + ,73087 + ,124 + ,112 + ,115199 + ,84 + ,54 + ,51360 + ,87 + ,87 + ,114928 + ,44 + ,72 + ,53009 + ,96 + ,91 + ,114397 + ,70 + ,65 + ,55064 + ,87 + ,85 + ,113337 + ,58 + ,37 + ,63016 + ,68 + ,68 + ,111664 + ,55 + ,59 + ,38650 + ,98 + ,98 + ,108715 + ,64 + ,35 + ,40671 + ,80 + ,78 + ,107342 + ,77 + ,53 + ,82043 + ,116 + ,111 + ,107335 + ,48 + ,61 + ,49319 + ,65 + ,64 + ,106539 + ,36 + ,68 + ,77411 + ,63 + ,63 + ,105615 + ,57 + ,70 + ,202316 + ,51 + ,48 + ,105410 + ,62 + ,72 + ,89041 + ,88 + ,86 + ,105324 + ,42 + ,71 + ,26982 + ,46 + ,46 + ,103012 + ,30 + ,37 + ,29467 + ,28 + ,26 + ,102531 + ,46 + ,63 + ,40001 + ,64 + ,63 + ,101324 + ,81 + ,104 + ,70780 + ,103 + ,100 + ,100885 + ,39 + ,29 + ,49288 + ,49 + ,48 + ,100672 + ,38 + ,69 + ,50466 + ,55 + ,55 + ,99946 + ,106 + ,80 + ,99501 + ,125 + ,119 + ,99768 + ,24 + ,62 + ,15430 + ,27 + ,27 + ,99246 + ,27 + ,63 + ,37361 + ,52 + ,51 + ,98599 + ,48 + ,55 + ,36252 + ,46 + ,44 + ,98030 + ,30 + ,41 + ,31701 + ,35 + ,35 + ,94763 + ,94 + ,75 + ,56979 + ,100 + ,99 + ,93340 + ,41 + ,63 + ,43448 + ,60 + ,60 + ,93125 + ,30 + ,29 + ,50838 + ,37 + ,36 + ,91185 + ,57 + ,66 + ,21067 + ,67 + ,67 + ,90961 + ,42 + ,78 + ,63785 + ,49 + ,49 + ,90938 + ,40 + ,51 + ,37137 + ,43 + ,42 + ,89318 + ,75 + ,78 + ,44970 + ,82 + ,81 + ,88817 + ,70 + ,60 + ,46765 + ,56 + ,56 + ,84944 + ,54 + ,72 + ,54565 + ,90 + ,89 + ,84572 + ,43 + ,82 + ,72571 + ,84 + ,84 + ,84256 + ,97 + ,58 + ,59155 + ,76 + ,75 + ,80953 + ,49 + ,27 + ,56622 + ,59 + ,58 + ,78800 + ,20 + ,66 + ,33032 + ,21 + ,21 + ,78776 + ,30 + ,18 + ,26998 + ,34 + ,34 + ,75812 + ,28 + ,57 + ,35606 + ,30 + ,30 + ,75426 + ,3 + ,19 + ,47261 + ,36 + ,33 + ,74398 + ,41 + ,30 + ,31258 + ,51 + ,51 + ,74112 + ,28 + ,54 + ,174949 + ,52 + ,52 + ,73567 + ,37 + ,31 + ,23238 + ,18 + ,18 + ,69471 + ,22 + ,63 + ,22618 + ,26 + ,25 + ,68948 + ,31 + ,47 + ,35838 + ,45 + ,43 + ,67746 + ,18 + ,35 + ,62832 + ,58 + ,56 + ,67507 + ,101 + ,112 + ,78956 + ,49 + ,49 + ,65029 + ,21 + ,61 + ,32551 + ,21 + ,21 + ,64320 + ,16 + ,56 + ,62147 + ,24 + ,23 + ,61857 + ,23 + ,30 + ,25162 + ,31 + ,28 + ,61499 + ,28 + ,75 + ,36990 + ,15 + ,15 + ,50999 + ,2 + ,66 + ,63989 + ,8 + ,8 + ,46660 + ,12 + ,13 + ,6179 + ,13 + ,13 + ,43287 + ,13 + ,64 + ,43750 + ,49 + ,49 + ,38214 + ,16 + ,21 + ,8773 + ,16 + ,16 + ,35523 + ,0 + ,53 + ,52491 + ,33 + ,33 + ,32750 + ,1 + ,22 + ,22807 + ,5 + ,5 + ,31414 + ,18 + ,9 + ,14116 + ,39 + ,39 + ,24188 + ,8 + ,7 + ,5950 + ,7 + ,7 + ,22938 + ,12 + ,0 + ,1168 + ,11 + ,11 + ,21054 + ,4 + ,0 + ,855 + ,4 + ,4 + ,17547 + ,0 + ,4 + ,3926 + ,3 + ,3 + ,14688 + ,4 + ,0 + ,6023 + ,5 + ,5 + ,7199 + ,7 + ,0 + ,1644 + ,6 + ,6 + ,969 + ,0 + ,0 + ,0 + ,0 + ,0 + ,455 + ,0 + ,0 + ,0 + ,0 + ,0 + ,203 + ,0 + ,0 + ,0 + ,0 + ,0 + ,98 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0) + ,dim=c(6 + ,164) + ,dimnames=list(c('y' + ,'1' + ,'2' + ,'3' + ,'4' + ,'5') + ,1:164)) > y <- array(NA,dim=c(6,164),dimnames=list(c('y','1','2','3','4','5'),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 = '' > 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 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] "y" > x[,par1] [1] 293403 277108 264020 260646 246100 244051 241329 234730 234509 233482 [11] 233406 228548 223914 223696 223004 213765 210554 202204 199512 195304 [21] 191467 191381 191276 190410 188967 188780 185139 185039 184217 181853 [31] 181379 181344 179562 178863 178140 176789 176460 175877 175568 174107 [41] 173587 173260 172684 167845 167131 167105 166790 164767 162810 162336 [51] 161678 158980 157250 156833 155383 154991 154730 151503 146455 143937 [61] 142339 142146 142141 142069 141933 139350 139144 137793 136911 136548 [71] 135171 134043 131876 131122 130539 130533 130232 129100 128655 128066 [81] 127619 127324 126683 126681 125971 125366 122433 121135 119291 118958 [91] 118807 118372 116900 116775 115199 114928 114397 113337 111664 108715 [101] 107342 107335 106539 105615 105410 105324 103012 102531 101324 100885 [111] 100672 99946 99768 99246 98599 98030 94763 93340 93125 91185 [121] 90961 90938 89318 88817 84944 84572 84256 80953 78800 78776 [131] 75812 75426 74398 74112 73567 69471 68948 67746 67507 65029 [141] 64320 61857 61499 50999 46660 43287 38214 35523 32750 31414 [151] 24188 22938 21054 17547 14688 7199 969 455 203 98 [161] 0 0 0 0 > 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 98 203 455 969 7199 14688 17547 21054 22938 24188 4 1 1 1 1 1 1 1 1 1 1 31414 32750 35523 38214 43287 46660 50999 61499 61857 64320 65029 1 1 1 1 1 1 1 1 1 1 1 67507 67746 68948 69471 73567 74112 74398 75426 75812 78776 78800 1 1 1 1 1 1 1 1 1 1 1 80953 84256 84572 84944 88817 89318 90938 90961 91185 93125 93340 1 1 1 1 1 1 1 1 1 1 1 94763 98030 98599 99246 99768 99946 100672 100885 101324 102531 103012 1 1 1 1 1 1 1 1 1 1 1 105324 105410 105615 106539 107335 107342 108715 111664 113337 114397 114928 1 1 1 1 1 1 1 1 1 1 1 115199 116775 116900 118372 118807 118958 119291 121135 122433 125366 125971 1 1 1 1 1 1 1 1 1 1 1 126681 126683 127324 127619 128066 128655 129100 130232 130533 130539 131122 1 1 1 1 1 1 1 1 1 1 1 131876 134043 135171 136548 136911 137793 139144 139350 141933 142069 142141 1 1 1 1 1 1 1 1 1 1 1 142146 142339 143937 146455 151503 154730 154991 155383 156833 157250 158980 1 1 1 1 1 1 1 1 1 1 1 161678 162336 162810 164767 166790 167105 167131 167845 172684 173260 173587 1 1 1 1 1 1 1 1 1 1 1 174107 175568 175877 176460 176789 178140 178863 179562 181344 181379 181853 1 1 1 1 1 1 1 1 1 1 1 184217 185039 185139 188780 188967 190410 191276 191381 191467 195304 199512 1 1 1 1 1 1 1 1 1 1 1 202204 210554 213765 223004 223696 223914 228548 233406 233482 234509 234730 1 1 1 1 1 1 1 1 1 1 1 241329 244051 246100 260646 264020 277108 293403 1 1 1 1 1 1 1 > colnames(x) [1] "y" "X1" "X2" "X3" "X4" "X5" > colnames(x)[par1] [1] "y" > x[,par1] [1] 293403 277108 264020 260646 246100 244051 241329 234730 234509 233482 [11] 233406 228548 223914 223696 223004 213765 210554 202204 199512 195304 [21] 191467 191381 191276 190410 188967 188780 185139 185039 184217 181853 [31] 181379 181344 179562 178863 178140 176789 176460 175877 175568 174107 [41] 173587 173260 172684 167845 167131 167105 166790 164767 162810 162336 [51] 161678 158980 157250 156833 155383 154991 154730 151503 146455 143937 [61] 142339 142146 142141 142069 141933 139350 139144 137793 136911 136548 [71] 135171 134043 131876 131122 130539 130533 130232 129100 128655 128066 [81] 127619 127324 126683 126681 125971 125366 122433 121135 119291 118958 [91] 118807 118372 116900 116775 115199 114928 114397 113337 111664 108715 [101] 107342 107335 106539 105615 105410 105324 103012 102531 101324 100885 [111] 100672 99946 99768 99246 98599 98030 94763 93340 93125 91185 [121] 90961 90938 89318 88817 84944 84572 84256 80953 78800 78776 [131] 75812 75426 74398 74112 73567 69471 68948 67746 67507 65029 [141] 64320 61857 61499 50999 46660 43287 38214 35523 32750 31414 [151] 24188 22938 21054 17547 14688 7199 969 455 203 98 [161] 0 0 0 0 > 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/1yjky1356093488.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: y Inputs: X1, X2, X3, X4, X5 Number of observations: 164 1) X1 <= 37; criterion = 1, statistic = 98.012 2) X1 <= 18; criterion = 1, statistic = 30.045 3) X3 <= 6023; criterion = 1, statistic = 16.265 4)* weights = 14 3) X3 > 6023 5)* weights = 10 2) X1 > 18 6)* weights = 18 1) X1 > 37 7) X4 <= 90; criterion = 1, statistic = 26.498 8)* weights = 61 7) X4 > 90 9)* weights = 61 > postscript(file="/var/fisher/rcomp/tmp/2xvqq1356093488.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/3hw7w1356093488.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 293403 176061.902 117341.0984 2 277108 129880.852 147227.1475 3 264020 176061.902 87958.0984 4 260646 176061.902 84584.0984 5 246100 176061.902 70038.0984 6 244051 176061.902 67989.0984 7 241329 176061.902 65267.0984 8 234730 176061.902 58668.0984 9 234509 176061.902 58447.0984 10 233482 129880.852 103601.1475 11 233406 176061.902 57344.0984 12 228548 176061.902 52486.0984 13 223914 176061.902 47852.0984 14 223696 176061.902 47634.0984 15 223004 176061.902 46942.0984 16 213765 176061.902 37703.0984 17 210554 176061.902 34492.0984 18 202204 129880.852 72323.1475 19 199512 129880.852 69631.1475 20 195304 176061.902 19242.0984 21 191467 176061.902 15405.0984 22 191381 176061.902 15319.0984 23 191276 176061.902 15214.0984 24 190410 176061.902 14348.0984 25 188967 176061.902 12905.0984 26 188780 176061.902 12718.0984 27 185139 176061.902 9077.0984 28 185039 176061.902 8977.0984 29 184217 129880.852 54336.1475 30 181853 176061.902 5791.0984 31 181379 176061.902 5317.0984 32 181344 176061.902 5282.0984 33 179562 176061.902 3500.0984 34 178863 129880.852 48982.1475 35 178140 129880.852 48259.1475 36 176789 176061.902 727.0984 37 176460 176061.902 398.0984 38 175877 176061.902 -184.9016 39 175568 176061.902 -493.9016 40 174107 176061.902 -1954.9016 41 173587 176061.902 -2474.9016 42 173260 129880.852 43379.1475 43 172684 176061.902 -3377.9016 44 167845 176061.902 -8216.9016 45 167131 129880.852 37250.1475 46 167105 129880.852 37224.1475 47 166790 129880.852 36909.1475 48 164767 129880.852 34886.1475 49 162810 129880.852 32929.1475 50 162336 176061.902 -13725.9016 51 161678 129880.852 31797.1475 52 158980 176061.902 -17081.9016 53 157250 176061.902 -18811.9016 54 156833 129880.852 26952.1475 55 155383 176061.902 -20678.9016 56 154991 176061.902 -21070.9016 57 154730 176061.902 -21331.9016 58 151503 176061.902 -24558.9016 59 146455 176061.902 -29606.9016 60 143937 176061.902 -32124.9016 61 142339 176061.902 -33722.9016 62 142146 176061.902 -33915.9016 63 142141 129880.852 12260.1475 64 142069 129880.852 12188.1475 65 141933 176061.902 -34128.9016 66 139350 129880.852 9469.1475 67 139144 129880.852 9263.1475 68 137793 129880.852 7912.1475 69 136911 176061.902 -39150.9016 70 136548 176061.902 -39513.9016 71 135171 129880.852 5290.1475 72 134043 129880.852 4162.1475 73 131876 86457.889 45418.1111 74 131122 129880.852 1241.1475 75 130539 129880.852 658.1475 76 130533 129880.852 652.1475 77 130232 176061.902 -45829.9016 78 129100 129880.852 -780.8525 79 128655 176061.902 -47406.9016 80 128066 129880.852 -1814.8525 81 127619 129880.852 -2261.8525 82 127324 176061.902 -48737.9016 83 126683 129880.852 -3197.8525 84 126681 129880.852 -3199.8525 85 125971 129880.852 -3909.8525 86 125366 129880.852 -4514.8525 87 122433 129880.852 -7447.8525 88 121135 129880.852 -8745.8525 89 119291 176061.902 -56770.9016 90 118958 129880.852 -10922.8525 91 118807 129880.852 -11073.8525 92 118372 176061.902 -57689.9016 93 116900 129880.852 -12980.8525 94 116775 86457.889 30317.1111 95 115199 129880.852 -14681.8525 96 114928 176061.902 -61133.9016 97 114397 129880.852 -15483.8525 98 113337 129880.852 -16543.8525 99 111664 176061.902 -64397.9016 100 108715 129880.852 -21165.8525 101 107342 176061.902 -68719.9016 102 107335 129880.852 -22545.8525 103 106539 86457.889 20081.1111 104 105615 129880.852 -24265.8525 105 105410 129880.852 -24470.8525 106 105324 129880.852 -24556.8525 107 103012 86457.889 16554.1111 108 102531 129880.852 -27349.8525 109 101324 176061.902 -74737.9016 110 100885 129880.852 -28995.8525 111 100672 129880.852 -29208.8525 112 99946 176061.902 -76115.9016 113 99768 86457.889 13310.1111 114 99246 86457.889 12788.1111 115 98599 129880.852 -31281.8525 116 98030 86457.889 11572.1111 117 94763 176061.902 -81298.9016 118 93340 129880.852 -36540.8525 119 93125 86457.889 6667.1111 120 91185 129880.852 -38695.8525 121 90961 129880.852 -38919.8525 122 90938 129880.852 -38942.8525 123 89318 129880.852 -40562.8525 124 88817 129880.852 -41063.8525 125 84944 129880.852 -44936.8525 126 84572 129880.852 -45308.8525 127 84256 129880.852 -45624.8525 128 80953 129880.852 -48927.8525 129 78800 86457.889 -7657.8889 130 78776 86457.889 -7681.8889 131 75812 86457.889 -10645.8889 132 75426 48633.900 26792.1000 133 74398 129880.852 -55482.8525 134 74112 86457.889 -12345.8889 135 73567 86457.889 -12890.8889 136 69471 86457.889 -16986.8889 137 68948 86457.889 -17509.8889 138 67746 48633.900 19112.1000 139 67507 129880.852 -62373.8525 140 65029 86457.889 -21428.8889 141 64320 48633.900 15686.1000 142 61857 86457.889 -24600.8889 143 61499 86457.889 -24958.8889 144 50999 48633.900 2365.1000 145 46660 48633.900 -1973.9000 146 43287 48633.900 -5346.9000 147 38214 48633.900 -10419.9000 148 35523 48633.900 -13110.9000 149 32750 48633.900 -15883.9000 150 31414 48633.900 -17219.9000 151 24188 7809.929 16378.0714 152 22938 7809.929 15128.0714 153 21054 7809.929 13244.0714 154 17547 7809.929 9737.0714 155 14688 7809.929 6878.0714 156 7199 7809.929 -610.9286 157 969 7809.929 -6840.9286 158 455 7809.929 -7354.9286 159 203 7809.929 -7606.9286 160 98 7809.929 -7711.9286 161 0 7809.929 -7809.9286 162 0 7809.929 -7809.9286 163 0 7809.929 -7809.9286 164 0 7809.929 -7809.9286 > 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/4a4ip1356093488.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/5fb761356093488.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/6p5aw1356093488.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/79jvn1356093488.tab") + } > > try(system("convert tmp/2xvqq1356093488.ps tmp/2xvqq1356093488.png",intern=TRUE)) character(0) > try(system("convert tmp/3hw7w1356093488.ps tmp/3hw7w1356093488.png",intern=TRUE)) character(0) > try(system("convert tmp/4a4ip1356093488.ps tmp/4a4ip1356093488.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.345 0.685 6.221