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(439387 + ,134 + ,107 + ,177551 + ,171 + ,405942 + ,86 + ,136 + ,72875 + ,133 + ,405267 + ,91 + ,122 + ,109249 + ,70 + ,394976 + ,102 + ,141 + ,95066 + ,115 + ,390163 + ,134 + ,138 + ,134796 + ,145 + ,382564 + ,97 + ,149 + ,139537 + ,184 + ,374269 + ,129 + ,157 + ,126893 + ,160 + ,371645 + ,136 + ,175 + ,234853 + ,238 + ,370878 + ,127 + ,149 + ,153824 + ,155 + ,368833 + ,145 + ,106 + ,175681 + ,282 + ,358662 + ,130 + ,91 + ,101817 + ,210 + ,351056 + ,150 + ,221 + ,135062 + ,159 + ,349227 + ,164 + ,183 + ,106385 + ,144 + ,348955 + ,139 + ,161 + ,144068 + ,164 + ,347930 + ,125 + ,115 + ,62464 + ,165 + ,346142 + ,80 + ,147 + ,131106 + ,161 + ,344751 + ,95 + ,108 + ,113587 + ,118 + ,343613 + ,117 + ,148 + ,108179 + ,190 + ,334082 + ,59 + ,137 + ,97967 + ,80 + ,325723 + ,132 + ,132 + ,104155 + ,112 + ,322679 + ,113 + ,155 + ,91677 + ,145 + ,319346 + ,119 + ,168 + ,107549 + ,156 + ,310108 + ,111 + ,143 + ,94584 + ,147 + ,309762 + ,134 + ,161 + ,146648 + ,165 + ,308944 + ,115 + ,127 + ,143950 + ,256 + ,305210 + ,128 + ,178 + ,104434 + ,152 + ,292930 + ,72 + ,143 + ,139206 + ,106 + ,292891 + ,109 + ,113 + ,87408 + ,107 + ,291777 + ,132 + ,136 + ,119906 + ,162 + ,287314 + ,116 + ,200 + ,159803 + ,157 + ,287239 + ,90 + ,136 + ,72117 + ,145 + ,285266 + ,116 + ,122 + ,90694 + ,130 + ,284519 + ,98 + ,133 + ,85008 + ,119 + ,283283 + ,123 + ,73 + ,162627 + ,213 + ,280943 + ,132 + ,132 + ,112368 + ,192 + ,279589 + ,163 + ,115 + ,94588 + ,127 + ,277542 + ,95 + ,122 + ,74844 + ,76 + ,276709 + ,111 + ,127 + ,161961 + ,179 + ,275578 + ,139 + ,145 + ,118850 + ,161 + ,273632 + ,61 + ,120 + ,137639 + ,137 + ,273576 + ,89 + ,81 + ,112669 + ,102 + ,269169 + ,80 + ,141 + ,95684 + ,106 + ,268118 + ,140 + ,118 + ,139141 + ,197 + ,268066 + ,152 + ,100 + ,174110 + ,202 + ,266805 + ,134 + ,110 + ,106271 + ,139 + ,265348 + ,88 + ,133 + ,109840 + ,155 + ,264530 + ,96 + ,104 + ,124252 + ,147 + ,264159 + ,83 + ,110 + ,63583 + ,73 + ,262412 + ,170 + ,132 + ,144645 + ,181 + ,256814 + ,117 + ,133 + ,105416 + ,140 + ,255082 + ,86 + ,120 + ,91072 + ,125 + ,249893 + ,93 + ,118 + ,93071 + ,132 + ,248834 + ,112 + ,81 + ,93587 + ,152 + ,247842 + ,108 + ,153 + ,130307 + ,111 + ,243048 + ,113 + ,151 + ,125369 + ,143 + ,242782 + ,131 + ,162 + ,124550 + ,170 + ,242395 + ,111 + ,135 + ,59938 + ,107 + ,241171 + ,113 + ,128 + ,78912 + ,125 + ,237531 + ,122 + ,112 + ,92288 + ,102 + ,236398 + ,74 + ,85 + ,50548 + ,89 + ,236370 + ,104 + ,135 + ,84891 + ,133 + ,232791 + ,67 + ,129 + ,95329 + ,122 + ,230091 + ,73 + ,69 + ,100174 + ,98 + ,225816 + ,77 + ,127 + ,82124 + ,86 + ,224936 + ,120 + ,111 + ,113864 + ,222 + ,219392 + ,73 + ,159 + ,84892 + ,104 + ,219074 + ,86 + ,149 + ,77826 + ,103 + ,212262 + ,47 + ,112 + ,105612 + ,122 + ,210247 + ,88 + ,123 + ,138599 + ,152 + ,209639 + ,88 + ,118 + ,151611 + ,153 + ,209481 + ,68 + ,150 + ,124254 + ,107 + ,207253 + ,62 + ,106 + ,98073 + ,108 + ,207178 + ,137 + ,131 + ,112215 + ,199 + ,205260 + ,103 + ,168 + ,79738 + ,93 + ,204450 + ,75 + ,132 + ,79146 + ,117 + ,202898 + ,125 + ,122 + ,106816 + ,145 + ,202410 + ,78 + ,112 + ,238712 + ,57 + ,201970 + ,101 + ,159 + ,96056 + ,155 + ,201345 + ,88 + ,81 + ,62853 + ,113 + ,200181 + ,127 + ,144 + ,76302 + ,134 + ,199717 + ,68 + ,83 + ,64631 + ,95 + ,199642 + ,57 + ,94 + ,55062 + ,80 + ,199186 + ,89 + ,119 + ,87026 + ,121 + ,197813 + ,114 + ,104 + ,108461 + ,162 + ,195822 + ,56 + ,78 + ,77457 + ,113 + ,193456 + ,80 + ,102 + ,61263 + ,136 + ,192718 + ,74 + ,80 + ,62486 + ,101 + ,192645 + ,81 + ,128 + ,96740 + ,108 + ,190673 + ,77 + ,72 + ,61680 + ,88 + ,189021 + ,86 + ,76 + ,95216 + ,192 + ,189020 + ,29 + ,45 + ,106221 + ,109 + ,186273 + ,50 + ,155 + ,97392 + ,158 + ,183696 + ,64 + ,103 + ,126938 + ,106 + ,182915 + ,89 + ,36 + ,48029 + ,82 + ,181728 + ,77 + ,90 + ,92059 + ,127 + ,180424 + ,79 + ,116 + ,125976 + ,128 + ,180362 + ,69 + ,108 + ,88766 + ,84 + ,179994 + ,47 + ,55 + ,87656 + ,67 + ,179928 + ,66 + ,137 + ,74783 + ,85 + ,178489 + ,78 + ,123 + ,143372 + ,123 + ,176062 + ,44 + ,122 + ,80849 + ,150 + ,174970 + ,120 + ,94 + ,71764 + ,114 + ,174311 + ,62 + ,59 + ,44244 + ,72 + ,173420 + ,123 + ,123 + ,67486 + ,109 + ,173260 + ,41 + ,78 + ,37238 + ,16 + ,170849 + ,161 + ,143 + ,136051 + ,163 + ,166270 + ,93 + ,134 + ,80613 + ,124 + ,166059 + ,61 + ,128 + ,94747 + ,65 + ,162366 + ,71 + ,110 + ,68007 + ,92 + ,161691 + ,55 + ,125 + ,105793 + ,41 + ,161189 + ,50 + ,84 + ,81964 + ,74 + ,157518 + ,67 + ,103 + ,68966 + ,103 + ,157448 + ,93 + ,74 + ,114029 + ,157 + ,157125 + ,37 + ,81 + ,59591 + ,89 + ,156389 + ,92 + ,184 + ,104880 + ,120 + ,150006 + ,105 + ,120 + ,77993 + ,132 + ,147989 + ,55 + ,93 + ,63995 + ,90 + ,147760 + ,83 + ,110 + ,45635 + ,132 + ,146175 + ,62 + ,102 + ,57139 + ,68 + ,145905 + ,30 + ,99 + ,38692 + ,38 + ,145249 + ,55 + ,61 + ,41449 + ,68 + ,143182 + ,52 + ,89 + ,35224 + ,66 + ,141987 + ,45 + ,100 + ,57793 + ,60 + ,140319 + ,50 + ,45 + ,90586 + ,52 + ,138731 + ,127 + ,80 + ,99971 + ,87 + ,138630 + ,70 + ,118 + ,113402 + ,104 + ,137093 + ,37 + ,81 + ,117129 + ,97 + ,136341 + ,58 + ,78 + ,48194 + ,57 + ,135798 + ,116 + ,127 + ,151244 + ,61 + ,135248 + ,58 + ,111 + ,98956 + ,126 + ,133301 + ,26 + ,77 + ,15986 + ,27 + ,130908 + ,142 + ,176 + ,135096 + ,108 + ,118033 + ,49 + ,121 + ,144253 + ,15 + ,114673 + ,33 + ,46 + ,31081 + ,41 + ,107465 + ,37 + ,65 + ,42087 + ,33 + ,106655 + ,28 + ,69 + ,197426 + ,60 + ,101097 + ,30 + ,41 + ,31701 + ,35 + ,94381 + ,42 + ,89 + ,66089 + ,50 + ,87995 + ,38 + ,121 + ,65702 + ,28 + ,80953 + ,49 + ,27 + ,56622 + ,59 + ,78800 + ,20 + ,66 + ,33032 + ,21 + ,73566 + ,22 + ,67 + ,22618 + ,26 + ,65295 + ,8 + ,80 + ,76173 + ,49 + ,65029 + ,21 + ,61 + ,32551 + ,21 + ,61857 + ,23 + ,30 + ,25162 + ,31 + ,46660 + ,12 + ,13 + ,6179 + ,13 + ,43287 + ,13 + ,64 + ,43750 + ,49 + ,38214 + ,16 + ,21 + ,8773 + ,16 + ,33186 + ,1 + ,22 + ,22807 + ,5 + ,31414 + ,18 + ,9 + ,14116 + ,39 + ,24188 + ,8 + ,7 + ,5950 + ,7 + ,23623 + ,12 + ,0 + ,1168 + ,11 + ,21054 + ,4 + ,0 + ,855 + ,4 + ,17547 + ,0 + ,4 + ,3926 + ,3 + ,14688 + ,4 + ,0 + ,6023 + ,5 + ,7199 + ,7 + ,0 + ,1644 + ,6 + ,969 + ,0 + ,0 + ,0 + ,0 + ,455 + ,0 + ,0 + ,0 + ,0 + ,203 + ,0 + ,0 + ,0 + ,0 + ,98 + ,0 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0) + ,dim=c(5 + ,164) + ,dimnames=list(c('y' + ,'1' + ,'2' + ,'3' + ,'4') + ,1:164)) > y <- array(NA,dim=c(5,164),dimnames=list(c('y','1','2','3','4'),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] 439387 405942 405267 394976 390163 382564 374269 371645 370878 368833 [11] 358662 351056 349227 348955 347930 346142 344751 343613 334082 325723 [21] 322679 319346 310108 309762 308944 305210 292930 292891 291777 287314 [31] 287239 285266 284519 283283 280943 279589 277542 276709 275578 273632 [41] 273576 269169 268118 268066 266805 265348 264530 264159 262412 256814 [51] 255082 249893 248834 247842 243048 242782 242395 241171 237531 236398 [61] 236370 232791 230091 225816 224936 219392 219074 212262 210247 209639 [71] 209481 207253 207178 205260 204450 202898 202410 201970 201345 200181 [81] 199717 199642 199186 197813 195822 193456 192718 192645 190673 189021 [91] 189020 186273 183696 182915 181728 180424 180362 179994 179928 178489 [101] 176062 174970 174311 173420 173260 170849 166270 166059 162366 161691 [111] 161189 157518 157448 157125 156389 150006 147989 147760 146175 145905 [121] 145249 143182 141987 140319 138731 138630 137093 136341 135798 135248 [131] 133301 130908 118033 114673 107465 106655 101097 94381 87995 80953 [141] 78800 73566 65295 65029 61857 46660 43287 38214 33186 31414 [151] 24188 23623 21054 17547 14688 7199 969 455 203 98 [161] 1 0 0 0 > 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 31414 33186 38214 43287 46660 61857 65029 65295 73566 78800 1 1 1 1 1 1 1 1 1 1 1 80953 87995 94381 101097 106655 107465 114673 118033 130908 133301 135248 1 1 1 1 1 1 1 1 1 1 1 135798 136341 137093 138630 138731 140319 141987 143182 145249 145905 146175 1 1 1 1 1 1 1 1 1 1 1 147760 147989 150006 156389 157125 157448 157518 161189 161691 162366 166059 1 1 1 1 1 1 1 1 1 1 1 166270 170849 173260 173420 174311 174970 176062 178489 179928 179994 180362 1 1 1 1 1 1 1 1 1 1 1 180424 181728 182915 183696 186273 189020 189021 190673 192645 192718 193456 1 1 1 1 1 1 1 1 1 1 1 195822 197813 199186 199642 199717 200181 201345 201970 202410 202898 204450 1 1 1 1 1 1 1 1 1 1 1 205260 207178 207253 209481 209639 210247 212262 219074 219392 224936 225816 1 1 1 1 1 1 1 1 1 1 1 230091 232791 236370 236398 237531 241171 242395 242782 243048 247842 248834 1 1 1 1 1 1 1 1 1 1 1 249893 255082 256814 262412 264159 264530 265348 266805 268066 268118 269169 1 1 1 1 1 1 1 1 1 1 1 273576 273632 275578 276709 277542 279589 280943 283283 284519 285266 287239 1 1 1 1 1 1 1 1 1 1 1 287314 291777 292891 292930 305210 308944 309762 310108 319346 322679 325723 1 1 1 1 1 1 1 1 1 1 1 334082 343613 344751 346142 347930 348955 349227 351056 358662 368833 370878 1 1 1 1 1 1 1 1 1 1 1 371645 374269 382564 390163 394976 405267 405942 439387 1 1 1 1 1 1 1 1 > colnames(x) [1] "y" "X1" "X2" "X3" "X4" > colnames(x)[par1] [1] "y" > x[,par1] [1] 439387 405942 405267 394976 390163 382564 374269 371645 370878 368833 [11] 358662 351056 349227 348955 347930 346142 344751 343613 334082 325723 [21] 322679 319346 310108 309762 308944 305210 292930 292891 291777 287314 [31] 287239 285266 284519 283283 280943 279589 277542 276709 275578 273632 [41] 273576 269169 268118 268066 266805 265348 264530 264159 262412 256814 [51] 255082 249893 248834 247842 243048 242782 242395 241171 237531 236398 [61] 236370 232791 230091 225816 224936 219392 219074 212262 210247 209639 [71] 209481 207253 207178 205260 204450 202898 202410 201970 201345 200181 [81] 199717 199642 199186 197813 195822 193456 192718 192645 190673 189021 [91] 189020 186273 183696 182915 181728 180424 180362 179994 179928 178489 [101] 176062 174970 174311 173420 173260 170849 166270 166059 162366 161691 [111] 161189 157518 157448 157125 156389 150006 147989 147760 146175 145905 [121] 145249 143182 141987 140319 138731 138630 137093 136341 135798 135248 [131] 133301 130908 118033 114673 107465 106655 101097 94381 87995 80953 [141] 78800 73566 65295 65029 61857 46660 43287 38214 33186 31414 [151] 24188 23623 21054 17547 14688 7199 969 455 203 98 [161] 1 0 0 0 > 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/12l2n1323703860.tab") + } + } > m Conditional inference tree with 6 terminal nodes Response: y Inputs: X1, X2, X3, X4 Number of observations: 164 1) X1 <= 58; criterion = 1, statistic = 103.59 2) X1 <= 23; criterion = 1, statistic = 41.759 3) X2 <= 9; criterion = 1, statistic = 17.846 4)* weights = 15 3) X2 > 9 5)* weights = 9 2) X1 > 23 6) X4 <= 66; criterion = 0.993, statistic = 9.686 7)* weights = 16 6) X4 > 66 8)* weights = 13 1) X1 > 58 9) X4 <= 132; criterion = 1, statistic = 20.723 10)* weights = 59 9) X4 > 132 11)* weights = 52 > postscript(file="/var/wessaorg/rcomp/tmp/2h4dr1323703860.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/3rvhb1323703860.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 439387 285972.173 153414.8269 2 405942 285972.173 119969.8269 3 405267 219557.746 185709.2542 4 394976 219557.746 175418.2542 5 390163 285972.173 104190.8269 6 382564 285972.173 96591.8269 7 374269 285972.173 88296.8269 8 371645 285972.173 85672.8269 9 370878 285972.173 84905.8269 10 368833 285972.173 82860.8269 11 358662 285972.173 72689.8269 12 351056 285972.173 65083.8269 13 349227 285972.173 63254.8269 14 348955 285972.173 62982.8269 15 347930 285972.173 61957.8269 16 346142 285972.173 60169.8269 17 344751 219557.746 125193.2542 18 343613 285972.173 57640.8269 19 334082 219557.746 114524.2542 20 325723 219557.746 106165.2542 21 322679 285972.173 36706.8269 22 319346 285972.173 33373.8269 23 310108 285972.173 24135.8269 24 309762 285972.173 23789.8269 25 308944 285972.173 22971.8269 26 305210 285972.173 19237.8269 27 292930 219557.746 73372.2542 28 292891 219557.746 73333.2542 29 291777 285972.173 5804.8269 30 287314 285972.173 1341.8269 31 287239 285972.173 1266.8269 32 285266 219557.746 65708.2542 33 284519 219557.746 64961.2542 34 283283 285972.173 -2689.1731 35 280943 285972.173 -5029.1731 36 279589 219557.746 60031.2542 37 277542 219557.746 57984.2542 38 276709 285972.173 -9263.1731 39 275578 285972.173 -10394.1731 40 273632 285972.173 -12340.1731 41 273576 219557.746 54018.2542 42 269169 219557.746 49611.2542 43 268118 285972.173 -17854.1731 44 268066 285972.173 -17906.1731 45 266805 285972.173 -19167.1731 46 265348 285972.173 -20624.1731 47 264530 285972.173 -21442.1731 48 264159 219557.746 44601.2542 49 262412 285972.173 -23560.1731 50 256814 285972.173 -29158.1731 51 255082 219557.746 35524.2542 52 249893 219557.746 30335.2542 53 248834 285972.173 -37138.1731 54 247842 219557.746 28284.2542 55 243048 285972.173 -42924.1731 56 242782 285972.173 -43190.1731 57 242395 219557.746 22837.2542 58 241171 219557.746 21613.2542 59 237531 219557.746 17973.2542 60 236398 219557.746 16840.2542 61 236370 285972.173 -49602.1731 62 232791 219557.746 13233.2542 63 230091 219557.746 10533.2542 64 225816 219557.746 6258.2542 65 224936 285972.173 -61036.1731 66 219392 219557.746 -165.7458 67 219074 219557.746 -483.7458 68 212262 170997.538 41264.4615 69 210247 285972.173 -75725.1731 70 209639 285972.173 -76333.1731 71 209481 219557.746 -10076.7458 72 207253 219557.746 -12304.7458 73 207178 285972.173 -78794.1731 74 205260 219557.746 -14297.7458 75 204450 219557.746 -15107.7458 76 202898 285972.173 -83074.1731 77 202410 219557.746 -17147.7458 78 201970 285972.173 -84002.1731 79 201345 219557.746 -18212.7458 80 200181 285972.173 -85791.1731 81 199717 219557.746 -19840.7458 82 199642 170997.538 28644.4615 83 199186 219557.746 -20371.7458 84 197813 285972.173 -88159.1731 85 195822 170997.538 24824.4615 86 193456 285972.173 -92516.1731 87 192718 219557.746 -26839.7458 88 192645 219557.746 -26912.7458 89 190673 219557.746 -28884.7458 90 189021 285972.173 -96951.1731 91 189020 170997.538 18022.4615 92 186273 170997.538 15275.4615 93 183696 219557.746 -35861.7458 94 182915 219557.746 -36642.7458 95 181728 219557.746 -37829.7458 96 180424 219557.746 -39133.7458 97 180362 219557.746 -39195.7458 98 179994 170997.538 8996.4615 99 179928 219557.746 -39629.7458 100 178489 219557.746 -41068.7458 101 176062 170997.538 5064.4615 102 174970 219557.746 -44587.7458 103 174311 219557.746 -45246.7458 104 173420 219557.746 -46137.7458 105 173260 124202.375 49057.6250 106 170849 285972.173 -115123.1731 107 166270 219557.746 -53287.7458 108 166059 219557.746 -53498.7458 109 162366 219557.746 -57191.7458 110 161691 124202.375 37488.6250 111 161189 170997.538 -9808.5385 112 157518 219557.746 -62039.7458 113 157448 285972.173 -128524.1731 114 157125 170997.538 -13872.5385 115 156389 219557.746 -63168.7458 116 150006 219557.746 -69551.7458 117 147989 170997.538 -23008.5385 118 147760 219557.746 -71797.7458 119 146175 219557.746 -73382.7458 120 145905 124202.375 21702.6250 121 145249 170997.538 -25748.5385 122 143182 124202.375 18979.6250 123 141987 124202.375 17784.6250 124 140319 124202.375 16116.6250 125 138731 219557.746 -80826.7458 126 138630 219557.746 -80927.7458 127 137093 170997.538 -33904.5385 128 136341 124202.375 12138.6250 129 135798 219557.746 -83759.7458 130 135248 170997.538 -35749.5385 131 133301 124202.375 9098.6250 132 130908 219557.746 -88649.7458 133 118033 124202.375 -6169.3750 134 114673 124202.375 -9529.3750 135 107465 124202.375 -16737.3750 136 106655 124202.375 -17547.3750 137 101097 124202.375 -23105.3750 138 94381 124202.375 -29821.3750 139 87995 124202.375 -36207.3750 140 80953 124202.375 -43249.3750 141 78800 56210.444 22589.5556 142 73566 56210.444 17355.5556 143 65295 56210.444 9084.5556 144 65029 56210.444 8818.5556 145 61857 56210.444 5646.5556 146 46660 56210.444 -9550.4444 147 43287 56210.444 -12923.4444 148 38214 56210.444 -17996.4444 149 33186 56210.444 -23024.4444 150 31414 9429.267 21984.7333 151 24188 9429.267 14758.7333 152 23623 9429.267 14193.7333 153 21054 9429.267 11624.7333 154 17547 9429.267 8117.7333 155 14688 9429.267 5258.7333 156 7199 9429.267 -2230.2667 157 969 9429.267 -8460.2667 158 455 9429.267 -8974.2667 159 203 9429.267 -9226.2667 160 98 9429.267 -9331.2667 161 1 9429.267 -9428.2667 162 0 9429.267 -9429.2667 163 0 9429.267 -9429.2667 164 0 9429.267 -9429.2667 > 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/4y28q1323703860.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/5pj9x1323703860.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/6g0bz1323703860.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/7b89t1323703860.tab") + } > > try(system("convert tmp/2h4dr1323703860.ps tmp/2h4dr1323703860.png",intern=TRUE)) character(0) > try(system("convert tmp/3rvhb1323703860.ps tmp/3rvhb1323703860.png",intern=TRUE)) character(0) > try(system("convert tmp/4y28q1323703860.ps tmp/4y28q1323703860.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.286 0.198 3.486