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(279055 + ,96 + ,42 + ,130 + ,140824 + ,32033 + ,165 + ,165 + ,209884 + ,75 + ,38 + ,143 + ,110459 + ,20654 + ,135 + ,132 + ,233432 + ,70 + ,46 + ,118 + ,105079 + ,16346 + ,121 + ,121 + ,222117 + ,134 + ,42 + ,146 + ,112098 + ,35926 + ,148 + ,145 + ,179751 + ,72 + ,30 + ,73 + ,43929 + ,10621 + ,73 + ,71 + ,70849 + ,8 + ,35 + ,89 + ,76173 + ,10024 + ,49 + ,47 + ,568125 + ,169 + ,40 + ,146 + ,187326 + ,43068 + ,185 + ,177 + ,33186 + ,1 + ,18 + ,22 + ,22807 + ,1271 + ,5 + ,5 + ,227332 + ,88 + ,38 + ,132 + ,144408 + ,34416 + ,125 + ,124 + ,258676 + ,98 + ,37 + ,92 + ,66485 + ,20318 + ,93 + ,92 + ,341549 + ,101 + ,46 + ,147 + ,79089 + ,24409 + ,154 + ,149 + ,260484 + ,122 + ,60 + ,203 + ,81625 + ,20648 + ,98 + ,93 + ,202918 + ,57 + ,37 + ,113 + ,68788 + ,12347 + ,70 + ,70 + ,367799 + ,139 + ,55 + ,171 + ,103297 + ,21857 + ,148 + ,148 + ,269455 + ,87 + ,44 + ,87 + ,69446 + ,11034 + ,100 + ,100 + ,394578 + ,176 + ,63 + ,208 + ,114948 + ,33433 + ,150 + ,142 + ,335567 + ,114 + ,40 + ,153 + ,167949 + ,35902 + ,197 + ,194 + ,423110 + ,121 + ,43 + ,97 + ,125081 + ,22355 + ,114 + ,113 + ,182016 + ,103 + ,32 + ,95 + ,125818 + ,31219 + ,169 + ,162 + ,267365 + ,135 + ,52 + ,197 + ,136588 + ,21983 + ,200 + ,186 + ,279428 + ,123 + ,49 + ,160 + ,112431 + ,40085 + ,148 + ,147 + ,506616 + ,97 + ,41 + ,148 + ,103037 + ,18507 + ,140 + ,137 + ,201993 + ,74 + ,25 + ,84 + ,82317 + ,16278 + ,74 + ,71 + ,200004 + ,103 + ,57 + ,227 + ,118906 + ,24662 + ,128 + ,123 + ,257139 + ,158 + ,45 + ,154 + ,83515 + ,31452 + ,140 + ,134 + ,256931 + ,113 + ,42 + ,151 + ,104581 + ,32580 + ,116 + ,115 + ,296850 + ,102 + ,45 + ,142 + ,103129 + ,22883 + ,147 + ,138 + ,307100 + ,132 + ,43 + ,148 + ,83243 + ,27652 + ,132 + ,125 + ,184160 + ,62 + ,36 + ,110 + ,37110 + ,9845 + ,70 + ,66 + ,393860 + ,150 + ,45 + ,149 + ,113344 + ,20190 + ,144 + ,137 + ,309877 + ,138 + ,50 + ,179 + ,139165 + ,46201 + ,155 + ,152 + ,252512 + ,50 + ,50 + ,149 + ,86652 + ,10971 + ,165 + ,159 + ,367819 + ,141 + ,51 + ,187 + ,112302 + ,34811 + ,161 + ,159 + ,115602 + ,48 + ,42 + ,153 + ,69652 + ,3029 + ,31 + ,31 + ,430118 + ,141 + ,44 + ,163 + ,119442 + ,38941 + ,199 + ,185 + ,273950 + ,83 + ,42 + ,127 + ,69867 + ,4958 + ,78 + ,78 + ,428028 + ,112 + ,44 + ,151 + ,101629 + ,32344 + ,121 + ,117 + ,251306 + ,79 + ,40 + ,100 + ,70168 + ,19433 + ,112 + ,109 + ,115658 + ,33 + ,17 + ,46 + ,31081 + ,12558 + ,41 + ,41 + ,388812 + ,149 + ,43 + ,156 + ,103925 + ,36524 + ,158 + ,149 + ,343783 + ,126 + ,41 + ,128 + ,92622 + ,26041 + ,123 + ,123 + ,198635 + ,81 + ,41 + ,111 + ,79011 + ,16637 + ,104 + ,103 + ,213258 + ,84 + ,40 + ,119 + ,93487 + ,28395 + ,94 + ,87 + ,182398 + ,68 + ,49 + ,148 + ,64520 + ,16747 + ,73 + ,71 + ,157164 + ,50 + ,52 + ,65 + ,93473 + ,9105 + ,52 + ,51 + ,459440 + ,101 + ,42 + ,134 + ,114360 + ,11941 + ,71 + ,70 + ,78800 + ,20 + ,26 + ,66 + ,33032 + ,7935 + ,21 + ,21 + ,217575 + ,101 + ,59 + ,201 + ,96125 + ,19499 + ,155 + ,155 + ,368086 + ,150 + ,50 + ,177 + ,151911 + ,22938 + ,174 + ,172 + ,206448 + ,115 + ,50 + ,156 + ,89256 + ,25314 + ,136 + ,133 + ,244640 + ,99 + ,47 + ,158 + ,95676 + ,28527 + ,128 + ,125 + ,24188 + ,8 + ,4 + ,7 + ,5950 + ,2694 + ,7 + ,7 + ,399093 + ,88 + ,51 + ,175 + ,149695 + ,20867 + ,165 + ,158 + ,65029 + ,21 + ,18 + ,61 + ,32551 + ,3597 + ,21 + ,21 + ,101097 + ,30 + ,14 + ,41 + ,31701 + ,5296 + ,35 + ,35 + ,297973 + ,97 + ,41 + ,133 + ,100087 + ,32982 + ,137 + ,133 + ,369627 + ,163 + ,61 + ,228 + ,169707 + ,38975 + ,174 + ,169 + ,367127 + ,132 + ,40 + ,140 + ,150491 + ,42721 + ,257 + ,256 + ,374143 + ,161 + ,44 + ,155 + ,120192 + ,41455 + ,207 + ,190 + ,270099 + ,89 + ,40 + ,141 + ,95893 + ,23923 + ,103 + ,100 + ,391871 + ,160 + ,51 + ,181 + ,151715 + ,26719 + ,171 + ,171 + ,315924 + ,139 + ,29 + ,75 + ,176225 + ,53405 + ,279 + ,267 + ,291391 + ,104 + ,43 + ,97 + ,59900 + ,12526 + ,83 + ,80 + ,286417 + ,100 + ,42 + ,142 + ,104767 + ,26584 + ,130 + ,126 + ,270324 + ,66 + ,41 + ,136 + ,114799 + ,37062 + ,131 + ,132 + ,267432 + ,163 + ,30 + ,87 + ,72128 + ,25696 + ,126 + ,121 + ,215924 + ,93 + ,39 + ,140 + ,143592 + ,24634 + ,158 + ,156 + ,249232 + ,85 + ,51 + ,169 + ,89626 + ,27269 + ,138 + ,133 + ,260919 + ,150 + ,40 + ,129 + ,131072 + ,25270 + ,200 + ,199 + ,182961 + ,143 + ,29 + ,92 + ,126817 + ,24634 + ,104 + ,98 + ,256967 + ,107 + ,47 + ,160 + ,81351 + ,17828 + ,111 + ,109 + ,73566 + ,22 + ,23 + ,67 + ,22618 + ,3007 + ,26 + ,25 + ,272362 + ,85 + ,48 + ,179 + ,88977 + ,20065 + ,115 + ,113 + ,216802 + ,86 + ,38 + ,90 + ,92059 + ,24648 + ,127 + ,126 + ,228835 + ,131 + ,42 + ,144 + ,81897 + ,21588 + ,140 + ,137 + ,371391 + ,140 + ,46 + ,144 + ,108146 + ,25217 + ,121 + ,121 + ,392330 + ,156 + ,40 + ,144 + ,126372 + ,30927 + ,183 + ,178 + ,220401 + ,81 + ,45 + ,134 + ,249771 + ,18487 + ,68 + ,63 + ,225825 + ,137 + ,42 + ,146 + ,71154 + ,18050 + ,112 + ,109 + ,217623 + ,102 + ,41 + ,121 + ,71571 + ,17696 + ,103 + ,101 + ,199011 + ,72 + ,37 + ,112 + ,55918 + ,17326 + ,63 + ,61 + ,483074 + ,161 + ,47 + ,145 + ,160141 + ,39361 + ,166 + ,157 + ,145943 + ,30 + ,26 + ,99 + ,38692 + ,9648 + ,38 + ,38 + ,295224 + ,120 + ,48 + ,96 + ,102812 + ,26759 + ,163 + ,159 + ,80953 + ,49 + ,8 + ,27 + ,56622 + ,7905 + ,59 + ,58 + ,171206 + ,63 + ,27 + ,77 + ,15986 + ,4527 + ,27 + ,27 + ,179344 + ,76 + ,38 + ,137 + ,123534 + ,41517 + ,108 + ,108 + ,415550 + ,85 + ,41 + ,151 + ,108535 + ,21261 + ,88 + ,83 + ,366035 + ,146 + ,61 + ,126 + ,93879 + ,36099 + ,92 + ,88 + ,180679 + ,165 + ,45 + ,159 + ,144551 + ,39039 + ,170 + ,164 + ,298696 + ,89 + ,41 + ,101 + ,56750 + ,13841 + ,98 + ,96 + ,292260 + ,168 + ,42 + ,144 + ,127654 + ,23841 + ,205 + ,192 + ,199481 + ,48 + ,35 + ,102 + ,65594 + ,8589 + ,96 + ,94 + ,282361 + ,149 + ,36 + ,135 + ,59938 + ,15049 + ,107 + ,107 + ,329281 + ,75 + ,40 + ,147 + ,146975 + ,39038 + ,150 + ,144 + ,230588 + ,103 + ,40 + ,155 + ,165904 + ,36774 + ,138 + ,136 + ,297995 + ,116 + ,38 + ,138 + ,169265 + ,40076 + ,177 + ,171 + ,305984 + ,165 + ,43 + ,113 + ,183500 + ,43840 + ,213 + ,210 + ,416463 + ,155 + ,65 + ,248 + ,165986 + ,43146 + ,208 + ,193 + ,412530 + ,165 + ,33 + ,116 + ,184923 + ,50099 + ,307 + ,297 + ,297080 + ,121 + ,51 + ,176 + ,140358 + ,40312 + ,125 + ,125 + ,318283 + ,156 + ,45 + ,140 + ,149959 + ,32616 + ,208 + ,204 + ,202726 + ,81 + ,36 + ,59 + ,57224 + ,11338 + ,73 + ,70 + ,43287 + ,13 + ,19 + ,64 + ,43750 + ,7409 + ,49 + ,49 + ,223456 + ,113 + ,25 + ,40 + ,48029 + ,18213 + ,82 + ,82 + ,258249 + ,112 + ,44 + ,98 + ,104978 + ,45873 + ,206 + ,205 + ,299566 + ,133 + ,45 + ,139 + ,100046 + ,39844 + ,112 + ,111 + ,321797 + ,169 + ,44 + ,135 + ,101047 + ,28317 + ,139 + ,135 + ,170299 + ,28 + ,35 + ,97 + ,197426 + ,24797 + ,60 + ,59 + ,169545 + ,121 + ,46 + ,142 + ,160902 + ,7471 + ,70 + ,70 + ,354041 + ,82 + ,44 + ,155 + ,147172 + ,27259 + ,112 + ,108 + ,303273 + ,148 + ,45 + ,115 + ,109432 + ,23201 + ,142 + ,141 + ,23623 + ,12 + ,1 + ,0 + ,1168 + ,238 + ,11 + ,11 + ,195880 + ,146 + ,40 + ,103 + ,83248 + ,28830 + ,130 + ,130 + ,61857 + ,23 + ,11 + ,30 + ,25162 + ,3913 + ,31 + ,28 + ,207339 + ,84 + ,51 + ,130 + ,45724 + ,9935 + ,132 + ,101 + ,431443 + ,163 + ,38 + ,102 + ,110529 + ,27738 + ,219 + ,216 + ,21054 + ,4 + ,0 + ,0 + ,855 + ,338 + ,4 + ,4 + ,252805 + ,81 + ,30 + ,77 + ,101382 + ,13326 + ,102 + ,97 + ,31961 + ,18 + ,8 + ,9 + ,14116 + ,3988 + ,39 + ,39 + ,354622 + ,118 + ,43 + ,150 + ,89506 + ,24347 + ,125 + ,119 + ,251240 + ,76 + ,48 + ,163 + ,135356 + ,27111 + ,121 + ,118 + ,187003 + ,55 + ,49 + ,148 + ,116066 + ,3938 + ,42 + ,41 + ,172481 + ,57 + ,32 + ,94 + ,144244 + ,17416 + ,111 + ,107 + ,38214 + ,16 + ,8 + ,21 + ,8773 + ,1888 + ,16 + ,16 + ,256082 + ,93 + ,43 + ,151 + ,102153 + ,18700 + ,70 + ,69 + ,358276 + ,137 + ,52 + ,187 + ,117440 + ,36809 + ,162 + ,160 + ,211775 + ,50 + ,53 + ,171 + ,104128 + ,24959 + ,173 + ,158 + ,445926 + ,152 + ,49 + ,170 + ,134238 + ,37343 + ,171 + ,161 + ,348017 + ,163 + ,48 + ,145 + ,134047 + ,21849 + ,172 + ,165 + ,441946 + ,142 + ,56 + ,198 + ,279488 + ,49809 + ,254 + ,246 + ,208962 + ,77 + ,45 + ,152 + ,79756 + ,21654 + ,90 + ,89 + ,105332 + ,42 + ,40 + ,112 + ,66089 + ,8728 + ,50 + ,49 + ,315219 + ,94 + ,48 + ,173 + ,102070 + ,20920 + ,113 + ,107 + ,460249 + ,126 + ,50 + ,177 + ,146760 + ,27195 + ,187 + ,182 + ,160740 + ,63 + ,43 + ,153 + ,154771 + ,1037 + ,16 + ,16 + ,412099 + ,127 + ,46 + ,161 + ,165933 + ,42570 + ,175 + ,173 + ,173747 + ,59 + ,40 + ,115 + ,64593 + ,17672 + ,90 + ,90 + ,284582 + ,117 + ,45 + ,147 + ,92280 + ,34245 + ,140 + ,140 + ,283913 + ,110 + ,46 + ,124 + ,67150 + ,16786 + ,145 + ,142 + ,234262 + ,44 + ,37 + ,57 + ,128692 + ,20954 + ,141 + ,126 + ,386740 + ,95 + ,45 + ,144 + ,124089 + ,16378 + ,125 + ,123 + ,246963 + ,128 + ,39 + ,126 + ,125386 + ,31852 + ,241 + ,239 + ,173260 + ,41 + ,21 + ,78 + ,37238 + ,2805 + ,16 + ,15 + ,346748 + ,146 + ,50 + ,153 + ,140015 + ,38086 + ,175 + ,170 + ,176654 + ,147 + ,55 + ,196 + ,150047 + ,21166 + ,132 + ,123 + ,264767 + ,121 + ,40 + ,130 + ,154451 + ,34672 + ,154 + ,151 + ,314070 + ,185 + ,48 + ,159 + ,156349 + ,36171 + ,198 + ,194 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,14688 + ,4 + ,0 + ,0 + ,6023 + ,2065 + ,5 + ,5 + ,98 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,455 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,284420 + ,85 + ,46 + ,94 + ,84601 + ,19354 + ,125 + ,122 + ,410509 + ,157 + ,52 + ,129 + ,68946 + ,22124 + ,174 + ,173 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,203 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,7199 + ,7 + ,0 + ,0 + ,1644 + ,556 + ,6 + ,6 + ,46660 + ,12 + ,5 + ,13 + ,6179 + ,2089 + ,13 + ,13 + ,17547 + ,0 + ,1 + ,4 + ,3926 + ,2658 + ,3 + ,3 + ,121550 + ,37 + ,48 + ,89 + ,52789 + ,1813 + ,35 + ,35 + ,969 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,242258 + ,62 + ,34 + ,71 + ,100350 + ,17372 + ,80 + ,72) + ,dim=c(8 + ,164) + ,dimnames=list(c('Y' + ,'X1' + ,'X2' + ,'X3' + ,'X4' + ,'X5' + ,'X6' + ,'X7') + ,1:164)) > y <- array(NA,dim=c(8,164),dimnames=list(c('Y','X1','X2','X3','X4','X5','X6','X7'),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 = 'yes' > par3 = '2' > par2 = 'quantiles' > 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] "Y" > x[,par1] [1] 279055 209884 233432 222117 179751 70849 568125 33186 227332 258676 [11] 341549 260484 202918 367799 269455 394578 335567 423110 182016 267365 [21] 279428 506616 201993 200004 257139 256931 296850 307100 184160 393860 [31] 309877 252512 367819 115602 430118 273950 428028 251306 115658 388812 [41] 343783 198635 213258 182398 157164 459440 78800 217575 368086 206448 [51] 244640 24188 399093 65029 101097 297973 369627 367127 374143 270099 [61] 391871 315924 291391 286417 270324 267432 215924 249232 260919 182961 [71] 256967 73566 272362 216802 228835 371391 392330 220401 225825 217623 [81] 199011 483074 145943 295224 80953 171206 179344 415550 366035 180679 [91] 298696 292260 199481 282361 329281 230588 297995 305984 416463 412530 [101] 297080 318283 202726 43287 223456 258249 299566 321797 170299 169545 [111] 354041 303273 23623 195880 61857 207339 431443 21054 252805 31961 [121] 354622 251240 187003 172481 38214 256082 358276 211775 445926 348017 [131] 441946 208962 105332 315219 460249 160740 412099 173747 284582 283913 [141] 234262 386740 246963 173260 346748 176654 264767 314070 1 14688 [151] 98 455 0 0 284420 410509 0 203 7199 46660 [161] 17547 121550 969 242258 > 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,252805) [252805,568125] 82 82 > colnames(x) [1] "Y" "X1" "X2" "X3" "X4" "X5" "X6" "X7" > colnames(x)[par1] [1] "Y" > x[,par1] [1] [252805,568125] [ 0,252805) [ 0,252805) [ 0,252805) [5] [ 0,252805) [ 0,252805) [252805,568125] [ 0,252805) [9] [ 0,252805) [252805,568125] [252805,568125] [252805,568125] [13] [ 0,252805) [252805,568125] [252805,568125] [252805,568125] [17] [252805,568125] [252805,568125] [ 0,252805) [252805,568125] [21] [252805,568125] [252805,568125] [ 0,252805) [ 0,252805) [25] [252805,568125] [252805,568125] [252805,568125] [252805,568125] [29] [ 0,252805) [252805,568125] [252805,568125] [ 0,252805) [33] [252805,568125] [ 0,252805) [252805,568125] [252805,568125] [37] [252805,568125] [ 0,252805) [ 0,252805) [252805,568125] [41] [252805,568125] [ 0,252805) [ 0,252805) [ 0,252805) [45] [ 0,252805) [252805,568125] [ 0,252805) [ 0,252805) [49] [252805,568125] [ 0,252805) [ 0,252805) [ 0,252805) [53] [252805,568125] [ 0,252805) [ 0,252805) [252805,568125] [57] [252805,568125] [252805,568125] [252805,568125] [252805,568125] [61] [252805,568125] [252805,568125] [252805,568125] [252805,568125] [65] [252805,568125] [252805,568125] [ 0,252805) [ 0,252805) [69] [252805,568125] [ 0,252805) [252805,568125] [ 0,252805) [73] [252805,568125] [ 0,252805) [ 0,252805) [252805,568125] [77] [252805,568125] [ 0,252805) [ 0,252805) [ 0,252805) [81] [ 0,252805) [252805,568125] [ 0,252805) [252805,568125] [85] [ 0,252805) [ 0,252805) [ 0,252805) [252805,568125] [89] [252805,568125] [ 0,252805) [252805,568125] [252805,568125] [93] [ 0,252805) [252805,568125] [252805,568125] [ 0,252805) [97] [252805,568125] [252805,568125] [252805,568125] [252805,568125] [101] [252805,568125] [252805,568125] [ 0,252805) [ 0,252805) [105] [ 0,252805) [252805,568125] [252805,568125] [252805,568125] [109] [ 0,252805) [ 0,252805) [252805,568125] [252805,568125] [113] [ 0,252805) [ 0,252805) [ 0,252805) [ 0,252805) [117] [252805,568125] [ 0,252805) [252805,568125] [ 0,252805) [121] [252805,568125] [ 0,252805) [ 0,252805) [ 0,252805) [125] [ 0,252805) [252805,568125] [252805,568125] [ 0,252805) [129] [252805,568125] [252805,568125] [252805,568125] [ 0,252805) [133] [ 0,252805) [252805,568125] [252805,568125] [ 0,252805) [137] [252805,568125] [ 0,252805) [252805,568125] [252805,568125] [141] [ 0,252805) [252805,568125] [ 0,252805) [ 0,252805) [145] [252805,568125] [ 0,252805) [252805,568125] [252805,568125] [149] [ 0,252805) [ 0,252805) [ 0,252805) [ 0,252805) [153] [ 0,252805) [ 0,252805) [252805,568125] [252805,568125] [157] [ 0,252805) [ 0,252805) [ 0,252805) [ 0,252805) [161] [ 0,252805) [ 0,252805) [ 0,252805) [ 0,252805) Levels: [ 0,252805) [252805,568125] > 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/1o9m51324635661.tab") + } + } m.ct.i.pred m.ct.i.actu 1 2 1 538 206 2 32 698 [1] 0.7231183 [1] 0.9561644 [1] 0.8385346 m.ct.x.pred m.ct.x.actu 1 2 1 60 16 2 6 84 [1] 0.7894737 [1] 0.9333333 [1] 0.8674699 > m Conditional inference tree with 3 terminal nodes Response: as.factor(Y) Inputs: X1, X2, X3, X4, X5, X6, X7 Number of observations: 164 1) X1 <= 81; criterion = 1, statistic = 74.732 2) X5 <= 20954; criterion = 0.996, statistic = 11.881 3)* weights = 55 2) X5 > 20954 4)* weights = 7 1) X1 > 81 5)* weights = 102 > postscript(file="/var/wessaorg/rcomp/tmp/21rps1324635661.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/3hovx1324635661.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,] 1 1 [3,] 1 1 [4,] 1 2 [5,] 1 1 [6,] 1 1 [7,] 2 2 [8,] 1 1 [9,] 1 2 [10,] 2 2 [11,] 2 2 [12,] 2 2 [13,] 1 1 [14,] 2 2 [15,] 2 2 [16,] 2 2 [17,] 2 2 [18,] 2 2 [19,] 1 2 [20,] 2 2 [21,] 2 2 [22,] 2 2 [23,] 1 1 [24,] 1 2 [25,] 2 2 [26,] 2 2 [27,] 2 2 [28,] 2 2 [29,] 1 1 [30,] 2 2 [31,] 2 2 [32,] 1 1 [33,] 2 2 [34,] 1 1 [35,] 2 2 [36,] 2 2 [37,] 2 2 [38,] 1 1 [39,] 1 1 [40,] 2 2 [41,] 2 2 [42,] 1 1 [43,] 1 2 [44,] 1 1 [45,] 1 1 [46,] 2 2 [47,] 1 1 [48,] 1 2 [49,] 2 2 [50,] 1 2 [51,] 1 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,] 2 2 [64,] 2 2 [65,] 2 1 [66,] 2 2 [67,] 1 2 [68,] 1 2 [69,] 2 2 [70,] 1 2 [71,] 2 2 [72,] 1 1 [73,] 2 2 [74,] 1 2 [75,] 1 2 [76,] 2 2 [77,] 2 2 [78,] 1 1 [79,] 1 2 [80,] 1 2 [81,] 1 1 [82,] 2 2 [83,] 1 1 [84,] 2 2 [85,] 1 1 [86,] 1 1 [87,] 1 1 [88,] 2 2 [89,] 2 2 [90,] 1 2 [91,] 2 2 [92,] 2 2 [93,] 1 1 [94,] 2 2 [95,] 2 1 [96,] 1 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 2 [106,] 2 2 [107,] 2 2 [108,] 2 2 [109,] 1 1 [110,] 1 2 [111,] 2 2 [112,] 2 2 [113,] 1 1 [114,] 1 2 [115,] 1 1 [116,] 1 2 [117,] 2 2 [118,] 1 1 [119,] 2 1 [120,] 1 1 [121,] 2 2 [122,] 1 1 [123,] 1 1 [124,] 1 1 [125,] 1 1 [126,] 2 2 [127,] 2 2 [128,] 1 1 [129,] 2 2 [130,] 2 2 [131,] 2 2 [132,] 1 1 [133,] 1 1 [134,] 2 2 [135,] 2 2 [136,] 1 1 [137,] 2 2 [138,] 1 1 [139,] 2 2 [140,] 2 2 [141,] 1 1 [142,] 2 2 [143,] 1 2 [144,] 1 1 [145,] 2 2 [146,] 1 2 [147,] 2 2 [148,] 2 2 [149,] 1 1 [150,] 1 1 [151,] 1 1 [152,] 1 1 [153,] 1 1 [154,] 1 1 [155,] 2 2 [156,] 2 2 [157,] 1 1 [158,] 1 1 [159,] 1 1 [160,] 1 1 [161,] 1 1 [162,] 1 1 [163,] 1 1 [164,] 1 1 [ 0,252805) [252805,568125] [ 0,252805) 59 23 [252805,568125] 3 79 > postscript(file="/var/wessaorg/rcomp/tmp/4tuy11324635661.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/5ql691324635661.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/6tawy1324635661.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/7rfrt1324635661.tab") + } > > try(system("convert tmp/21rps1324635661.ps tmp/21rps1324635661.png",intern=TRUE)) character(0) > try(system("convert tmp/3hovx1324635661.ps tmp/3hovx1324635661.png",intern=TRUE)) character(0) > try(system("convert tmp/4tuy11324635661.ps tmp/4tuy11324635661.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.557 0.248 3.803