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(158258 + ,48 + ,18 + ,63 + ,20465 + ,23975 + ,186930 + ,53 + ,20 + ,56 + ,33629 + ,85634 + ,7215 + ,0 + ,0 + ,0 + ,1423 + ,1929 + ,128162 + ,51 + ,27 + ,63 + ,25629 + ,36294 + ,226974 + ,76 + ,31 + ,116 + ,54002 + ,72255 + ,500344 + ,125 + ,36 + ,138 + ,151036 + ,189748 + ,171007 + ,59 + ,23 + ,71 + ,33287 + ,61834 + ,179835 + ,80 + ,30 + ,107 + ,31172 + ,68167 + ,154581 + ,55 + ,30 + ,50 + ,28113 + ,38462 + ,278960 + ,67 + ,26 + ,79 + ,57803 + ,101219 + ,121844 + ,50 + ,24 + ,58 + ,49830 + ,43270 + ,183086 + ,77 + ,30 + ,91 + ,52143 + ,76183 + ,98796 + ,44 + ,22 + ,41 + ,21055 + ,31476 + ,209322 + ,79 + ,25 + ,91 + ,47007 + ,62157 + ,157125 + ,51 + ,18 + ,61 + ,28735 + ,46261 + ,154565 + ,54 + ,22 + ,74 + ,59147 + ,50063 + ,134198 + ,75 + ,33 + ,131 + ,78950 + ,64483 + ,69128 + ,2 + ,15 + ,45 + ,13497 + ,2341 + ,150680 + ,73 + ,34 + ,110 + ,46154 + ,48149 + ,27997 + ,13 + ,18 + ,41 + ,53249 + ,12743 + ,69919 + ,19 + ,15 + ,37 + ,10726 + ,18743 + ,233044 + ,93 + ,30 + ,84 + ,83700 + ,97057 + ,195820 + ,38 + ,25 + ,67 + ,40400 + ,17675 + ,127994 + ,48 + ,34 + ,69 + ,33797 + ,33106 + ,145433 + ,50 + ,21 + ,58 + ,36205 + ,53311 + ,170864 + ,48 + ,21 + ,60 + ,30165 + ,42754 + ,199655 + ,60 + ,25 + ,88 + ,58534 + ,59056 + ,188633 + ,81 + ,31 + ,75 + ,44663 + ,101621 + ,354266 + ,60 + ,31 + ,98 + ,92556 + ,118120 + ,192399 + ,52 + ,20 + ,67 + ,40078 + ,79572 + ,165753 + ,50 + ,28 + ,84 + ,34711 + ,42744 + ,173721 + ,60 + ,20 + ,58 + ,31076 + ,65931 + ,126739 + ,53 + ,17 + ,35 + ,74608 + ,38575 + ,224762 + ,76 + ,25 + ,74 + ,58092 + ,28795 + ,219428 + ,63 + ,24 + ,89 + ,42009 + ,94440 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,217267 + ,54 + ,27 + ,75 + ,36022 + ,38229 + ,99706 + ,44 + ,14 + ,39 + ,23333 + ,31972 + ,136733 + ,36 + ,35 + ,101 + ,53349 + ,40071 + ,249965 + ,83 + ,34 + ,135 + ,92596 + ,132480 + ,232951 + ,105 + ,22 + ,76 + ,49598 + ,62797 + ,143755 + ,37 + ,34 + ,118 + ,44093 + ,40429 + ,95734 + ,25 + ,23 + ,76 + ,84205 + ,45545 + ,191416 + ,63 + ,24 + ,65 + ,63369 + ,57568 + ,114820 + ,55 + ,26 + ,97 + ,60132 + ,39019 + ,157625 + ,41 + ,22 + ,67 + ,37403 + ,53866 + ,81293 + ,23 + ,35 + ,63 + ,24460 + ,38345 + ,210040 + ,63 + ,24 + ,96 + ,46456 + ,50210 + ,223771 + ,54 + ,31 + ,112 + ,66616 + ,80947 + ,160344 + ,68 + ,26 + ,75 + ,41554 + ,43461 + ,48188 + ,12 + ,22 + ,39 + ,22346 + ,14812 + ,145235 + ,84 + ,21 + ,63 + ,30874 + ,37819 + ,287839 + ,66 + ,27 + ,93 + ,68701 + ,102738 + ,235223 + ,56 + ,30 + ,76 + ,35728 + ,54509 + ,195583 + ,67 + ,33 + ,117 + ,29010 + ,62956 + ,145942 + ,40 + ,11 + ,30 + ,23110 + ,55411 + ,207309 + ,53 + ,26 + ,65 + ,38844 + ,50611 + ,93764 + ,26 + ,26 + ,78 + ,27084 + ,26692 + ,151985 + ,67 + ,23 + ,87 + ,35139 + ,60056 + ,190545 + ,36 + ,38 + ,85 + ,57476 + ,25155 + ,146414 + ,50 + ,30 + ,111 + ,33277 + ,42840 + ,130794 + ,48 + ,19 + ,60 + ,31141 + ,39358 + ,124234 + ,46 + ,19 + ,53 + ,61281 + ,47241 + ,112718 + ,53 + ,26 + ,67 + ,25820 + ,49611 + ,160817 + ,27 + ,26 + ,90 + ,23284 + ,41833 + ,99070 + ,38 + ,33 + ,100 + ,35378 + ,48930 + ,178653 + ,68 + ,36 + ,135 + ,74990 + ,110600 + ,138708 + ,93 + ,25 + ,71 + ,29653 + ,52235 + ,114408 + ,59 + ,24 + ,75 + ,64622 + ,53986 + ,31970 + ,5 + ,21 + ,42 + ,4157 + ,4105 + ,224494 + ,53 + ,19 + ,42 + ,29245 + ,59331 + ,123328 + ,36 + ,12 + ,8 + ,50008 + ,47796 + ,113504 + ,72 + ,30 + ,86 + ,52338 + ,38302 + ,105932 + ,49 + ,21 + ,41 + ,13310 + ,14063 + ,162203 + ,81 + ,34 + ,118 + ,92901 + ,54414 + ,100098 + ,27 + ,32 + ,91 + ,10956 + ,9903 + ,174768 + ,94 + ,28 + ,102 + ,34241 + ,53987 + ,156752 + ,71 + ,28 + ,89 + ,75043 + ,88937 + ,77269 + ,18 + ,21 + ,46 + ,21152 + ,21928 + ,84971 + ,34 + ,31 + ,60 + ,42249 + ,29487 + ,80522 + ,54 + ,26 + ,69 + ,42005 + ,35334 + ,276525 + ,44 + ,29 + ,95 + ,41152 + ,57596 + ,62974 + ,26 + ,23 + ,17 + ,14399 + ,29750 + ,120296 + ,44 + ,25 + ,61 + ,28263 + ,41029 + ,75555 + ,35 + ,22 + ,55 + ,17215 + ,12416 + ,157988 + ,32 + ,26 + ,55 + ,48140 + ,51158 + ,223247 + ,55 + ,33 + ,124 + ,62897 + ,79935 + ,115019 + ,58 + ,24 + ,73 + ,22883 + ,26552 + ,99602 + ,44 + ,24 + ,73 + ,41622 + ,25807 + ,151804 + ,39 + ,21 + ,67 + ,40715 + ,50620 + ,146005 + ,49 + ,28 + ,66 + ,65897 + ,61467 + ,163444 + ,72 + ,27 + ,75 + ,76542 + ,65292 + ,151517 + ,39 + ,25 + ,83 + ,37477 + ,55516 + ,133686 + ,28 + ,15 + ,55 + ,53216 + ,42006 + ,58128 + ,24 + ,13 + ,27 + ,40911 + ,26273 + ,234325 + ,49 + ,36 + ,115 + ,57021 + ,90248 + ,195576 + ,96 + ,24 + ,76 + ,73116 + ,61476 + ,19349 + ,13 + ,1 + ,0 + ,3895 + ,9604 + ,213189 + ,32 + ,24 + ,83 + ,46609 + ,45108 + ,151672 + ,41 + ,31 + ,90 + ,29351 + ,47232 + ,59117 + ,24 + ,4 + ,4 + ,2325 + ,3439 + ,71931 + ,52 + ,20 + ,56 + ,31747 + ,30553 + ,126653 + ,57 + ,23 + ,63 + ,32665 + ,24751 + ,113552 + ,28 + ,23 + ,52 + ,19249 + ,34458 + ,85338 + ,36 + ,12 + ,24 + ,15292 + ,24649 + ,27676 + ,2 + ,16 + ,17 + ,5842 + ,2342 + ,138522 + ,80 + ,29 + ,105 + ,33994 + ,52739 + ,122417 + ,29 + ,26 + ,20 + ,13018 + ,6245 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,87592 + ,46 + ,25 + ,51 + ,98177 + ,35381 + ,107205 + ,25 + ,21 + ,76 + ,37941 + ,19595 + ,144664 + ,51 + ,23 + ,59 + ,31032 + ,50848 + ,136540 + ,59 + ,21 + ,70 + ,32683 + ,39443 + ,71894 + ,36 + ,21 + ,38 + ,34545 + ,27023 + ,3616 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,175055 + ,38 + ,23 + ,81 + ,27525 + ,61022 + ,144618 + ,68 + ,33 + ,78 + ,66856 + ,63528 + ,152826 + ,28 + ,28 + ,67 + ,28549 + ,34835 + ,113245 + ,36 + ,23 + ,89 + ,38610 + ,37172 + ,43410 + ,7 + ,1 + ,3 + ,2781 + ,13 + ,175762 + ,70 + ,29 + ,87 + ,41211 + ,62548 + ,93634 + ,30 + ,17 + ,48 + ,22698 + ,31334 + ,117426 + ,59 + ,31 + ,66 + ,41194 + ,20839 + ,60493 + ,3 + ,12 + ,32 + ,32689 + ,5084 + ,19764 + ,10 + ,2 + ,4 + ,5752 + ,9927 + ,164062 + ,46 + ,21 + ,70 + ,26757 + ,53229 + ,128144 + ,34 + ,26 + ,94 + ,22527 + ,29877 + ,154959 + ,54 + ,29 + ,91 + ,44810 + ,37310 + ,11796 + ,1 + ,2 + ,1 + ,0 + ,0 + ,10674 + ,0 + ,0 + ,0 + ,0 + ,0 + ,138547 + ,35 + ,18 + ,39 + ,100674 + ,50067 + ,6836 + ,0 + ,1 + ,0 + ,0 + ,0 + ,154135 + ,48 + ,21 + ,45 + ,57786 + ,47708 + ,5118 + ,5 + ,0 + ,0 + ,0 + ,0 + ,40248 + ,8 + ,4 + ,7 + ,5444 + ,6012 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,120460 + ,36 + ,25 + ,75 + ,28470 + ,27749 + ,88837 + ,21 + ,26 + ,52 + ,61849 + ,47555 + ,7131 + ,0 + ,0 + ,0 + ,0 + ,0 + ,9056 + ,0 + ,4 + ,1 + ,2179 + ,1336 + ,68916 + ,15 + ,17 + ,49 + ,8019 + ,11017 + ,132697 + ,50 + ,21 + ,69 + ,39644 + ,55184 + ,100681 + ,17 + ,22 + ,56 + ,23494 + ,43485) + ,dim=c(6 + ,144) + ,dimnames=list(c('A' + ,'B' + ,'C' + ,'D' + ,'E' + ,'F') + ,1:144)) > y <- array(NA,dim=c(6,144),dimnames=list(c('A','B','C','D','E','F'),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 = '3' > par2 = 'none' > par1 = '1' > #'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] "A" > x[,par1] [1] 158258 186930 7215 128162 226974 500344 171007 179835 154581 278960 [11] 121844 183086 98796 209322 157125 154565 134198 69128 150680 27997 [21] 69919 233044 195820 127994 145433 170864 199655 188633 354266 192399 [31] 165753 173721 126739 224762 219428 0 217267 99706 136733 249965 [41] 232951 143755 95734 191416 114820 157625 81293 210040 223771 160344 [51] 48188 145235 287839 235223 195583 145942 207309 93764 151985 190545 [61] 146414 130794 124234 112718 160817 99070 178653 138708 114408 31970 [71] 224494 123328 113504 105932 162203 100098 174768 156752 77269 84971 [81] 80522 276525 62974 120296 75555 157988 223247 115019 99602 151804 [91] 146005 163444 151517 133686 58128 234325 195576 19349 213189 151672 [101] 59117 71931 126653 113552 85338 27676 138522 122417 0 87592 [111] 107205 144664 136540 71894 3616 0 175055 144618 152826 113245 [121] 43410 175762 93634 117426 60493 19764 164062 128144 154959 11796 [131] 10674 138547 6836 154135 5118 40248 0 120460 88837 7131 [141] 9056 68916 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 58128 59117 60493 62974 68916 1 1 1 1 1 1 1 1 1 1 1 69128 69919 71894 71931 75555 77269 80522 81293 84971 85338 87592 1 1 1 1 1 1 1 1 1 1 1 88837 93634 93764 95734 98796 99070 99602 99706 100098 100681 105932 1 1 1 1 1 1 1 1 1 1 1 107205 112718 113245 113504 113552 114408 114820 115019 117426 120296 120460 1 1 1 1 1 1 1 1 1 1 1 121844 122417 123328 124234 126653 126739 127994 128144 128162 130794 132697 1 1 1 1 1 1 1 1 1 1 1 133686 134198 136540 136733 138522 138547 138708 143755 144618 144664 145235 1 1 1 1 1 1 1 1 1 1 1 145433 145942 146005 146414 150680 151517 151672 151804 151985 152826 154135 1 1 1 1 1 1 1 1 1 1 1 154565 154581 154959 156752 157125 157625 157988 158258 160344 160817 162203 1 1 1 1 1 1 1 1 1 1 1 163444 164062 165753 170864 171007 173721 174768 175055 175762 178653 179835 1 1 1 1 1 1 1 1 1 1 1 183086 186930 188633 190545 191416 192399 195576 195583 195820 199655 207309 1 1 1 1 1 1 1 1 1 1 1 209322 210040 213189 217267 219428 223247 223771 224494 224762 226974 232951 1 1 1 1 1 1 1 1 1 1 1 233044 234325 235223 249965 276525 278960 287839 354266 500344 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "A" "B" "C" "D" "E" "F" > colnames(x)[par1] [1] "A" > x[,par1] [1] 158258 186930 7215 128162 226974 500344 171007 179835 154581 278960 [11] 121844 183086 98796 209322 157125 154565 134198 69128 150680 27997 [21] 69919 233044 195820 127994 145433 170864 199655 188633 354266 192399 [31] 165753 173721 126739 224762 219428 0 217267 99706 136733 249965 [41] 232951 143755 95734 191416 114820 157625 81293 210040 223771 160344 [51] 48188 145235 287839 235223 195583 145942 207309 93764 151985 190545 [61] 146414 130794 124234 112718 160817 99070 178653 138708 114408 31970 [71] 224494 123328 113504 105932 162203 100098 174768 156752 77269 84971 [81] 80522 276525 62974 120296 75555 157988 223247 115019 99602 151804 [91] 146005 163444 151517 133686 58128 234325 195576 19349 213189 151672 [101] 59117 71931 126653 113552 85338 27676 138522 122417 0 87592 [111] 107205 144664 136540 71894 3616 0 175055 144618 152826 113245 [121] 43410 175762 93634 117426 60493 19764 164062 128144 154959 11796 [131] 10674 138547 6836 154135 5118 40248 0 120460 88837 7131 [141] 9056 68916 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/14cgt1324421894.tab") + } + } > m Conditional inference tree with 7 terminal nodes Response: A Inputs: B, C, D, E, F Number of observations: 144 1) F <= 14812; criterion = 1, statistic = 106.666 2) C <= 4; criterion = 1, statistic = 18.402 3)* weights = 17 2) C > 4 4)* weights = 11 1) F > 14812 5) F <= 55516; criterion = 1, statistic = 70.866 6) B <= 26; criterion = 0.999, statistic = 13.431 7)* weights = 10 6) B > 26 8) F <= 37172; criterion = 0.963, statistic = 7.143 9)* weights = 24 8) F > 37172 10)* weights = 47 5) F > 55516 11) F <= 97057; criterion = 1, statistic = 20.126 12)* weights = 28 11) F > 97057 13)* weights = 7 > postscript(file="/var/wessaorg/rcomp/tmp/2p2gm1324421894.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/31dda1324421894.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 120285.50 37972.5000 2 186930 193611.00 -6681.0000 3 7215 14313.53 -7098.5294 4 128162 120285.50 7876.5000 5 226974 193611.00 33363.0000 6 500344 291237.14 209106.8571 7 171007 193611.00 -22604.0000 8 179835 193611.00 -13776.0000 9 154581 150364.28 4216.7234 10 278960 291237.14 -12277.1429 11 121844 150364.28 -28520.2766 12 183086 193611.00 -10525.0000 13 98796 120285.50 -21489.5000 14 209322 193611.00 15711.0000 15 157125 150364.28 6760.7234 16 154565 150364.28 4200.7234 17 134198 193611.00 -59413.0000 18 69128 67124.55 2003.4545 19 150680 150364.28 315.7234 20 27997 67124.55 -39127.5455 21 69919 83580.40 -13661.4000 22 233044 193611.00 39433.0000 23 195820 120285.50 75534.5000 24 127994 120285.50 7708.5000 25 145433 150364.28 -4931.2766 26 170864 150364.28 20499.7234 27 199655 193611.00 6044.0000 28 188633 291237.14 -102604.1429 29 354266 291237.14 63028.8571 30 192399 193611.00 -1212.0000 31 165753 150364.28 15388.7234 32 173721 193611.00 -19890.0000 33 126739 150364.28 -23625.2766 34 224762 120285.50 104476.5000 35 219428 193611.00 25817.0000 36 0 14313.53 -14313.5294 37 217267 150364.28 66902.7234 38 99706 120285.50 -20579.5000 39 136733 150364.28 -13631.2766 40 249965 291237.14 -41272.1429 41 232951 193611.00 39340.0000 42 143755 150364.28 -6609.2766 43 95734 83580.40 12153.6000 44 191416 193611.00 -2195.0000 45 114820 150364.28 -35544.2766 46 157625 150364.28 7260.7234 47 81293 83580.40 -2287.4000 48 210040 150364.28 59675.7234 49 223771 193611.00 30160.0000 50 160344 150364.28 9979.7234 51 48188 67124.55 -18936.5455 52 145235 150364.28 -5129.2766 53 287839 291237.14 -3398.1429 54 235223 150364.28 84858.7234 55 195583 193611.00 1972.0000 56 145942 150364.28 -4422.2766 57 207309 150364.28 56944.7234 58 93764 83580.40 10183.6000 59 151985 193611.00 -41626.0000 60 190545 120285.50 70259.5000 61 146414 150364.28 -3950.2766 62 130794 150364.28 -19570.2766 63 124234 150364.28 -26130.2766 64 112718 150364.28 -37646.2766 65 160817 150364.28 10452.7234 66 99070 150364.28 -51294.2766 67 178653 291237.14 -112584.1429 68 138708 150364.28 -11656.2766 69 114408 150364.28 -35956.2766 70 31970 67124.55 -35154.5455 71 224494 193611.00 30883.0000 72 123328 150364.28 -27036.2766 73 113504 150364.28 -36860.2766 74 105932 67124.55 38807.4545 75 162203 150364.28 11838.7234 76 100098 67124.55 32973.4545 77 174768 150364.28 24403.7234 78 156752 193611.00 -36859.0000 79 77269 83580.40 -6311.4000 80 84971 120285.50 -35314.5000 81 80522 120285.50 -39763.5000 82 276525 193611.00 82914.0000 83 62974 83580.40 -20606.4000 84 120296 150364.28 -30068.2766 85 75555 67124.55 8430.4545 86 157988 150364.28 7623.7234 87 223247 193611.00 29636.0000 88 115019 120285.50 -5266.5000 89 99602 120285.50 -20683.5000 90 151804 150364.28 1439.7234 91 146005 193611.00 -47606.0000 92 163444 193611.00 -30167.0000 93 151517 150364.28 1152.7234 94 133686 150364.28 -16678.2766 95 58128 83580.40 -25452.4000 96 234325 193611.00 40714.0000 97 195576 193611.00 1965.0000 98 19349 14313.53 5035.4706 99 213189 150364.28 62824.7234 100 151672 150364.28 1307.7234 101 59117 14313.53 44803.4706 102 71931 120285.50 -48354.5000 103 126653 120285.50 6367.5000 104 113552 120285.50 -6733.5000 105 85338 120285.50 -34947.5000 106 27676 67124.55 -39448.5455 107 138522 150364.28 -11842.2766 108 122417 67124.55 55292.4545 109 0 14313.53 -14313.5294 110 87592 120285.50 -32693.5000 111 107205 83580.40 23624.6000 112 144664 150364.28 -5700.2766 113 136540 150364.28 -13824.2766 114 71894 120285.50 -48391.5000 115 3616 14313.53 -10697.5294 116 0 14313.53 -14313.5294 117 175055 193611.00 -18556.0000 118 144618 193611.00 -48993.0000 119 152826 120285.50 32540.5000 120 113245 120285.50 -7040.5000 121 43410 14313.53 29096.4706 122 175762 193611.00 -17849.0000 123 93634 120285.50 -26651.5000 124 117426 120285.50 -2859.5000 125 60493 67124.55 -6631.5455 126 19764 14313.53 5450.4706 127 164062 150364.28 13697.7234 128 128144 120285.50 7858.5000 129 154959 150364.28 4594.7234 130 11796 14313.53 -2517.5294 131 10674 14313.53 -3639.5294 132 138547 150364.28 -11817.2766 133 6836 14313.53 -7477.5294 134 154135 150364.28 3770.7234 135 5118 14313.53 -9195.5294 136 40248 14313.53 25934.4706 137 0 14313.53 -14313.5294 138 120460 120285.50 174.5000 139 88837 83580.40 5256.6000 140 7131 14313.53 -7182.5294 141 9056 14313.53 -5257.5294 142 68916 67124.55 1791.4545 143 132697 150364.28 -17667.2766 144 100681 83580.40 17100.6000 > 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/4izme1324421894.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/558zt1324421894.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/6ehpq1324421894.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/7ekpp1324421894.tab") + } > > try(system("convert tmp/2p2gm1324421894.ps tmp/2p2gm1324421894.png",intern=TRUE)) character(0) > try(system("convert tmp/31dda1324421894.ps tmp/31dda1324421894.png",intern=TRUE)) character(0) > try(system("convert tmp/4izme1324421894.ps tmp/4izme1324421894.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.333 0.274 3.620