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 = '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 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 1 98 203 455 969 7199 14688 17547 21054 23623 3 1 1 1 1 1 1 1 1 1 1 24188 31961 33186 38214 43287 46660 61857 65029 70849 73566 78800 1 1 1 1 1 1 1 1 1 1 1 80953 101097 105332 115602 115658 121550 145943 157164 160740 169545 170299 1 1 1 1 1 1 1 1 1 1 1 171206 172481 173260 173747 176654 179344 179751 180679 182016 182398 182961 1 1 1 1 1 1 1 1 1 1 1 184160 187003 195880 198635 199011 199481 200004 201993 202726 202918 206448 1 1 1 1 1 1 1 1 1 1 1 207339 208962 209884 211775 213258 215924 216802 217575 217623 220401 222117 1 1 1 1 1 1 1 1 1 1 1 223456 225825 227332 228835 230588 233432 234262 242258 244640 246963 249232 1 1 1 1 1 1 1 1 1 1 1 251240 251306 252512 252805 256082 256931 256967 257139 258249 258676 260484 1 1 1 1 1 1 1 1 1 1 1 260919 264767 267365 267432 269455 270099 270324 272362 273950 279055 279428 1 1 1 1 1 1 1 1 1 1 1 282361 283913 284420 284582 286417 291391 292260 295224 296850 297080 297973 1 1 1 1 1 1 1 1 1 1 1 297995 298696 299566 303273 305984 307100 309877 314070 315219 315924 318283 1 1 1 1 1 1 1 1 1 1 1 321797 329281 335567 341549 343783 346748 348017 354041 354622 358276 366035 1 1 1 1 1 1 1 1 1 1 1 367127 367799 367819 368086 369627 371391 374143 386740 388812 391871 392330 1 1 1 1 1 1 1 1 1 1 1 393860 394578 399093 410509 412099 412530 415550 416463 423110 428028 430118 1 1 1 1 1 1 1 1 1 1 1 431443 441946 445926 459440 460249 483074 506616 568125 1 1 1 1 1 1 1 1 > colnames(x) [1] "Y" "X1" "X2" "X3" "X4" "X5" "X6" "X7" > 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 == '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/14c571324635417.tab") + } + } > m Conditional inference tree with 8 terminal nodes Response: Y Inputs: X1, X2, X3, X4, X5, X6, X7 Number of observations: 164 1) X1 <= 49; criterion = 1, statistic = 110.047 2) X1 <= 23; criterion = 1, statistic = 25.866 3) X3 <= 9; criterion = 1, statistic = 17.88 4)* weights = 15 3) X3 > 9 5)* weights = 9 2) X1 > 23 6)* weights = 11 1) X1 > 49 7) X1 <= 84; criterion = 1, statistic = 37.413 8) X7 <= 107; criterion = 0.979, statistic = 8.829 9) X1 <= 74; criterion = 0.962, statistic = 7.703 10)* weights = 13 9) X1 > 74 11)* weights = 8 8) X7 > 107 12)* weights = 10 7) X1 > 84 13) X4 <= 100087; criterion = 0.989, statistic = 9.982 14)* weights = 32 13) X4 > 100087 15)* weights = 66 > postscript(file="/var/wessaorg/rcomp/tmp/21lgx1324635417.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/3x7kz1324635417.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 279055 334612.621 -55557.6212 2 209884 254313.900 -44429.9000 3 233432 254313.900 -20881.9000 4 222117 334612.621 -112495.6212 5 179751 185756.154 -6005.1538 6 70849 56827.556 14021.4444 7 568125 334612.621 233512.3788 8 33186 56827.556 -23641.5556 9 227332 334612.621 -107280.6212 10 258676 274544.688 -15868.6875 11 341549 274544.688 67004.3125 12 260484 274544.688 -14060.6875 13 202918 185756.154 17161.8462 14 367799 334612.621 33186.3788 15 269455 274544.688 -5089.6875 16 394578 334612.621 59965.3788 17 335567 334612.621 954.3788 18 423110 334612.621 88497.3788 19 182016 334612.621 -152596.6212 20 267365 334612.621 -67247.6212 21 279428 334612.621 -55184.6212 22 506616 334612.621 172003.3788 23 201993 185756.154 16236.8462 24 200004 334612.621 -134608.6212 25 257139 274544.688 -17405.6875 26 256931 334612.621 -77681.6212 27 296850 334612.621 -37762.6212 28 307100 274544.688 32555.3125 29 184160 185756.154 -1596.1538 30 393860 334612.621 59247.3788 31 309877 334612.621 -24735.6212 32 252512 254313.900 -1801.9000 33 367819 334612.621 33206.3788 34 115602 142130.636 -26528.6364 35 430118 334612.621 95505.3788 36 273950 222259.500 51690.5000 37 428028 334612.621 93415.3788 38 251306 254313.900 -3007.9000 39 115658 142130.636 -26472.6364 40 388812 334612.621 54199.3788 41 343783 274544.688 69238.3125 42 198635 222259.500 -23624.5000 43 213258 222259.500 -9001.5000 44 182398 185756.154 -3358.1538 45 157164 185756.154 -28592.1538 46 459440 334612.621 124827.3788 47 78800 56827.556 21972.4444 48 217575 274544.688 -56969.6875 49 368086 334612.621 33473.3788 50 206448 274544.688 -68096.6875 51 244640 274544.688 -29904.6875 52 24188 9465.733 14722.2667 53 399093 334612.621 64480.3788 54 65029 56827.556 8201.4444 55 101097 142130.636 -41033.6364 56 297973 274544.688 23428.3125 57 369627 334612.621 35014.3788 58 367127 334612.621 32514.3788 59 374143 334612.621 39530.3788 60 270099 274544.688 -4445.6875 61 391871 334612.621 57258.3788 62 315924 334612.621 -18688.6212 63 291391 274544.688 16846.3125 64 286417 334612.621 -48195.6212 65 270324 254313.900 16010.1000 66 267432 274544.688 -7112.6875 67 215924 334612.621 -118688.6212 68 249232 274544.688 -25312.6875 69 260919 334612.621 -73693.6212 70 182961 334612.621 -151651.6212 71 256967 274544.688 -17577.6875 72 73566 56827.556 16738.4444 73 272362 274544.688 -2182.6875 74 216802 274544.688 -57742.6875 75 228835 274544.688 -45709.6875 76 371391 334612.621 36778.3788 77 392330 334612.621 57717.3788 78 220401 222259.500 -1858.5000 79 225825 274544.688 -48719.6875 80 217623 274544.688 -56921.6875 81 199011 185756.154 13254.8462 82 483074 334612.621 148461.3788 83 145943 142130.636 3812.3636 84 295224 334612.621 -39388.6212 85 80953 142130.636 -61177.6364 86 171206 185756.154 -14550.1538 87 179344 254313.900 -74969.9000 88 415550 334612.621 80937.3788 89 366035 274544.688 91490.3125 90 180679 334612.621 -153933.6212 91 298696 274544.688 24151.3125 92 292260 334612.621 -42352.6212 93 199481 142130.636 57350.3636 94 282361 274544.688 7816.3125 95 329281 254313.900 74967.1000 96 230588 334612.621 -104024.6212 97 297995 334612.621 -36617.6212 98 305984 334612.621 -28628.6212 99 416463 334612.621 81850.3788 100 412530 334612.621 77917.3788 101 297080 334612.621 -37532.6212 102 318283 334612.621 -16329.6212 103 202726 222259.500 -19533.5000 104 43287 56827.556 -13540.5556 105 223456 274544.688 -51088.6875 106 258249 334612.621 -76363.6212 107 299566 274544.688 25021.3125 108 321797 334612.621 -12815.6212 109 170299 142130.636 28168.3636 110 169545 334612.621 -165067.6212 111 354041 254313.900 99727.1000 112 303273 334612.621 -31339.6212 113 23623 9465.733 14157.2667 114 195880 274544.688 -78664.6875 115 61857 56827.556 5029.4444 116 207339 222259.500 -14920.5000 117 431443 334612.621 96830.3788 118 21054 9465.733 11588.2667 119 252805 222259.500 30545.5000 120 31961 9465.733 22495.2667 121 354622 274544.688 80077.3125 122 251240 254313.900 -3073.9000 123 187003 185756.154 1246.8462 124 172481 185756.154 -13275.1538 125 38214 56827.556 -18613.5556 126 256082 334612.621 -78530.6212 127 358276 334612.621 23663.3788 128 211775 254313.900 -42538.9000 129 445926 334612.621 111313.3788 130 348017 334612.621 13404.3788 131 441946 334612.621 107333.3788 132 208962 222259.500 -13297.5000 133 105332 142130.636 -36798.6364 134 315219 334612.621 -19393.6212 135 460249 334612.621 125636.3788 136 160740 185756.154 -25016.1538 137 412099 334612.621 77486.3788 138 173747 185756.154 -12009.1538 139 284582 274544.688 10037.3125 140 283913 274544.688 9368.3125 141 234262 142130.636 92131.3636 142 386740 334612.621 52127.3788 143 246963 334612.621 -87649.6212 144 173260 142130.636 31129.3636 145 346748 334612.621 12135.3788 146 176654 334612.621 -157958.6212 147 264767 334612.621 -69845.6212 148 314070 334612.621 -20542.6212 149 1 9465.733 -9464.7333 150 14688 9465.733 5222.2667 151 98 9465.733 -9367.7333 152 455 9465.733 -9010.7333 153 0 9465.733 -9465.7333 154 0 9465.733 -9465.7333 155 284420 274544.688 9875.3125 156 410509 274544.688 135964.3125 157 0 9465.733 -9465.7333 158 203 9465.733 -9262.7333 159 7199 9465.733 -2266.7333 160 46660 56827.556 -10167.5556 161 17547 9465.733 8081.2667 162 121550 142130.636 -20580.6364 163 969 9465.733 -8496.7333 164 242258 185756.154 56501.8462 > 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/4i0jd1324635417.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/592i31324635417.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/64v401324635417.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/7gt6c1324635417.tab") + } > > try(system("convert tmp/21lgx1324635417.ps tmp/21lgx1324635417.png",intern=TRUE)) character(0) > try(system("convert tmp/3x7kz1324635417.ps tmp/3x7kz1324635417.png",intern=TRUE)) character(0) > try(system("convert tmp/4i0jd1324635417.ps tmp/4i0jd1324635417.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.649 0.280 3.937