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(272545 + ,1747 + ,69 + ,483 + ,32033 + ,3 + ,116 + ,144 + ,179444 + ,1209 + ,64 + ,429 + ,20654 + ,4 + ,127 + ,133 + ,222373 + ,1844 + ,69 + ,673 + ,16346 + ,16 + ,106 + ,162 + ,218443 + ,2683 + ,104 + ,1137 + ,35926 + ,2 + ,133 + ,148 + ,167843 + ,1228 + ,51 + ,374 + ,10621 + ,1 + ,64 + ,88 + ,70849 + ,631 + ,28 + ,179 + ,10024 + ,3 + ,89 + ,129 + ,506574 + ,4627 + ,123 + ,2251 + ,43068 + ,0 + ,122 + ,128 + ,33186 + ,381 + ,19 + ,111 + ,1271 + ,0 + ,22 + ,67 + ,216660 + ,2063 + ,59 + ,740 + ,34416 + ,7 + ,117 + ,132 + ,213274 + ,1758 + ,44 + ,595 + ,20318 + ,0 + ,82 + ,120 + ,307153 + ,2132 + ,109 + ,800 + ,24409 + ,0 + ,147 + ,169 + ,237633 + ,2128 + ,114 + ,660 + ,20648 + ,7 + ,184 + ,210 + ,164292 + ,1667 + ,68 + ,635 + ,12347 + ,8 + ,113 + ,122 + ,364402 + ,2965 + ,79 + ,1172 + ,21857 + ,4 + ,171 + ,191 + ,244103 + ,2098 + ,84 + ,674 + ,11034 + ,10 + ,87 + ,162 + ,384448 + ,4904 + ,178 + ,1692 + ,33433 + ,0 + ,199 + ,223 + ,325587 + ,2242 + ,68 + ,811 + ,35902 + ,6 + ,139 + ,140 + ,323652 + ,2977 + ,157 + ,1168 + ,22355 + ,4 + ,92 + ,144 + ,176082 + ,1438 + ,55 + ,507 + ,31219 + ,3 + ,85 + ,111 + ,266736 + ,2347 + ,87 + ,689 + ,21983 + ,8 + ,193 + ,199 + ,278265 + ,2522 + ,70 + ,837 + ,40085 + ,0 + ,160 + ,187 + ,442703 + ,2889 + ,103 + ,1270 + ,18507 + ,1 + ,144 + ,144 + ,180393 + ,1447 + ,41 + ,462 + ,16278 + ,5 + ,84 + ,89 + ,189897 + ,1717 + ,54 + ,601 + ,24662 + ,9 + ,208 + ,208 + ,234247 + ,3362 + ,121 + ,1242 + ,31452 + ,1 + ,154 + ,165 + ,237452 + ,2898 + ,125 + ,1025 + ,32580 + ,0 + ,139 + ,146 + ,267268 + ,2828 + ,127 + ,1062 + ,22883 + ,5 + ,127 + ,158 + ,270787 + ,1972 + ,86 + ,618 + ,27652 + ,0 + ,148 + ,154 + ,155915 + ,1495 + ,51 + ,559 + ,9845 + ,0 + ,99 + ,117 + ,342564 + ,2840 + ,69 + ,1062 + ,20190 + ,0 + ,135 + ,158 + ,282172 + ,2299 + ,76 + ,913 + ,46201 + ,3 + ,171 + ,183 + ,216584 + ,1909 + ,76 + ,643 + ,10971 + ,6 + ,149 + ,186 + ,318563 + ,2091 + ,84 + ,779 + ,34811 + ,1 + ,178 + ,185 + ,98672 + ,971 + ,37 + ,322 + ,3029 + ,4 + ,137 + ,141 + ,386258 + ,3293 + ,95 + ,1243 + ,38941 + ,4 + ,151 + ,156 + ,273950 + ,2764 + ,56 + ,1186 + ,4958 + ,0 + ,127 + ,159 + ,425120 + ,3682 + ,120 + ,1324 + ,32344 + ,0 + ,151 + ,161 + ,227636 + ,1918 + ,83 + ,640 + ,19433 + ,2 + ,89 + ,139 + ,115658 + ,947 + ,33 + ,284 + ,12558 + ,1 + ,46 + ,55 + ,349863 + ,3433 + ,194 + ,1210 + ,36524 + ,2 + ,153 + ,163 + ,324178 + ,3246 + ,79 + ,1490 + ,26041 + ,10 + ,122 + ,145 + ,178083 + ,1692 + ,67 + ,667 + ,16637 + ,9 + ,111 + ,148 + ,195153 + ,1735 + ,73 + ,635 + ,28395 + ,5 + ,108 + ,115 + ,177694 + ,1771 + ,61 + ,479 + ,16747 + ,6 + ,142 + ,174 + ,153778 + ,2496 + ,82 + ,1022 + ,9105 + ,1 + ,45 + ,73 + ,455168 + ,5501 + ,151 + ,2068 + ,11941 + ,2 + ,131 + ,147 + ,78800 + ,918 + ,42 + ,330 + ,7935 + ,2 + ,66 + ,82 + ,208051 + ,2228 + ,76 + ,648 + ,19499 + ,0 + ,180 + ,201 + ,348077 + ,4051 + ,118 + ,1367 + ,22938 + ,10 + ,165 + ,181 + ,175523 + ,2081 + ,54 + ,868 + ,25314 + ,3 + ,146 + ,164 + ,224591 + ,1875 + ,74 + ,588 + ,28524 + ,0 + ,137 + ,158 + ,24188 + ,496 + ,24 + ,218 + ,2694 + ,0 + ,7 + ,12 + ,372238 + ,2537 + ,314 + ,833 + ,20867 + ,8 + ,157 + ,163 + ,65029 + ,744 + ,17 + ,255 + ,3597 + ,5 + ,61 + ,67 + ,101097 + ,1161 + ,64 + ,454 + ,5296 + ,3 + ,41 + ,52 + ,279012 + ,3027 + ,58 + ,1108 + ,32982 + ,1 + ,120 + ,134 + ,317644 + ,2526 + ,84 + ,662 + ,38975 + ,5 + ,228 + ,230 + ,340471 + ,3705 + ,185 + ,1119 + ,42721 + ,5 + ,137 + ,145 + ,358958 + ,2667 + ,141 + ,1058 + ,41455 + ,0 + ,150 + ,153 + ,252529 + ,2175 + ,83 + ,822 + ,23923 + ,12 + ,127 + ,139 + ,370628 + ,3949 + ,140 + ,1302 + ,26719 + ,10 + ,161 + ,178 + ,304468 + ,3165 + ,117 + ,1145 + ,53405 + ,12 + ,73 + ,101 + ,265870 + ,2939 + ,113 + ,1185 + ,12526 + ,11 + ,97 + ,169 + ,264889 + ,2610 + ,88 + ,931 + ,26584 + ,8 + ,142 + ,163 + ,228595 + ,1426 + ,66 + ,557 + ,37062 + ,2 + ,125 + ,139 + ,216027 + ,1646 + ,65 + ,436 + ,25696 + ,0 + ,87 + ,116 + ,198798 + ,1971 + ,132 + ,596 + ,24634 + ,6 + ,128 + ,137 + ,238146 + ,2746 + ,145 + ,837 + ,27269 + ,9 + ,148 + ,167 + ,234891 + ,2308 + ,81 + ,848 + ,25270 + ,2 + ,116 + ,135 + ,175816 + ,1684 + ,69 + ,625 + ,24634 + ,5 + ,89 + ,102 + ,239314 + ,2537 + ,68 + ,865 + ,17828 + ,13 + ,154 + ,173 + ,73566 + ,893 + ,32 + ,385 + ,3007 + ,6 + ,67 + ,88 + ,242622 + ,2195 + ,84 + ,718 + ,20065 + ,7 + ,171 + ,175 + ,187167 + ,1695 + ,53 + ,705 + ,24648 + ,2 + ,90 + ,133 + ,209049 + ,2061 + ,63 + ,732 + ,21588 + ,2 + ,133 + ,148 + ,360592 + ,2329 + ,86 + ,988 + ,25217 + ,4 + ,144 + ,169 + ,342846 + ,2695 + ,92 + ,1077 + ,30927 + ,3 + ,133 + ,140 + ,207650 + ,1809 + ,107 + ,524 + ,18487 + ,6 + ,125 + ,154 + ,206500 + ,2290 + ,62 + ,697 + ,18050 + ,2 + ,134 + ,148 + ,182357 + ,1791 + ,64 + ,644 + ,17696 + ,0 + ,110 + ,134 + ,153613 + ,1678 + ,46 + ,622 + ,17326 + ,1 + ,89 + ,109 + ,456979 + ,4023 + ,124 + ,1227 + ,39361 + ,0 + ,138 + ,175 + ,145943 + ,1369 + ,69 + ,653 + ,9648 + ,5 + ,99 + ,99 + ,280366 + ,2308 + ,104 + ,656 + ,26759 + ,2 + ,92 + ,122 + ,80953 + ,870 + ,25 + ,437 + ,7905 + ,0 + ,27 + ,28 + ,150216 + ,1966 + ,54 + ,822 + ,4527 + ,0 + ,77 + ,101 + ,167878 + ,1459 + ,59 + ,423 + ,41517 + ,6 + ,137 + ,139 + ,369718 + ,3795 + ,205 + ,1489 + ,21261 + ,1 + ,137 + ,143 + ,322454 + ,2673 + ,116 + ,929 + ,36099 + ,0 + ,122 + ,206 + ,179797 + ,3085 + ,104 + ,1044 + ,39039 + ,1 + ,159 + ,171 + ,262883 + ,2367 + ,91 + ,792 + ,13841 + ,1 + ,85 + ,138 + ,262793 + ,2209 + ,77 + ,678 + ,23841 + ,3 + ,138 + ,148 + ,189142 + ,1829 + ,63 + ,597 + ,8589 + ,9 + ,90 + ,114 + ,275997 + ,3087 + ,74 + ,1099 + ,15049 + ,1 + ,135 + ,140 + ,328875 + ,2559 + ,82 + ,966 + ,39038 + ,4 + ,147 + ,156 + ,189252 + ,1624 + ,36 + ,555 + ,30391 + ,3 + ,139 + ,140 + ,222504 + ,1607 + ,51 + ,552 + ,39932 + ,5 + ,127 + ,127 + ,287386 + ,2109 + ,79 + ,778 + ,43840 + ,0 + ,104 + ,141 + ,389104 + ,4015 + ,151 + ,1322 + ,43146 + ,12 + ,248 + ,251 + ,397681 + ,3705 + ,108 + ,1415 + ,50099 + ,13 + ,106 + ,114 + ,287748 + ,2714 + ,136 + ,853 + ,40312 + ,8 + ,176 + ,198 + ,294320 + ,2325 + ,65 + ,848 + ,32616 + ,0 + ,130 + ,155 + ,186856 + ,1999 + ,179 + ,640 + ,11338 + ,0 + ,59 + ,138 + ,43287 + ,602 + ,14 + ,214 + ,7409 + ,4 + ,64 + ,71 + ,185468 + ,2146 + ,80 + ,716 + ,18213 + ,4 + ,36 + ,84 + ,235352 + ,2325 + ,146 + ,795 + ,45873 + ,0 + ,98 + ,167 + ,268077 + ,2617 + ,48 + ,1170 + ,39844 + ,0 + ,125 + ,155 + ,305195 + ,2688 + ,90 + ,1048 + ,28317 + ,0 + ,124 + ,150 + ,143356 + ,1207 + ,72 + ,399 + ,24797 + ,0 + ,83 + ,112 + ,154165 + ,3102 + ,88 + ,906 + ,7471 + ,0 + ,127 + ,161 + ,307000 + ,1869 + ,68 + ,609 + ,27259 + ,4 + ,143 + ,149 + ,298039 + ,2304 + ,88 + ,688 + ,23201 + ,0 + ,115 + ,164 + ,23623 + ,398 + ,11 + ,156 + ,238 + ,0 + ,0 + ,0 + ,195817 + ,2205 + ,73 + ,779 + ,28830 + ,0 + ,103 + ,155 + ,61857 + ,530 + ,25 + ,192 + ,3913 + ,4 + ,30 + ,32 + ,163766 + ,1596 + ,48 + ,457 + ,9935 + ,0 + ,119 + ,169 + ,414506 + ,3083 + ,117 + ,1195 + ,27738 + ,1 + ,102 + ,140 + ,21054 + ,387 + ,16 + ,146 + ,338 + ,0 + ,0 + ,0 + ,252805 + ,2137 + ,52 + ,866 + ,13326 + ,5 + ,77 + ,111 + ,31961 + ,492 + ,22 + ,200 + ,3988 + ,0 + ,9 + ,25 + ,317367 + ,3450 + ,115 + ,1230 + ,24347 + ,3 + ,137 + ,146 + ,240153 + ,2089 + ,65 + ,696 + ,27111 + ,7 + ,163 + ,183 + ,175083 + ,1658 + ,88 + ,491 + ,3938 + ,13 + ,146 + ,181 + ,152043 + ,1685 + ,53 + ,670 + ,17416 + ,3 + ,84 + ,107 + ,38214 + ,568 + ,34 + ,276 + ,1888 + ,0 + ,21 + ,27 + ,216299 + ,2059 + ,42 + ,716 + ,18700 + ,2 + ,151 + ,163 + ,357602 + ,2792 + ,82 + ,1021 + ,36809 + ,0 + ,187 + ,198 + ,198104 + ,1395 + ,61 + ,481 + ,24959 + ,0 + ,171 + ,205 + ,410803 + ,3590 + ,80 + ,1582 + ,37343 + ,4 + ,167 + ,187 + ,316105 + ,2387 + ,97 + ,820 + ,21849 + ,0 + ,145 + ,187 + ,397297 + ,3334 + ,124 + ,1153 + ,49809 + ,3 + ,175 + ,186 + ,187992 + ,1250 + ,35 + ,473 + ,21654 + ,0 + ,137 + ,151 + ,102424 + ,1121 + ,42 + ,401 + ,8728 + ,0 + ,100 + ,131 + ,286327 + ,2880 + ,335 + ,954 + ,20920 + ,4 + ,150 + ,155 + ,407378 + ,4104 + ,170 + ,1447 + ,27195 + ,4 + ,163 + ,172 + ,143860 + ,1759 + ,54 + ,546 + ,1037 + ,15 + ,149 + ,160 + ,391854 + ,4138 + ,132 + ,1728 + ,42570 + ,2 + ,161 + ,172 + ,157429 + ,1831 + ,77 + ,689 + ,17672 + ,4 + ,112 + ,143 + ,258751 + ,1787 + ,48 + ,590 + ,34245 + ,2 + ,135 + ,151 + ,282399 + ,2535 + ,94 + ,897 + ,16786 + ,1 + ,124 + ,158 + ,217665 + ,1816 + ,113 + ,613 + ,20954 + ,0 + ,45 + ,125 + ,366774 + ,3873 + ,116 + ,1548 + ,16378 + ,9 + ,120 + ,145 + ,236660 + ,2181 + ,88 + ,759 + ,31852 + ,1 + ,126 + ,145 + ,173260 + ,2035 + ,63 + ,716 + ,2805 + ,3 + ,78 + ,79 + ,323545 + ,2960 + ,99 + ,955 + ,38086 + ,11 + ,136 + ,174 + ,168994 + ,1915 + ,57 + ,720 + ,21166 + ,5 + ,179 + ,192 + ,253330 + ,2648 + ,86 + ,1023 + ,34672 + ,2 + ,118 + ,132 + ,301703 + ,2633 + ,105 + ,818 + ,36171 + ,1 + ,147 + ,159 + ,1 + ,2 + ,0 + ,0 + ,0 + ,9 + ,0 + ,0 + ,14688 + ,207 + ,10 + ,85 + ,2065 + ,0 + ,0 + ,0 + ,98 + ,5 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,455 + ,8 + ,2 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,246435 + ,2116 + ,84 + ,737 + ,19354 + ,2 + ,88 + ,133 + ,382374 + ,3286 + ,154 + ,1080 + ,22124 + ,3 + ,129 + ,204 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,203 + ,4 + ,4 + ,0 + ,0 + ,0 + ,0 + ,0 + ,7199 + ,151 + ,5 + ,74 + ,556 + ,0 + ,0 + ,0 + ,46660 + ,474 + ,20 + ,259 + ,2089 + ,0 + ,13 + ,15 + ,17547 + ,141 + ,5 + ,69 + ,2658 + ,0 + ,4 + ,4 + ,116678 + ,1047 + ,42 + ,285 + ,1813 + ,0 + ,76 + ,152 + ,969 + ,29 + ,2 + ,0 + ,0 + ,0 + ,0 + ,0 + ,206501 + ,1822 + ,68 + ,591 + ,17372 + ,2 + ,71 + ,125) + ,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 = '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] 272545 179444 222373 218443 167843 70849 506574 33186 216660 213274 [11] 307153 237633 164292 364402 244103 384448 325587 323652 176082 266736 [21] 278265 442703 180393 189897 234247 237452 267268 270787 155915 342564 [31] 282172 216584 318563 98672 386258 273950 425120 227636 115658 349863 [41] 324178 178083 195153 177694 153778 455168 78800 208051 348077 175523 [51] 224591 24188 372238 65029 101097 279012 317644 340471 358958 252529 [61] 370628 304468 265870 264889 228595 216027 198798 238146 234891 175816 [71] 239314 73566 242622 187167 209049 360592 342846 207650 206500 182357 [81] 153613 456979 145943 280366 80953 150216 167878 369718 322454 179797 [91] 262883 262793 189142 275997 328875 189252 222504 287386 389104 397681 [101] 287748 294320 186856 43287 185468 235352 268077 305195 143356 154165 [111] 307000 298039 23623 195817 61857 163766 414506 21054 252805 31961 [121] 317367 240153 175083 152043 38214 216299 357602 198104 410803 316105 [131] 397297 187992 102424 286327 407378 143860 391854 157429 258751 282399 [141] 217665 366774 236660 173260 323545 168994 253330 301703 1 14688 [151] 98 455 0 0 246435 382374 0 203 7199 46660 [161] 17547 116678 969 206501 > 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,227636) [227636,506574] 82 82 > colnames(x) [1] "Y" "X1" "X2" "X3" "X4" "X5" "X6" "X7" > colnames(x)[par1] [1] "Y" > x[,par1] [1] [227636,506574] [ 0,227636) [ 0,227636) [ 0,227636) [5] [ 0,227636) [ 0,227636) [227636,506574] [ 0,227636) [9] [ 0,227636) [ 0,227636) [227636,506574] [227636,506574] [13] [ 0,227636) [227636,506574] [227636,506574] [227636,506574] [17] [227636,506574] [227636,506574] [ 0,227636) [227636,506574] [21] [227636,506574] [227636,506574] [ 0,227636) [ 0,227636) [25] [227636,506574] [227636,506574] [227636,506574] [227636,506574] [29] [ 0,227636) [227636,506574] [227636,506574] [ 0,227636) [33] [227636,506574] [ 0,227636) [227636,506574] [227636,506574] [37] [227636,506574] [227636,506574] [ 0,227636) [227636,506574] [41] [227636,506574] [ 0,227636) [ 0,227636) [ 0,227636) [45] [ 0,227636) [227636,506574] [ 0,227636) [ 0,227636) [49] [227636,506574] [ 0,227636) [ 0,227636) [ 0,227636) [53] [227636,506574] [ 0,227636) [ 0,227636) [227636,506574] [57] [227636,506574] [227636,506574] [227636,506574] [227636,506574] [61] [227636,506574] [227636,506574] [227636,506574] [227636,506574] [65] [227636,506574] [ 0,227636) [ 0,227636) [227636,506574] [69] [227636,506574] [ 0,227636) [227636,506574] [ 0,227636) [73] [227636,506574] [ 0,227636) [ 0,227636) [227636,506574] [77] [227636,506574] [ 0,227636) [ 0,227636) [ 0,227636) [81] [ 0,227636) [227636,506574] [ 0,227636) [227636,506574] [85] [ 0,227636) [ 0,227636) [ 0,227636) [227636,506574] [89] [227636,506574] [ 0,227636) [227636,506574] [227636,506574] [93] [ 0,227636) [227636,506574] [227636,506574] [ 0,227636) [97] [ 0,227636) [227636,506574] [227636,506574] [227636,506574] [101] [227636,506574] [227636,506574] [ 0,227636) [ 0,227636) [105] [ 0,227636) [227636,506574] [227636,506574] [227636,506574] [109] [ 0,227636) [ 0,227636) [227636,506574] [227636,506574] [113] [ 0,227636) [ 0,227636) [ 0,227636) [ 0,227636) [117] [227636,506574] [ 0,227636) [227636,506574] [ 0,227636) [121] [227636,506574] [227636,506574] [ 0,227636) [ 0,227636) [125] [ 0,227636) [ 0,227636) [227636,506574] [ 0,227636) [129] [227636,506574] [227636,506574] [227636,506574] [ 0,227636) [133] [ 0,227636) [227636,506574] [227636,506574] [ 0,227636) [137] [227636,506574] [ 0,227636) [227636,506574] [227636,506574] [141] [ 0,227636) [227636,506574] [227636,506574] [ 0,227636) [145] [227636,506574] [ 0,227636) [227636,506574] [227636,506574] [149] [ 0,227636) [ 0,227636) [ 0,227636) [ 0,227636) [153] [ 0,227636) [ 0,227636) [227636,506574] [227636,506574] [157] [ 0,227636) [ 0,227636) [ 0,227636) [ 0,227636) [161] [ 0,227636) [ 0,227636) [ 0,227636) [ 0,227636) Levels: [ 0,227636) [227636,506574] > 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/1f5rf1324311507.tab") + } + } > 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 <= 2081; criterion = 1, statistic = 80.761 2) X4 <= 25696; criterion = 0.996, statistic = 12.091 3)* weights = 68 2) X4 > 25696 4)* weights = 12 1) X1 > 2081 5)* weights = 84 > postscript(file="/var/wessaorg/rcomp/tmp/2tesb1324311507.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/3e07h1324311507.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 1 [2,] 1 1 [3,] 1 1 [4,] 1 2 [5,] 1 1 [6,] 1 1 [7,] 2 2 [8,] 1 1 [9,] 1 1 [10,] 1 1 [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 1 [20,] 2 2 [21,] 2 2 [22,] 2 2 [23,] 1 1 [24,] 1 1 [25,] 2 2 [26,] 2 2 [27,] 2 2 [28,] 2 1 [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,] 2 1 [39,] 1 1 [40,] 2 2 [41,] 2 2 [42,] 1 1 [43,] 1 1 [44,] 1 1 [45,] 1 2 [46,] 2 2 [47,] 1 1 [48,] 1 2 [49,] 2 2 [50,] 1 1 [51,] 1 1 [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,] 1 1 [67,] 1 1 [68,] 2 2 [69,] 2 2 [70,] 1 1 [71,] 2 2 [72,] 1 1 [73,] 2 2 [74,] 1 1 [75,] 1 1 [76,] 2 2 [77,] 2 2 [78,] 1 1 [79,] 1 2 [80,] 1 1 [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 2 [96,] 1 1 [97,] 1 1 [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 1 [112,] 2 2 [113,] 1 1 [114,] 1 2 [115,] 1 1 [116,] 1 1 [117,] 2 2 [118,] 1 1 [119,] 2 2 [120,] 1 1 [121,] 2 2 [122,] 2 2 [123,] 1 1 [124,] 1 1 [125,] 1 1 [126,] 1 1 [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 1 [140,] 2 2 [141,] 1 1 [142,] 2 2 [143,] 2 2 [144,] 1 1 [145,] 2 2 [146,] 1 1 [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,227636) [227636,506574] [ 0,227636) 74 8 [227636,506574] 6 76 > postscript(file="/var/wessaorg/rcomp/tmp/47grx1324311507.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/5leeq1324311507.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/6ajm41324311507.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/77gq21324311508.tab") + } > > try(system("convert tmp/2tesb1324311507.ps tmp/2tesb1324311507.png",intern=TRUE)) character(0) > try(system("convert tmp/3e07h1324311507.ps tmp/3e07h1324311507.png",intern=TRUE)) character(0) > try(system("convert tmp/47grx1324311507.ps tmp/47grx1324311507.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.844 0.280 3.122