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(1773 + ,158258 + ,90 + ,48 + ,20465 + ,6200 + ,1704 + ,186930 + ,58 + ,53 + ,33629 + ,10265 + ,192 + ,7215 + ,18 + ,0 + ,1423 + ,603 + ,2295 + ,129098 + ,95 + ,51 + ,25629 + ,8874 + ,3450 + ,230632 + ,136 + ,76 + ,54002 + ,20323 + ,6813 + ,508313 + ,261 + ,128 + ,151036 + ,26258 + ,1795 + ,180745 + ,56 + ,62 + ,33287 + ,10165 + ,1681 + ,185559 + ,59 + ,83 + ,31172 + ,8247 + ,1897 + ,154581 + ,44 + ,55 + ,28113 + ,8683 + ,2917 + ,290658 + ,95 + ,67 + ,57803 + ,16957 + ,1946 + ,121844 + ,75 + ,50 + ,49830 + ,8058 + ,2148 + ,184039 + ,69 + ,77 + ,52143 + ,20488 + ,1832 + ,100324 + ,98 + ,46 + ,21055 + ,7945 + ,3138 + ,215855 + ,117 + ,79 + ,47007 + ,13448 + ,1476 + ,168265 + ,58 + ,56 + ,28735 + ,5389 + ,1567 + ,154647 + ,88 + ,54 + ,59147 + ,6185 + ,1756 + ,142018 + ,57 + ,81 + ,78950 + ,24369 + ,1247 + ,79030 + ,61 + ,6 + ,13497 + ,70 + ,2779 + ,167047 + ,87 + ,74 + ,46154 + ,17327 + ,726 + ,27997 + ,24 + ,13 + ,53249 + ,3878 + ,1048 + ,73019 + ,59 + ,22 + ,10726 + ,3149 + ,2805 + ,241082 + ,100 + ,99 + ,83700 + ,20517 + ,1760 + ,195820 + ,72 + ,38 + ,40400 + ,2570 + ,2261 + ,141899 + ,53 + ,59 + ,33797 + ,5162 + ,1848 + ,145433 + ,86 + ,50 + ,36205 + ,5299 + ,1665 + ,183744 + ,32 + ,50 + ,30165 + ,7233 + ,2082 + ,202232 + ,161 + ,61 + ,58534 + ,15657 + ,1440 + ,199532 + ,93 + ,87 + ,44663 + ,15329 + ,2741 + ,354924 + ,118 + ,60 + ,92556 + ,14881 + ,2112 + ,192399 + ,44 + ,52 + ,40078 + ,16318 + ,1684 + ,182286 + ,44 + ,61 + ,34711 + ,9556 + ,1616 + ,181590 + ,45 + ,60 + ,31076 + ,10462 + ,2227 + ,133801 + ,105 + ,53 + ,74608 + ,7192 + ,3088 + ,233686 + ,123 + ,76 + ,58092 + ,4362 + ,2389 + ,219428 + ,53 + ,63 + ,42009 + ,14349 + ,1 + ,0 + ,1 + ,0 + ,0 + ,0 + ,2099 + ,223044 + ,63 + ,54 + ,36022 + ,10881 + ,1669 + ,100129 + ,51 + ,44 + ,23333 + ,8022 + ,2095 + ,136733 + ,48 + ,36 + ,53349 + ,13073 + ,2153 + ,249965 + ,64 + ,83 + ,92596 + ,26641 + ,2390 + ,242379 + ,71 + ,105 + ,49598 + ,14426 + ,1701 + ,145794 + ,59 + ,37 + ,44093 + ,15604 + ,983 + ,96404 + ,32 + ,25 + ,84205 + ,9184 + ,2161 + ,195891 + ,78 + ,64 + ,63369 + ,5989 + ,1276 + ,117156 + ,50 + ,55 + ,60132 + ,11270 + ,1189 + ,157787 + ,94 + ,41 + ,37403 + ,13958 + ,745 + ,81293 + ,32 + ,23 + ,24460 + ,7162 + ,2231 + ,224049 + ,100 + ,67 + ,46456 + ,13275 + ,2242 + ,223789 + ,87 + ,54 + ,66616 + ,21224 + ,2639 + ,160344 + ,59 + ,68 + ,41554 + ,10615 + ,658 + ,48188 + ,28 + ,12 + ,22346 + ,2102 + ,1917 + ,161922 + ,69 + ,99 + ,30874 + ,12396 + ,2489 + ,294283 + ,73 + ,74 + ,68701 + ,18717 + ,2026 + ,235223 + ,79 + ,56 + ,35728 + ,9724 + ,1911 + ,195583 + ,59 + ,67 + ,29010 + ,9863 + ,1716 + ,146061 + ,56 + ,40 + ,23110 + ,8374 + ,1852 + ,208834 + ,67 + ,53 + ,38844 + ,8030 + ,981 + ,93764 + ,24 + ,26 + ,27084 + ,7509 + ,1177 + ,151985 + ,66 + ,67 + ,35139 + ,14146 + ,2809 + ,190545 + ,95 + ,36 + ,57476 + ,7768 + ,1688 + ,148922 + ,60 + ,50 + ,33277 + ,13823 + ,2097 + ,132856 + ,80 + ,48 + ,31141 + ,7230 + ,1309 + ,126107 + ,60 + ,46 + ,61281 + ,10170 + ,1244 + ,112718 + ,37 + ,53 + ,25820 + ,7573 + ,1256 + ,160930 + ,35 + ,27 + ,23284 + ,5753 + ,1293 + ,99184 + ,40 + ,38 + ,35378 + ,9791 + ,2303 + ,192535 + ,70 + ,71 + ,74990 + ,19365 + ,2897 + ,138708 + ,65 + ,93 + ,29653 + ,9422 + ,1103 + ,114408 + ,38 + ,59 + ,64622 + ,12310 + ,340 + ,31970 + ,15 + ,5 + ,4157 + ,1283 + ,2791 + ,225558 + ,112 + ,53 + ,29245 + ,6372 + ,1333 + ,137011 + ,71 + ,40 + ,50008 + ,5413 + ,1441 + ,113612 + ,68 + ,72 + ,52338 + ,10837 + ,1623 + ,108641 + ,71 + ,51 + ,13310 + ,3394 + ,2650 + ,162203 + ,67 + ,81 + ,92901 + ,12964 + ,1499 + ,100098 + ,44 + ,27 + ,10956 + ,3495 + ,2302 + ,174768 + ,60 + ,94 + ,34241 + ,11580 + ,2540 + ,158459 + ,97 + ,71 + ,75043 + ,9970 + ,1000 + ,80934 + ,30 + ,20 + ,21152 + ,4911 + ,1234 + ,84971 + ,71 + ,34 + ,42249 + ,10138 + ,927 + ,80545 + ,68 + ,54 + ,42005 + ,14697 + ,2176 + ,287191 + ,64 + ,49 + ,41152 + ,8464 + ,957 + ,62974 + ,28 + ,26 + ,14399 + ,4204 + ,1551 + ,134091 + ,40 + ,48 + ,28263 + ,10226 + ,1014 + ,75555 + ,46 + ,35 + ,17215 + ,3456 + ,1771 + ,162154 + ,54 + ,32 + ,48140 + ,8895 + ,2613 + ,226638 + ,227 + ,55 + ,62897 + ,22557 + ,1203 + ,115019 + ,110 + ,58 + ,22883 + ,6900 + ,1337 + ,108749 + ,62 + ,44 + ,41622 + ,8620 + ,1524 + ,155537 + ,52 + ,45 + ,40715 + ,7820 + ,1829 + ,153133 + ,41 + ,49 + ,65897 + ,12112 + ,2229 + ,165618 + ,78 + ,72 + ,76542 + ,13178 + ,1233 + ,151517 + ,57 + ,39 + ,37477 + ,7028 + ,1365 + ,133686 + ,58 + ,28 + ,53216 + ,6616 + ,950 + ,61342 + ,40 + ,24 + ,40911 + ,9570 + ,2319 + ,245196 + ,117 + ,52 + ,57021 + ,14612 + ,1857 + ,195576 + ,70 + ,96 + ,73116 + ,11219 + ,223 + ,19349 + ,12 + ,13 + ,3895 + ,786 + ,2390 + ,225371 + ,105 + ,38 + ,46609 + ,11252 + ,1973 + ,152796 + ,76 + ,41 + ,29351 + ,9289 + ,700 + ,59117 + ,29 + ,24 + ,2325 + ,593 + ,1062 + ,91762 + ,24 + ,54 + ,31747 + ,6562 + ,1311 + ,136769 + ,54 + ,68 + ,32665 + ,8208 + ,1157 + ,114798 + ,61 + ,28 + ,19249 + ,7488 + ,823 + ,85338 + ,40 + ,36 + ,15292 + ,4574 + ,596 + ,27676 + ,22 + ,2 + ,5842 + ,522 + ,1545 + ,153535 + ,48 + ,91 + ,33994 + ,12840 + ,1130 + ,122417 + ,37 + ,29 + ,13018 + ,1350 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1082 + ,91529 + ,32 + ,46 + ,98177 + ,10623 + ,1135 + ,107205 + ,67 + ,25 + ,37941 + ,5322 + ,1366 + ,144664 + ,44 + ,51 + ,31032 + ,7987 + ,1452 + ,136540 + ,62 + ,59 + ,32683 + ,10566 + ,870 + ,76656 + ,60 + ,36 + ,34545 + ,1900 + ,78 + ,3616 + ,5 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1127 + ,183065 + ,43 + ,40 + ,27525 + ,10698 + ,1582 + ,144677 + ,84 + ,68 + ,66856 + ,14884 + ,2034 + ,159104 + ,98 + ,28 + ,28549 + ,6852 + ,919 + ,113273 + ,38 + ,36 + ,38610 + ,6873 + ,778 + ,43410 + ,19 + ,7 + ,2781 + ,4 + ,1752 + ,175774 + ,73 + ,70 + ,41211 + ,9188 + ,957 + ,95401 + ,42 + ,30 + ,22698 + ,5141 + ,1875 + ,118893 + ,54 + ,59 + ,41194 + ,4260 + ,731 + ,60493 + ,40 + ,3 + ,32689 + ,443 + ,285 + ,19764 + ,12 + ,10 + ,5752 + ,2416 + ,1834 + ,164062 + ,56 + ,46 + ,26757 + ,9831 + ,1147 + ,132696 + ,32 + ,34 + ,22527 + ,5953 + ,1646 + ,155367 + ,54 + ,54 + ,44810 + ,9435 + ,256 + ,11796 + ,9 + ,1 + ,0 + ,0 + ,98 + ,10674 + ,9 + ,0 + ,0 + ,0 + ,1404 + ,142261 + ,57 + ,39 + ,100674 + ,7642 + ,41 + ,6836 + ,3 + ,0 + ,0 + ,0 + ,1824 + ,162563 + ,63 + ,48 + ,57786 + ,6837 + ,42 + ,5118 + ,3 + ,5 + ,0 + ,0 + ,528 + ,40248 + ,16 + ,8 + ,5444 + ,775 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1073 + ,122641 + ,47 + ,38 + ,28470 + ,8191 + ,1305 + ,88837 + ,38 + ,21 + ,61849 + ,1661 + ,81 + ,7131 + ,4 + ,0 + ,0 + ,0 + ,261 + ,9056 + ,14 + ,0 + ,2179 + ,548 + ,934 + ,76611 + ,24 + ,15 + ,8019 + ,3080 + ,1179 + ,132697 + ,50 + ,50 + ,39644 + ,13400 + ,1147 + ,100681 + ,19 + ,17 + ,23494 + ,8181) + ,dim=c(6 + ,144) + ,dimnames=list(c('TNP' + ,'TTS' + ,'NL' + ,'BC' + ,'CWNC' + ,'CWNR') + ,1:144)) > y <- array(NA,dim=c(6,144),dimnames=list(c('TNP','TTS','NL','BC','CWNC','CWNR'),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 = '0' > par2 = 'none' > par1 = '2' > #'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] "TTS" > x[,par1] [1] 158258 186930 7215 129098 230632 508313 180745 185559 154581 290658 [11] 121844 184039 100324 215855 168265 154647 142018 79030 167047 27997 [21] 73019 241082 195820 141899 145433 183744 202232 199532 354924 192399 [31] 182286 181590 133801 233686 219428 0 223044 100129 136733 249965 [41] 242379 145794 96404 195891 117156 157787 81293 224049 223789 160344 [51] 48188 161922 294283 235223 195583 146061 208834 93764 151985 190545 [61] 148922 132856 126107 112718 160930 99184 192535 138708 114408 31970 [71] 225558 137011 113612 108641 162203 100098 174768 158459 80934 84971 [81] 80545 287191 62974 134091 75555 162154 226638 115019 108749 155537 [91] 153133 165618 151517 133686 61342 245196 195576 19349 225371 152796 [101] 59117 91762 136769 114798 85338 27676 153535 122417 0 91529 [111] 107205 144664 136540 76656 3616 0 183065 144677 159104 113273 [121] 43410 175774 95401 118893 60493 19764 164062 132696 155367 11796 [131] 10674 142261 6836 162563 5118 40248 0 122641 88837 7131 [141] 9056 76611 132697 100681 > 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 3616 5118 6836 7131 7215 9056 10674 11796 19349 19764 4 1 1 1 1 1 1 1 1 1 1 27676 27997 31970 40248 43410 48188 59117 60493 61342 62974 73019 1 1 1 1 1 1 1 1 1 1 1 75555 76611 76656 79030 80545 80934 81293 84971 85338 88837 91529 1 1 1 1 1 1 1 1 1 1 1 91762 93764 95401 96404 99184 100098 100129 100324 100681 107205 108641 1 1 1 1 1 1 1 1 1 1 1 108749 112718 113273 113612 114408 114798 115019 117156 118893 121844 122417 1 1 1 1 1 1 1 1 1 1 1 122641 126107 129098 132696 132697 132856 133686 133801 134091 136540 136733 1 1 1 1 1 1 1 1 1 1 1 136769 137011 138708 141899 142018 142261 144664 144677 145433 145794 146061 1 1 1 1 1 1 1 1 1 1 1 148922 151517 151985 152796 153133 153535 154581 154647 155367 155537 157787 1 1 1 1 1 1 1 1 1 1 1 158258 158459 159104 160344 160930 161922 162154 162203 162563 164062 165618 1 1 1 1 1 1 1 1 1 1 1 167047 168265 174768 175774 180745 181590 182286 183065 183744 184039 185559 1 1 1 1 1 1 1 1 1 1 1 186930 190545 192399 192535 195576 195583 195820 195891 199532 202232 208834 1 1 1 1 1 1 1 1 1 1 1 215855 219428 223044 223789 224049 225371 225558 226638 230632 233686 235223 1 1 1 1 1 1 1 1 1 1 1 241082 242379 245196 249965 287191 290658 294283 354924 508313 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "TNP" "TTS" "NL" "BC" "CWNC" "CWNR" > colnames(x)[par1] [1] "TTS" > x[,par1] [1] 158258 186930 7215 129098 230632 508313 180745 185559 154581 290658 [11] 121844 184039 100324 215855 168265 154647 142018 79030 167047 27997 [21] 73019 241082 195820 141899 145433 183744 202232 199532 354924 192399 [31] 182286 181590 133801 233686 219428 0 223044 100129 136733 249965 [41] 242379 145794 96404 195891 117156 157787 81293 224049 223789 160344 [51] 48188 161922 294283 235223 195583 146061 208834 93764 151985 190545 [61] 148922 132856 126107 112718 160930 99184 192535 138708 114408 31970 [71] 225558 137011 113612 108641 162203 100098 174768 158459 80934 84971 [81] 80545 287191 62974 134091 75555 162154 226638 115019 108749 155537 [91] 153133 165618 151517 133686 61342 245196 195576 19349 225371 152796 [101] 59117 91762 136769 114798 85338 27676 153535 122417 0 91529 [111] 107205 144664 136540 76656 3616 0 183065 144677 159104 113273 [121] 43410 175774 95401 118893 60493 19764 164062 132696 155367 11796 [131] 10674 142261 6836 162563 5118 40248 0 122641 88837 7131 [141] 9056 76611 132697 100681 > 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/1oz011324475135.tab") + } + } > m Conditional inference tree with 7 terminal nodes Response: TTS Inputs: TNP, NL, BC, CWNC, CWNR Number of observations: 144 1) TNP <= 1082; criterion = 1, statistic = 113.354 2) TNP <= 726; criterion = 1, statistic = 33.107 3) TNP <= 261; criterion = 1, statistic = 15.611 4)* weights = 13 3) TNP > 261 5)* weights = 7 2) TNP > 726 6)* weights = 19 1) TNP > 1082 7) TNP <= 2097; criterion = 1, statistic = 62.609 8) TNP <= 1365; criterion = 1, statistic = 16.49 9)* weights = 24 8) TNP > 1365 10)* weights = 47 7) TNP > 2097 11) TNP <= 2650; criterion = 1, statistic = 15.895 12)* weights = 23 11) TNP > 2650 13)* weights = 11 > postscript(file="/var/wessaorg/rcomp/tmp/2k9wc1324475135.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/3tomk1324475135.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 158258 157211.553 1046.4468 2 186930 157211.553 29718.4468 3 7215 6214.692 1000.3077 4 129098 202277.696 -73179.6957 5 230632 254273.455 -23641.4545 6 508313 254273.455 254039.5455 7 180745 157211.553 23533.4468 8 185559 157211.553 28347.4468 9 154581 157211.553 -2630.5532 10 290658 254273.455 36384.5455 11 121844 157211.553 -35367.5532 12 184039 202277.696 -18238.6957 13 100324 157211.553 -56887.5532 14 215855 254273.455 -38418.4545 15 168265 157211.553 11053.4468 16 154647 157211.553 -2564.5532 17 142018 157211.553 -15193.5532 18 79030 123725.958 -44695.9583 19 167047 254273.455 -87226.4545 20 27997 36422.857 -8425.8571 21 73019 82260.211 -9241.2105 22 241082 254273.455 -13191.4545 23 195820 157211.553 38608.4468 24 141899 202277.696 -60378.6957 25 145433 157211.553 -11778.5532 26 183744 157211.553 26532.4468 27 202232 157211.553 45020.4468 28 199532 157211.553 42320.4468 29 354924 254273.455 100650.5455 30 192399 202277.696 -9878.6957 31 182286 157211.553 25074.4468 32 181590 157211.553 24378.4468 33 133801 202277.696 -68476.6957 34 233686 254273.455 -20587.4545 35 219428 202277.696 17150.3043 36 0 6214.692 -6214.6923 37 223044 202277.696 20766.3043 38 100129 157211.553 -57082.5532 39 136733 157211.553 -20478.5532 40 249965 202277.696 47687.3043 41 242379 202277.696 40101.3043 42 145794 157211.553 -11417.5532 43 96404 82260.211 14143.7895 44 195891 202277.696 -6386.6957 45 117156 123725.958 -6569.9583 46 157787 123725.958 34061.0417 47 81293 82260.211 -967.2105 48 224049 202277.696 21771.3043 49 223789 202277.696 21511.3043 50 160344 202277.696 -41933.6957 51 48188 36422.857 11765.1429 52 161922 157211.553 4710.4468 53 294283 202277.696 92005.3043 54 235223 157211.553 78011.4468 55 195583 157211.553 38371.4468 56 146061 157211.553 -11150.5532 57 208834 157211.553 51622.4468 58 93764 82260.211 11503.7895 59 151985 123725.958 28259.0417 60 190545 254273.455 -63728.4545 61 148922 157211.553 -8289.5532 62 132856 157211.553 -24355.5532 63 126107 123725.958 2381.0417 64 112718 123725.958 -11007.9583 65 160930 123725.958 37204.0417 66 99184 123725.958 -24541.9583 67 192535 202277.696 -9742.6957 68 138708 254273.455 -115565.4545 69 114408 123725.958 -9317.9583 70 31970 36422.857 -4452.8571 71 225558 254273.455 -28715.4545 72 137011 123725.958 13285.0417 73 113612 157211.553 -43599.5532 74 108641 157211.553 -48570.5532 75 162203 202277.696 -40074.6957 76 100098 157211.553 -57113.5532 77 174768 202277.696 -27509.6957 78 158459 202277.696 -43818.6957 79 80934 82260.211 -1326.2105 80 84971 123725.958 -38754.9583 81 80545 82260.211 -1715.2105 82 287191 202277.696 84913.3043 83 62974 82260.211 -19286.2105 84 134091 157211.553 -23120.5532 85 75555 82260.211 -6705.2105 86 162154 157211.553 4942.4468 87 226638 202277.696 24360.3043 88 115019 123725.958 -8706.9583 89 108749 123725.958 -14976.9583 90 155537 157211.553 -1674.5532 91 153133 157211.553 -4078.5532 92 165618 202277.696 -36659.6957 93 151517 123725.958 27791.0417 94 133686 123725.958 9960.0417 95 61342 82260.211 -20918.2105 96 245196 202277.696 42918.3043 97 195576 157211.553 38364.4468 98 19349 6214.692 13134.3077 99 225371 202277.696 23093.3043 100 152796 157211.553 -4415.5532 101 59117 36422.857 22694.1429 102 91762 82260.211 9501.7895 103 136769 123725.958 13043.0417 104 114798 123725.958 -8927.9583 105 85338 82260.211 3077.7895 106 27676 36422.857 -8746.8571 107 153535 157211.553 -3676.5532 108 122417 123725.958 -1308.9583 109 0 6214.692 -6214.6923 110 91529 82260.211 9268.7895 111 107205 123725.958 -16520.9583 112 144664 157211.553 -12547.5532 113 136540 157211.553 -20671.5532 114 76656 82260.211 -5604.2105 115 3616 6214.692 -2598.6923 116 0 6214.692 -6214.6923 117 183065 123725.958 59339.0417 118 144677 157211.553 -12534.5532 119 159104 157211.553 1892.4468 120 113273 82260.211 31012.7895 121 43410 82260.211 -38850.2105 122 175774 157211.553 18562.4468 123 95401 82260.211 13140.7895 124 118893 157211.553 -38318.5532 125 60493 82260.211 -21767.2105 126 19764 36422.857 -16658.8571 127 164062 157211.553 6850.4468 128 132696 123725.958 8970.0417 129 155367 157211.553 -1844.5532 130 11796 6214.692 5581.3077 131 10674 6214.692 4459.3077 132 142261 157211.553 -14950.5532 133 6836 6214.692 621.3077 134 162563 157211.553 5351.4468 135 5118 6214.692 -1096.6923 136 40248 36422.857 3825.1429 137 0 6214.692 -6214.6923 138 122641 82260.211 40380.7895 139 88837 123725.958 -34888.9583 140 7131 6214.692 916.3077 141 9056 6214.692 2841.3077 142 76611 82260.211 -5649.2105 143 132697 123725.958 8971.0417 144 100681 123725.958 -23044.9583 > 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/4imi81324475135.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/5whhz1324475135.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/6k2gn1324475135.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/7nh8b1324475135.tab") + } > > try(system("convert tmp/2k9wc1324475135.ps tmp/2k9wc1324475135.png",intern=TRUE)) character(0) > try(system("convert tmp/3tomk1324475135.ps tmp/3tomk1324475135.png",intern=TRUE)) character(0) > try(system("convert tmp/4imi81324475135.ps tmp/4imi81324475135.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.857 0.353 4.210