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 = '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] "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]) 855 1168 5950 8773 14116 15986 22618 22807 25162 31081 31701 1 1 1 1 1 1 1 1 1 1 1 32551 33032 37110 37238 38692 43750 43929 45724 48029 55918 56622 1 1 1 1 1 1 1 1 1 1 1 56750 57224 59900 59938 64520 64593 65594 66089 66485 67150 68788 1 1 1 1 1 1 1 1 1 1 1 69446 69652 69867 70168 71154 71571 72128 76173 79011 79089 79756 1 1 1 1 1 1 1 1 1 1 1 81351 81625 81897 82317 83243 83248 83515 86652 88977 89256 89506 1 1 1 1 1 1 1 1 1 1 1 89626 92059 92280 92622 93473 93487 93879 95676 95893 96125 100046 1 1 1 1 1 1 1 1 1 1 1 100087 101047 101382 101629 102070 102153 102812 103037 103129 103297 103925 1 1 1 1 1 1 1 1 1 1 1 104128 104581 104767 104978 105079 108146 108535 109432 110459 110529 112098 1 1 1 1 1 1 1 1 1 1 1 112302 112431 113344 114360 114799 114948 116066 117440 118906 119442 120192 1 1 1 1 1 1 1 1 1 1 1 123534 124089 125081 125386 125818 126372 126817 127654 128692 131072 134047 1 1 1 1 1 1 1 1 1 1 1 134238 135356 136588 139165 140015 140358 140824 143592 144244 144408 144551 1 1 1 1 1 1 1 1 1 1 1 146760 146975 147172 149695 149959 150047 150491 151715 151911 154451 154771 1 1 1 1 1 1 1 1 1 1 1 156349 160141 160902 165904 165933 165986 167949 169265 169707 176225 183500 1 1 1 1 1 1 1 1 1 1 1 184923 187326 197426 249771 279488 1 1 1 1 1 > colnames(x) [1] "Y1" "X1" "X2" "X3" "X4" "X5" "X6" > 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 == '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/1jwgy1324642806.tab") + } + } > m Conditional inference tree with 6 terminal nodes Response: Y1 Inputs: X1, X2, X3, X4, X5, X6 Number of observations: 148 1) X1 <= 74151; criterion = 1, statistic = 79.218 2) X5 <= 110; criterion = 1, statistic = 16.198 3)* weights = 19 2) X5 > 110 4)* weights = 8 1) X1 > 74151 5) X1 <= 170492; criterion = 1, statistic = 41.999 6) X2 <= 34245; criterion = 1, statistic = 27.551 7) X3 <= 112; criterion = 0.999, statistic = 14.714 8)* weights = 29 7) X3 > 112 9)* weights = 45 6) X2 > 34245 10)* weights = 20 5) X1 > 170492 11)* weights = 27 > postscript(file="/var/wessaorg/rcomp/tmp/2ofl81324642806.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/38dpm1324642806.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 140824 156589.19 -15765.1852 2 110459 105304.91 5154.0889 3 105079 105304.91 -225.9111 4 112098 133964.40 -21866.4000 5 43929 83147.55 -39218.5517 6 76173 28178.16 47994.8421 7 187326 156589.19 30736.8148 8 22807 28178.16 -5371.1579 9 144408 133964.40 10443.6000 10 66485 83147.55 -16662.5517 11 79089 105304.91 -26215.9111 12 81625 83147.55 -1522.5517 13 68788 81275.38 -12487.3750 14 103297 105304.91 -2007.9111 15 69446 83147.55 -13701.5517 16 114948 105304.91 9643.0889 17 167949 133964.40 33984.6000 18 125081 105304.91 19776.0889 19 125818 105304.91 20513.0889 20 136588 105304.91 31283.0889 21 112431 133964.40 -21533.4000 22 103037 105304.91 -2267.9111 23 82317 83147.55 -830.5517 24 118906 105304.91 13601.0889 25 83515 105304.91 -21789.9111 26 104581 105304.91 -723.9111 27 103129 105304.91 -2175.9111 28 83243 105304.91 -22061.9111 29 37110 28178.16 8931.8421 30 113344 156589.19 -43245.1852 31 139165 156589.19 -17424.1852 32 86652 105304.91 -18652.9111 33 112302 156589.19 -44287.1852 34 69652 81275.38 -11623.3750 35 119442 156589.19 -37147.1852 36 69867 83147.55 -13280.5517 37 101629 156589.19 -54960.1852 38 70168 83147.55 -12979.5517 39 31081 28178.16 2902.8421 40 103925 133964.40 -30039.4000 41 92622 105304.91 -12682.9111 42 79011 83147.55 -4136.5517 43 93487 83147.55 10339.4483 44 64520 81275.38 -16755.3750 45 93473 83147.55 10325.4483 46 114360 83147.55 31212.4483 47 33032 28178.16 4853.8421 48 96125 105304.91 -9179.9111 49 151911 156589.19 -4678.1852 50 89256 105304.91 -16048.9111 51 95676 105304.91 -9628.9111 52 5950 28178.16 -22228.1579 53 149695 156589.19 -6894.1852 54 32551 28178.16 4372.8421 55 31701 28178.16 3522.8421 56 100087 105304.91 -5217.9111 57 169707 156589.19 13117.8148 58 150491 156589.19 -6098.1852 59 120192 156589.19 -36397.1852 60 95893 83147.55 12745.4483 61 151715 156589.19 -4874.1852 62 176225 156589.19 19635.8148 63 59900 83147.55 -23247.5517 64 104767 105304.91 -537.9111 65 114799 133964.40 -19165.4000 66 72128 105304.91 -33176.9111 67 143592 105304.91 38287.0889 68 89626 105304.91 -15678.9111 69 131072 105304.91 25767.0889 70 126817 83147.55 43669.4483 71 81351 83147.55 -1796.5517 72 22618 28178.16 -5560.1579 73 88977 105304.91 -16327.9111 74 92059 105304.91 -13245.9111 75 81897 105304.91 -23407.9111 76 108146 105304.91 2841.0889 77 126372 105304.91 21067.0889 78 249771 156589.19 93181.8148 79 71154 83147.55 -11993.5517 80 71571 83147.55 -11576.5517 81 55918 83147.55 -27229.5517 82 160141 156589.19 3551.8148 83 38692 28178.16 10513.8421 84 102812 105304.91 -2492.9111 85 56622 28178.16 28443.8421 86 15986 28178.16 -12192.1579 87 123534 133964.40 -10430.4000 88 108535 83147.55 25387.4483 89 93879 133964.40 -40085.4000 90 144551 133964.40 10586.6000 91 56750 83147.55 -26397.5517 92 127654 105304.91 22349.0889 93 65594 83147.55 -17553.5517 94 59938 83147.55 -23209.5517 95 146975 133964.40 13010.6000 96 165904 133964.40 31939.6000 97 169265 133964.40 35300.6000 98 183500 156589.19 26910.8148 99 165986 156589.19 9396.8148 100 184923 156589.19 28333.8148 101 140358 133964.40 6393.6000 102 149959 156589.19 -6630.1852 103 57224 83147.55 -25923.5517 104 43750 28178.16 15571.8421 105 48029 83147.55 -35118.5517 106 104978 133964.40 -28986.4000 107 100046 133964.40 -33918.4000 108 101047 105304.91 -4257.9111 109 197426 156589.19 40836.8148 110 160902 83147.55 77754.4483 111 147172 156589.19 -9417.1852 112 109432 105304.91 4127.0889 113 1168 28178.16 -27010.1579 114 83248 105304.91 -22056.9111 115 25162 28178.16 -3016.1579 116 45724 81275.38 -35551.3750 117 110529 156589.19 -46060.1852 118 855 28178.16 -27323.1579 119 101382 83147.55 18234.4483 120 14116 28178.16 -14062.1579 121 89506 105304.91 -15798.9111 122 135356 105304.91 30051.0889 123 116066 81275.38 34790.6250 124 144244 83147.55 61096.4483 125 8773 28178.16 -19405.1579 126 102153 83147.55 19005.4483 127 117440 133964.40 -16524.4000 128 104128 105304.91 -1176.9111 129 134238 156589.19 -22351.1852 130 134047 156589.19 -22542.1852 131 279488 156589.19 122898.8148 132 79756 83147.55 -3391.5517 133 66089 81275.38 -15186.3750 134 102070 105304.91 -3234.9111 135 146760 156589.19 -9829.1852 136 154771 81275.38 73495.6250 137 165933 133964.40 31968.6000 138 64593 81275.38 -16682.3750 139 92280 105304.91 -13024.9111 140 67150 105304.91 -38154.9111 141 128692 105304.91 23387.0889 142 124089 105304.91 18784.0889 143 125386 105304.91 20081.0889 144 37238 28178.16 9059.8421 145 140015 133964.40 6050.6000 146 150047 105304.91 44742.0889 147 154451 133964.40 20486.6000 148 156349 133964.40 22384.6000 > 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/487ti1324642806.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/5fau01324642806.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/6wnz31324642806.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/7ezim1324642806.tab") + } > > try(system("convert tmp/2ofl81324642806.ps tmp/2ofl81324642806.png",intern=TRUE)) character(0) > try(system("convert tmp/38dpm1324642806.ps tmp/38dpm1324642806.png",intern=TRUE)) character(0) > try(system("convert tmp/487ti1324642806.ps tmp/487ti1324642806.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.465 0.303 4.717