R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(1801 + ,159261 + ,48 + ,19 + ,67 + ,20465 + ,6200 + ,23975 + ,1717 + ,189672 + ,53 + ,20 + ,56 + ,33629 + ,10265 + ,85634 + ,192 + ,7215 + ,0 + ,0 + ,0 + ,1423 + ,603 + ,1929 + ,2295 + ,129098 + ,51 + ,27 + ,63 + ,25629 + ,8874 + ,36294 + ,3450 + ,230632 + ,76 + ,31 + ,116 + ,54002 + ,20323 + ,72255 + ,6861 + ,515038 + ,136 + ,36 + ,138 + ,151036 + ,26258 + ,189748 + ,1795 + ,180745 + ,62 + ,23 + ,71 + ,33287 + ,10165 + ,61834 + ,1681 + ,185559 + ,83 + ,30 + ,107 + ,31172 + ,8247 + ,68167 + ,1897 + ,154581 + ,55 + ,30 + ,50 + ,28113 + ,8683 + ,38462 + ,2974 + ,298001 + ,67 + ,26 + ,79 + ,57803 + ,16957 + ,101219 + ,1946 + ,121844 + ,50 + ,24 + ,58 + ,49830 + ,8058 + ,43270 + ,2148 + ,184039 + ,77 + ,30 + ,91 + ,52143 + ,20488 + ,76183 + ,1832 + ,100324 + ,46 + ,22 + ,41 + ,21055 + ,7945 + ,31476 + ,3157 + ,217742 + ,79 + ,28 + ,100 + ,47007 + ,13448 + ,62157 + ,1476 + ,168265 + ,56 + ,18 + ,61 + ,28735 + ,5389 + ,46261 + ,1567 + ,154647 + ,54 + ,22 + ,74 + ,59147 + ,6185 + ,50063 + ,1756 + ,142018 + ,81 + ,33 + ,131 + ,78950 + ,24369 + ,64483 + ,1247 + ,79030 + ,6 + ,15 + ,45 + ,13497 + ,70 + ,2341 + ,2779 + ,167047 + ,74 + ,34 + ,110 + ,46154 + ,17327 + ,48149 + ,726 + ,27997 + ,13 + ,18 + ,41 + ,53249 + ,3878 + ,12743 + ,1048 + ,73019 + ,22 + ,15 + ,37 + ,10726 + ,3149 + ,18743 + ,2805 + ,241082 + ,99 + ,30 + ,84 + ,83700 + ,20517 + ,97057 + ,1760 + ,195820 + ,38 + ,25 + ,67 + ,40400 + ,2570 + ,17675 + ,2266 + ,142001 + ,59 + ,34 + ,69 + ,33797 + ,5162 + ,33106 + ,1848 + ,145433 + ,50 + ,21 + ,58 + ,36205 + ,5299 + ,53311 + ,1665 + ,183744 + ,50 + ,21 + ,60 + ,30165 + ,7233 + ,42754 + ,2082 + ,202232 + ,61 + ,25 + ,88 + ,58534 + ,15657 + ,59056 + ,1440 + ,199532 + ,87 + ,31 + ,75 + ,44663 + ,15329 + ,101621 + ,2741 + ,354924 + ,60 + ,31 + ,98 + ,92556 + ,14881 + ,118120 + ,2112 + ,192399 + ,52 + ,20 + ,67 + ,40078 + ,16318 + ,79572 + ,1684 + ,182286 + ,61 + ,28 + ,84 + ,34711 + ,9556 + ,42744 + ,1616 + ,181590 + ,60 + ,22 + ,62 + ,31076 + ,10462 + ,65931 + ,2227 + ,133801 + ,53 + ,17 + ,35 + ,74608 + ,7192 + ,38575 + ,3088 + ,233686 + ,76 + ,25 + ,74 + ,58092 + ,4362 + ,28795 + ,2389 + ,219428 + ,63 + ,24 + ,89 + ,42009 + ,14349 + ,94440 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,2099 + ,223044 + ,54 + ,28 + ,79 + ,36022 + ,10881 + ,38229 + ,1669 + ,100129 + ,44 + ,14 + ,39 + ,23333 + ,8022 + ,31972 + ,2095 + ,136733 + ,36 + ,35 + ,101 + ,53349 + ,13073 + ,40071 + ,2153 + ,249965 + ,83 + ,34 + ,135 + ,92596 + ,26641 + ,132480 + ,2390 + ,242379 + ,105 + ,22 + ,76 + ,49598 + ,14426 + ,62797 + ,1701 + ,145794 + ,37 + ,34 + ,118 + ,44093 + ,15604 + ,40429 + ,983 + ,96404 + ,25 + ,23 + ,76 + ,84205 + ,9184 + ,45545 + ,2161 + ,195891 + ,64 + ,24 + ,65 + ,63369 + ,5989 + ,57568 + ,1276 + ,117156 + ,55 + ,26 + ,97 + ,60132 + ,11270 + ,39019 + ,1190 + ,157787 + ,41 + ,22 + ,67 + ,37403 + ,13958 + ,53866 + ,745 + ,81293 + ,23 + ,35 + ,63 + ,24460 + ,7162 + ,38345 + ,2330 + ,237435 + ,75 + ,24 + ,96 + ,46456 + ,13275 + ,50210 + ,2289 + ,233155 + ,59 + ,31 + ,112 + ,66616 + ,21224 + ,80947 + ,2639 + ,160344 + ,68 + ,26 + ,75 + ,41554 + ,10615 + ,43461 + ,658 + ,48188 + ,12 + ,22 + ,39 + ,22346 + ,2102 + ,14812 + ,1917 + ,161922 + ,99 + ,21 + ,63 + ,30874 + ,12396 + ,37819 + ,2557 + ,307432 + ,78 + ,27 + ,93 + ,68701 + ,18717 + ,102738 + ,2026 + ,235223 + ,56 + ,30 + ,76 + ,35728 + ,9724 + ,54509 + ,1911 + ,195583 + ,67 + ,33 + ,117 + ,29010 + ,9863 + ,62956 + ,1716 + ,146061 + ,40 + ,11 + ,30 + ,23110 + ,8374 + ,55411 + ,1852 + ,208834 + ,53 + ,26 + ,65 + ,38844 + ,8030 + ,50611 + ,981 + ,93764 + ,26 + ,26 + ,78 + ,27084 + ,7509 + ,26692 + ,1177 + ,151985 + ,67 + ,23 + ,87 + ,35139 + ,14146 + ,60056 + ,2809 + ,190545 + ,36 + ,38 + ,85 + ,57476 + ,7768 + ,25155 + ,1688 + ,148922 + ,50 + ,31 + ,115 + ,33277 + ,13823 + ,42840 + ,2097 + ,132856 + ,48 + ,20 + ,62 + ,31141 + ,7230 + ,39358 + ,1331 + ,129561 + ,46 + ,22 + ,60 + ,61281 + ,10170 + ,47241 + ,1244 + ,112718 + ,53 + ,26 + ,67 + ,25820 + ,7573 + ,49611 + ,1256 + ,160930 + ,27 + ,26 + ,90 + ,23284 + ,5753 + ,41833 + ,1293 + ,99184 + ,38 + ,33 + ,100 + ,35378 + ,9791 + ,48930 + ,2303 + ,192535 + ,71 + ,36 + ,135 + ,74990 + ,19365 + ,110600 + ,2897 + ,138708 + ,93 + ,25 + ,71 + ,29653 + ,9422 + ,52235 + ,1103 + ,114408 + ,59 + ,24 + ,75 + ,64622 + ,12310 + ,53986 + ,340 + ,31970 + ,5 + ,21 + ,42 + ,4157 + ,1283 + ,4105 + ,2791 + ,225558 + ,53 + ,19 + ,42 + ,29245 + ,6372 + ,59331 + ,1333 + ,137011 + ,40 + ,12 + ,8 + ,50008 + ,5413 + ,47796 + ,1441 + ,113612 + ,72 + ,30 + ,86 + ,52338 + ,10837 + ,38302 + ,1623 + ,108641 + ,51 + ,21 + ,41 + ,13310 + ,3394 + ,14063 + ,2650 + ,162203 + ,81 + ,34 + ,118 + ,92901 + ,12964 + ,54414 + ,1499 + ,100098 + ,27 + ,32 + ,91 + ,10956 + ,3495 + ,9903 + ,2302 + ,174768 + ,94 + ,28 + ,102 + ,34241 + ,11580 + ,53987 + ,2540 + ,158459 + ,71 + ,28 + ,89 + ,75043 + ,9970 + ,88937 + ,1000 + ,80934 + ,20 + ,21 + ,46 + ,21152 + ,4911 + ,21928 + ,1234 + ,84971 + ,34 + ,31 + ,60 + ,42249 + ,10138 + ,29487 + ,927 + ,80545 + ,54 + ,26 + ,69 + ,42005 + ,14697 + ,35334 + ,2176 + ,287191 + ,49 + ,29 + ,95 + ,41152 + ,8464 + ,57596 + ,957 + ,62974 + ,26 + ,23 + ,17 + ,14399 + ,4204 + ,29750 + ,1551 + ,134091 + ,48 + ,25 + ,61 + ,28263 + ,10226 + ,41029 + ,1014 + ,75555 + ,35 + ,22 + ,55 + ,17215 + ,3456 + ,12416 + ,1771 + ,162154 + ,32 + ,26 + ,55 + ,48140 + ,8895 + ,51158 + ,2613 + ,226638 + ,55 + ,33 + ,124 + ,62897 + ,22557 + ,79935 + ,1203 + ,115019 + ,58 + ,24 + ,73 + ,22883 + ,6900 + ,26552 + ,1337 + ,108749 + ,44 + ,24 + ,73 + ,41622 + ,8620 + ,25807 + ,1524 + ,155537 + ,45 + ,21 + ,67 + ,40715 + ,7820 + ,50620 + ,1829 + ,153133 + ,49 + ,28 + ,66 + ,65897 + ,12112 + ,61467 + ,2229 + ,165618 + ,72 + ,27 + ,75 + ,76542 + ,13178 + ,65292 + ,1233 + ,151517 + ,39 + ,25 + ,83 + ,37477 + ,7028 + ,55516 + ,1365 + ,133686 + ,28 + ,15 + ,55 + ,53216 + ,6616 + ,42006 + ,950 + ,61342 + ,24 + ,13 + ,27 + ,40911 + ,9570 + ,26273 + ,2319 + ,245196 + ,52 + ,36 + ,115 + ,57021 + ,14612 + ,90248 + ,1857 + ,195576 + ,96 + ,24 + ,76 + ,73116 + ,11219 + ,61476 + ,223 + ,19349 + ,13 + ,1 + ,0 + ,3895 + ,786 + ,9604 + ,2390 + ,225371 + ,38 + ,24 + ,83 + ,46609 + ,11252 + ,45108 + ,1973 + ,152796 + ,41 + ,31 + ,90 + ,29351 + ,9289 + ,47232 + ,700 + ,59117 + ,24 + ,4 + ,4 + ,2325 + ,593 + ,3439 + ,1062 + ,91762 + ,54 + ,21 + ,60 + ,31747 + ,6562 + ,30553 + ,1311 + ,136769 + ,68 + ,23 + ,63 + ,32665 + ,8208 + ,24751 + ,1157 + ,114798 + ,28 + ,23 + ,52 + ,19249 + ,7488 + ,34458 + ,823 + ,85338 + ,36 + ,12 + ,24 + ,15292 + ,4574 + ,24649 + ,596 + ,27676 + ,2 + ,16 + ,17 + ,5842 + ,522 + ,2342 + ,1545 + ,153535 + ,91 + ,29 + ,105 + ,33994 + ,12840 + ,52739 + ,1130 + ,122417 + ,29 + ,26 + ,20 + ,13018 + ,1350 + ,6245 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1082 + ,91529 + ,46 + ,25 + ,51 + ,98177 + ,10623 + ,35381 + ,1135 + ,107205 + ,25 + ,21 + ,76 + ,37941 + ,5322 + ,19595 + ,1367 + ,144664 + ,51 + ,23 + ,59 + ,31032 + ,7987 + ,50848 + ,1452 + ,136540 + ,59 + ,21 + ,70 + ,32683 + ,10566 + ,39443 + ,870 + ,76656 + ,36 + ,21 + ,38 + ,34545 + ,1900 + ,27023 + ,78 + ,3616 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1127 + ,183065 + ,40 + ,23 + ,81 + ,27525 + ,10698 + ,61022 + ,1582 + ,144677 + ,68 + ,33 + ,78 + ,66856 + ,14884 + ,63528 + ,2034 + ,159104 + ,28 + ,30 + ,73 + ,28549 + ,6852 + ,34835 + ,919 + ,113273 + ,36 + ,23 + ,89 + ,38610 + ,6873 + ,37172 + ,778 + ,43410 + ,7 + ,1 + ,3 + ,2781 + ,4 + ,13 + ,1752 + ,175774 + ,70 + ,29 + ,87 + ,41211 + ,9188 + ,62548 + ,957 + ,95401 + ,30 + ,18 + ,51 + ,22698 + ,5141 + ,31334 + ,2098 + ,134837 + ,69 + ,33 + ,73 + ,41194 + ,4260 + ,20839 + ,731 + ,60493 + ,3 + ,12 + ,32 + ,32689 + ,443 + ,5084 + ,285 + ,19764 + ,10 + ,2 + ,4 + ,5752 + ,2416 + ,9927 + ,1834 + ,164062 + ,46 + ,21 + ,70 + ,26757 + ,9831 + ,53229 + ,1147 + ,132696 + ,34 + ,28 + ,102 + ,22527 + ,5953 + ,29877 + ,1646 + ,155367 + ,54 + ,29 + ,91 + ,44810 + ,9435 + ,37310 + ,256 + ,11796 + ,1 + ,2 + ,1 + ,0 + ,0 + ,0 + ,98 + ,10674 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1404 + ,142261 + ,39 + ,18 + ,39 + ,100674 + ,7642 + ,50067 + ,41 + ,6836 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,1824 + ,162563 + ,48 + ,21 + ,45 + ,57786 + ,6837 + ,47708 + ,42 + ,5118 + ,5 + ,0 + ,0 + ,0 + ,0 + ,0 + ,528 + ,40248 + ,8 + ,4 + ,7 + ,5444 + ,775 + ,6012 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1073 + ,122641 + ,38 + ,25 + ,75 + ,28470 + ,8191 + ,27749 + ,1305 + ,88837 + ,21 + ,26 + ,52 + ,61849 + ,1661 + ,47555 + ,81 + ,7131 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,261 + ,9056 + ,0 + ,4 + ,1 + ,2179 + ,548 + ,1336 + ,934 + ,76611 + ,15 + ,17 + ,49 + ,8019 + ,3080 + ,11017 + ,1180 + ,132697 + ,50 + ,21 + ,69 + ,39644 + ,13400 + ,55184 + ,1147 + ,100681 + ,17 + ,22 + ,56 + ,23494 + ,8181 + ,43485) + ,dim=c(8 + ,144) + ,dimnames=list(c('X1' + ,'Y' + ,'X2' + ,'X3' + ,'X4' + ,'X5' + ,'X6' + ,'X7') + ,1:144)) > y <- array(NA,dim=c(8,144),dimnames=list(c('X1','Y','X2','X3','X4','X5','X6','X7'),1:144)) > 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 = '8' > #'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] "X7" > x[,par1] [1] 23975 85634 1929 36294 72255 189748 61834 68167 38462 101219 [11] 43270 76183 31476 62157 46261 50063 64483 2341 48149 12743 [21] 18743 97057 17675 33106 53311 42754 59056 101621 118120 79572 [31] 42744 65931 38575 28795 94440 0 38229 31972 40071 132480 [41] 62797 40429 45545 57568 39019 53866 38345 50210 80947 43461 [51] 14812 37819 102738 54509 62956 55411 50611 26692 60056 25155 [61] 42840 39358 47241 49611 41833 48930 110600 52235 53986 4105 [71] 59331 47796 38302 14063 54414 9903 53987 88937 21928 29487 [81] 35334 57596 29750 41029 12416 51158 79935 26552 25807 50620 [91] 61467 65292 55516 42006 26273 90248 61476 9604 45108 47232 [101] 3439 30553 24751 34458 24649 2342 52739 6245 0 35381 [111] 19595 50848 39443 27023 0 0 61022 63528 34835 37172 [121] 13 62548 31334 20839 5084 9927 53229 29877 37310 0 [131] 0 50067 0 47708 0 6012 0 27749 47555 0 [141] 1336 11017 55184 43485 > 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 13 1336 1929 2341 2342 3439 4105 5084 6012 6245 10 1 1 1 1 1 1 1 1 1 1 9604 9903 9927 11017 12416 12743 14063 14812 17675 18743 19595 1 1 1 1 1 1 1 1 1 1 1 20839 21928 23975 24649 24751 25155 25807 26273 26552 26692 27023 1 1 1 1 1 1 1 1 1 1 1 27749 28795 29487 29750 29877 30553 31334 31476 31972 33106 34458 1 1 1 1 1 1 1 1 1 1 1 34835 35334 35381 36294 37172 37310 37819 38229 38302 38345 38462 1 1 1 1 1 1 1 1 1 1 1 38575 39019 39358 39443 40071 40429 41029 41833 42006 42744 42754 1 1 1 1 1 1 1 1 1 1 1 42840 43270 43461 43485 45108 45545 46261 47232 47241 47555 47708 1 1 1 1 1 1 1 1 1 1 1 47796 48149 48930 49611 50063 50067 50210 50611 50620 50848 51158 1 1 1 1 1 1 1 1 1 1 1 52235 52739 53229 53311 53866 53986 53987 54414 54509 55184 55411 1 1 1 1 1 1 1 1 1 1 1 55516 57568 57596 59056 59331 60056 61022 61467 61476 61834 62157 1 1 1 1 1 1 1 1 1 1 1 62548 62797 62956 63528 64483 65292 65931 68167 72255 76183 79572 1 1 1 1 1 1 1 1 1 1 1 79935 80947 85634 88937 90248 94440 97057 101219 101621 102738 110600 1 1 1 1 1 1 1 1 1 1 1 118120 132480 189748 1 1 1 > colnames(x) [1] "X1" "Y" "X2" "X3" "X4" "X5" "X6" "X7" > colnames(x)[par1] [1] "X7" > x[,par1] [1] 23975 85634 1929 36294 72255 189748 61834 68167 38462 101219 [11] 43270 76183 31476 62157 46261 50063 64483 2341 48149 12743 [21] 18743 97057 17675 33106 53311 42754 59056 101621 118120 79572 [31] 42744 65931 38575 28795 94440 0 38229 31972 40071 132480 [41] 62797 40429 45545 57568 39019 53866 38345 50210 80947 43461 [51] 14812 37819 102738 54509 62956 55411 50611 26692 60056 25155 [61] 42840 39358 47241 49611 41833 48930 110600 52235 53986 4105 [71] 59331 47796 38302 14063 54414 9903 53987 88937 21928 29487 [81] 35334 57596 29750 41029 12416 51158 79935 26552 25807 50620 [91] 61467 65292 55516 42006 26273 90248 61476 9604 45108 47232 [101] 3439 30553 24751 34458 24649 2342 52739 6245 0 35381 [111] 19595 50848 39443 27023 0 0 61022 63528 34835 37172 [121] 13 62548 31334 20839 5084 9927 53229 29877 37310 0 [131] 0 50067 0 47708 0 6012 0 27749 47555 0 [141] 1336 11017 55184 43485 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/1ok9p1324479638.tab") + } + } > m Conditional inference tree with 8 terminal nodes Response: X7 Inputs: X1, Y, X2, X3, X4, X5, X6 Number of observations: 144 1) Y <= 136769; criterion = 1, statistic = 105.929 2) X6 <= 3878; criterion = 1, statistic = 52.326 3) X5 <= 5842; criterion = 1, statistic = 19.614 4)* weights = 19 3) X5 > 5842 5)* weights = 12 2) X6 > 3878 6) X6 <= 6562; criterion = 0.997, statistic = 12.367 7)* weights = 8 6) X6 > 6562 8)* weights = 31 1) Y > 136769 9) Y <= 242379; criterion = 1, statistic = 37.442 10) X6 <= 14146; criterion = 1, statistic = 25.286 11) X6 <= 7768; criterion = 0.98, statistic = 8.887 12)* weights = 17 11) X6 > 7768 13)* weights = 35 10) X6 > 14146 14)* weights = 15 9) Y > 242379 15)* weights = 7 > postscript(file="/var/www/rcomp/tmp/2wcuz1324479638.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/www/rcomp/tmp/3q5lk1324479638.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 23975 42102.882 -18127.8824 2 85634 54986.257 30647.7429 3 1929 2037.211 -108.2105 4 36294 37832.194 -1538.1935 5 72255 75403.467 -3148.4667 6 189748 113164.143 76583.8571 7 61834 54986.257 6847.7429 8 68167 54986.257 13180.7429 9 38462 54986.257 -16524.2571 10 101219 113164.143 -11945.1429 11 43270 37832.194 5437.8065 12 76183 75403.467 779.5333 13 31476 37832.194 -6356.1935 14 62157 54986.257 7170.7429 15 46261 42102.882 4158.1176 16 50063 42102.882 7960.1176 17 64483 75403.467 -10920.4667 18 2341 15162.083 -12821.0833 19 48149 75403.467 -27254.4667 20 12743 15162.083 -2419.0833 21 18743 15162.083 3580.9167 22 97057 75403.467 21653.5333 23 17675 42102.882 -24427.8824 24 33106 42102.882 -8996.8824 25 53311 42102.882 11208.1176 26 42754 42102.882 651.1176 27 59056 75403.467 -16347.4667 28 101621 75403.467 26217.5333 29 118120 113164.143 4955.8571 30 79572 75403.467 4168.5333 31 42744 54986.257 -12242.2571 32 65931 54986.257 10944.7429 33 38575 37832.194 742.8065 34 28795 42102.882 -13307.8824 35 94440 75403.467 19036.5333 36 0 2037.211 -2037.2105 37 38229 54986.257 -16757.2571 38 31972 37832.194 -5860.1935 39 40071 37832.194 2238.8065 40 132480 113164.143 19315.8571 41 62797 75403.467 -12606.4667 42 40429 75403.467 -34974.4667 43 45545 37832.194 7712.8065 44 57568 42102.882 15465.1176 45 39019 37832.194 1186.8065 46 53866 54986.257 -1120.2571 47 38345 37832.194 512.8065 48 50210 54986.257 -4776.2571 49 80947 75403.467 5543.5333 50 43461 54986.257 -11525.2571 51 14812 15162.083 -350.0833 52 37819 54986.257 -17167.2571 53 102738 113164.143 -10426.1429 54 54509 54986.257 -477.2571 55 62956 54986.257 7969.7429 56 55411 54986.257 424.7429 57 50611 54986.257 -4375.2571 58 26692 37832.194 -11140.1935 59 60056 54986.257 5069.7429 60 25155 42102.882 -16947.8824 61 42840 54986.257 -12146.2571 62 39358 37832.194 1525.8065 63 47241 37832.194 9408.8065 64 49611 37832.194 11778.8065 65 41833 42102.882 -269.8824 66 48930 37832.194 11097.8065 67 110600 75403.467 35196.5333 68 52235 54986.257 -2751.2571 69 53986 37832.194 16153.8065 70 4105 2037.211 2067.7895 71 59331 42102.882 17228.1176 72 47796 42102.882 5693.1176 73 38302 37832.194 469.8065 74 14063 15162.083 -1099.0833 75 54414 54986.257 -572.2571 76 9903 15162.083 -5259.0833 77 53987 54986.257 -999.2571 78 88937 54986.257 33950.7429 79 21928 26065.625 -4137.6250 80 29487 37832.194 -8345.1935 81 35334 37832.194 -2498.1935 82 57596 113164.143 -55568.1429 83 29750 26065.625 3684.3750 84 41029 37832.194 3196.8065 85 12416 15162.083 -2746.0833 86 51158 54986.257 -3828.2571 87 79935 75403.467 4531.5333 88 26552 37832.194 -11280.1935 89 25807 37832.194 -12025.1935 90 50620 54986.257 -4366.2571 91 61467 54986.257 6480.7429 92 65292 54986.257 10305.7429 93 55516 42102.882 13413.1176 94 42006 37832.194 4173.8065 95 26273 37832.194 -11559.1935 96 90248 113164.143 -22916.1429 97 61476 54986.257 6489.7429 98 9604 2037.211 7566.7895 99 45108 54986.257 -9878.2571 100 47232 54986.257 -7754.2571 101 3439 2037.211 1401.7895 102 30553 26065.625 4487.3750 103 24751 37832.194 -13081.1935 104 34458 37832.194 -3374.1935 105 24649 26065.625 -1416.6250 106 2342 2037.211 304.7895 107 52739 54986.257 -2247.2571 108 6245 15162.083 -8917.0833 109 0 2037.211 -2037.2105 110 35381 37832.194 -2451.1935 111 19595 26065.625 -6470.6250 112 50848 54986.257 -4138.2571 113 39443 37832.194 1610.8065 114 27023 15162.083 11860.9167 115 0 2037.211 -2037.2105 116 0 2037.211 -2037.2105 117 61022 54986.257 6035.7429 118 63528 75403.467 -11875.4667 119 34835 42102.882 -7267.8824 120 37172 37832.194 -660.1935 121 13 2037.211 -2024.2105 122 62548 54986.257 7561.7429 123 31334 26065.625 5268.3750 124 20839 26065.625 -5226.6250 125 5084 15162.083 -10078.0833 126 9927 2037.211 7889.7895 127 53229 54986.257 -1757.2571 128 29877 26065.625 3811.3750 129 37310 54986.257 -17676.2571 130 0 2037.211 -2037.2105 131 0 2037.211 -2037.2105 132 50067 42102.882 7964.1176 133 0 2037.211 -2037.2105 134 47708 42102.882 5605.1176 135 0 2037.211 -2037.2105 136 6012 2037.211 3974.7895 137 0 2037.211 -2037.2105 138 27749 37832.194 -10083.1935 139 47555 15162.083 32392.9167 140 0 2037.211 -2037.2105 141 1336 2037.211 -701.2105 142 11017 15162.083 -4145.0833 143 55184 37832.194 17351.8065 144 43485 37832.194 5652.8065 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/www/rcomp/tmp/4fgbp1324479638.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/www/rcomp/tmp/5lae31324479638.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/www/rcomp/tmp/6dj8j1324479638.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/www/rcomp/tmp/7a32i1324479638.tab") + } > > try(system("convert tmp/2wcuz1324479638.ps tmp/2wcuz1324479638.png",intern=TRUE)) character(0) > try(system("convert tmp/3q5lk1324479638.ps tmp/3q5lk1324479638.png",intern=TRUE)) character(0) > try(system("convert tmp/4fgbp1324479638.ps tmp/4fgbp1324479638.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.130 0.180 3.293