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(150596 + ,535 + ,18 + ,20465 + ,37 + ,154801 + ,396 + ,20 + ,33629 + ,43 + ,7215 + ,72 + ,0 + ,1423 + ,0 + ,122139 + ,617 + ,26 + ,25629 + ,54 + ,221399 + ,1118 + ,30 + ,54002 + ,86 + ,441870 + ,1755 + ,34 + ,151036 + ,181 + ,134379 + ,498 + ,23 + ,33287 + ,42 + ,140428 + ,355 + ,30 + ,31172 + ,59 + ,103255 + ,413 + ,30 + ,28113 + ,46 + ,271630 + ,891 + ,26 + ,57803 + ,77 + ,121593 + ,629 + ,24 + ,49830 + ,49 + ,172071 + ,611 + ,30 + ,52143 + ,79 + ,83707 + ,564 + ,19 + ,21055 + ,37 + ,197412 + ,964 + ,25 + ,47007 + ,92 + ,134398 + ,362 + ,17 + ,28735 + ,31 + ,139224 + ,442 + ,19 + ,59147 + ,28 + ,134153 + ,391 + ,33 + ,78950 + ,103 + ,64149 + ,305 + ,15 + ,13497 + ,2 + ,122294 + ,721 + ,34 + ,46154 + ,48 + ,24889 + ,206 + ,15 + ,53249 + ,25 + ,52197 + ,310 + ,15 + ,10726 + ,16 + ,188915 + ,686 + ,27 + ,83700 + ,106 + ,172874 + ,590 + ,25 + ,40400 + ,35 + ,98575 + ,558 + ,34 + ,33797 + ,33 + ,143546 + ,569 + ,21 + ,36205 + ,45 + ,139780 + ,513 + ,21 + ,30165 + ,64 + ,163784 + ,602 + ,25 + ,58534 + ,73 + ,152479 + ,276 + ,28 + ,44663 + ,78 + ,304108 + ,791 + ,26 + ,92556 + ,63 + ,184024 + ,815 + ,20 + ,40078 + ,69 + ,151621 + ,427 + ,28 + ,34711 + ,36 + ,164516 + ,496 + ,20 + ,31076 + ,41 + ,120289 + ,655 + ,17 + ,74608 + ,59 + ,214701 + ,857 + ,25 + ,58092 + ,33 + ,196865 + ,736 + ,24 + ,42009 + ,76 + ,0 + ,0 + ,0 + ,0 + ,0 + ,191678 + ,884 + ,27 + ,36022 + ,27 + ,93107 + ,483 + ,14 + ,23333 + ,44 + ,129352 + ,495 + ,32 + ,53349 + ,43 + ,229143 + ,749 + ,31 + ,92596 + ,104 + ,177063 + ,627 + ,21 + ,49598 + ,120 + ,126602 + ,597 + ,34 + ,44093 + ,44 + ,93742 + ,348 + ,23 + ,84205 + ,71 + ,152153 + ,711 + ,24 + ,63369 + ,78 + ,95704 + ,322 + ,22 + ,60132 + ,106 + ,139793 + ,280 + ,22 + ,37403 + ,61 + ,76348 + ,205 + ,35 + ,24460 + ,53 + ,188980 + ,648 + ,21 + ,46456 + ,51 + ,172100 + ,580 + ,31 + ,66616 + ,46 + ,146552 + ,875 + ,26 + ,41554 + ,55 + ,48188 + ,205 + ,22 + ,22346 + ,14 + ,109185 + ,363 + ,21 + ,30874 + ,44 + ,263652 + ,757 + ,27 + ,68701 + ,113 + ,215609 + ,647 + ,26 + ,35728 + ,55 + ,174876 + ,584 + ,33 + ,29010 + ,46 + ,115124 + ,457 + ,11 + ,23110 + ,39 + ,179712 + ,438 + ,26 + ,38844 + ,51 + ,70369 + ,235 + ,26 + ,27084 + ,31 + ,109215 + ,312 + ,21 + ,35139 + ,36 + ,166096 + ,877 + ,38 + ,57476 + ,47 + ,130414 + ,454 + ,29 + ,33277 + ,53 + ,102057 + ,668 + ,19 + ,31141 + ,38 + ,115310 + ,346 + ,19 + ,61281 + ,52 + ,101181 + ,377 + ,24 + ,25820 + ,37 + ,135228 + ,365 + ,26 + ,23284 + ,11 + ,94982 + ,391 + ,29 + ,35378 + ,45 + ,166919 + ,476 + ,34 + ,74990 + ,59 + ,118169 + ,747 + ,25 + ,29653 + ,82 + ,102361 + ,246 + ,24 + ,64622 + ,49 + ,31970 + ,101 + ,21 + ,4157 + ,6 + ,200413 + ,901 + ,19 + ,29245 + ,81 + ,103381 + ,334 + ,12 + ,50008 + ,56 + ,94940 + ,404 + ,28 + ,52338 + ,105 + ,101560 + ,442 + ,21 + ,13310 + ,46 + ,144176 + ,627 + ,34 + ,92901 + ,46 + ,71921 + ,345 + ,32 + ,10956 + ,2 + ,126905 + ,538 + ,27 + ,34241 + ,51 + ,131184 + ,741 + ,26 + ,75043 + ,95 + ,60138 + ,253 + ,21 + ,21152 + ,18 + ,84971 + ,395 + ,31 + ,42249 + ,55 + ,80420 + ,211 + ,26 + ,42005 + ,48 + ,233569 + ,670 + ,26 + ,41152 + ,48 + ,56252 + ,244 + ,23 + ,14399 + ,39 + ,97181 + ,438 + ,25 + ,28263 + ,40 + ,50800 + ,255 + ,22 + ,17215 + ,36 + ,125941 + ,434 + ,26 + ,48140 + ,60 + ,211032 + ,613 + ,33 + ,62897 + ,114 + ,71960 + ,233 + ,22 + ,22883 + ,39 + ,90379 + ,360 + ,24 + ,41622 + ,45 + ,125650 + ,486 + ,21 + ,40715 + ,59 + ,115572 + ,535 + ,28 + ,65897 + ,59 + ,136266 + ,585 + ,22 + ,76542 + ,93 + ,146715 + ,402 + ,22 + ,37477 + ,35 + ,124626 + ,466 + ,15 + ,53216 + ,47 + ,49176 + ,291 + ,13 + ,40911 + ,36 + ,212926 + ,691 + ,36 + ,57021 + ,59 + ,173884 + ,515 + ,24 + ,73116 + ,79 + ,19349 + ,67 + ,1 + ,3895 + ,14 + ,181141 + ,712 + ,24 + ,46609 + ,42 + ,145502 + ,770 + ,31 + ,29351 + ,41 + ,45448 + ,247 + ,4 + ,2325 + ,8 + ,58280 + ,240 + ,20 + ,31747 + ,41 + ,115944 + ,360 + ,23 + ,32665 + ,24 + ,94341 + ,249 + ,23 + ,19249 + ,22 + ,59090 + ,138 + ,12 + ,15292 + ,18 + ,27676 + ,194 + ,16 + ,5842 + ,1 + ,120586 + ,285 + ,28 + ,33994 + ,53 + ,88011 + ,227 + ,10 + ,13018 + ,6 + ,0 + ,0 + ,0 + ,0 + ,0 + ,85610 + ,306 + ,25 + ,98177 + ,49 + ,94530 + ,355 + ,21 + ,37941 + ,33 + ,117769 + ,397 + ,21 + ,31032 + ,50 + ,107653 + ,369 + ,21 + ,32683 + ,64 + ,71894 + ,287 + ,21 + ,34545 + ,53 + ,3616 + ,14 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,154806 + ,301 + ,23 + ,27525 + ,48 + ,136061 + ,535 + ,29 + ,66856 + ,90 + ,141822 + ,530 + ,27 + ,28549 + ,46 + ,106515 + ,272 + ,23 + ,38610 + ,29 + ,43410 + ,292 + ,1 + ,2781 + ,1 + ,146920 + ,458 + ,25 + ,41211 + ,64 + ,88874 + ,241 + ,17 + ,22698 + ,29 + ,111924 + ,497 + ,29 + ,41194 + ,27 + ,60373 + ,165 + ,12 + ,32689 + ,4 + ,19764 + ,75 + ,2 + ,5752 + ,10 + ,121665 + ,461 + ,18 + ,26757 + ,47 + ,108685 + ,341 + ,25 + ,22527 + ,44 + ,124493 + ,446 + ,29 + ,44810 + ,51 + ,11796 + ,79 + ,2 + ,0 + ,0 + ,10674 + ,33 + ,0 + ,0 + ,0 + ,131263 + ,449 + ,18 + ,100674 + ,38 + ,6836 + ,11 + ,1 + ,0 + ,0 + ,153278 + ,606 + ,21 + ,57786 + ,57 + ,5118 + ,6 + ,0 + ,0 + ,0 + ,40248 + ,183 + ,4 + ,5444 + ,6 + ,0 + ,0 + ,0 + ,0 + ,0 + ,100728 + ,310 + ,25 + ,28470 + ,22 + ,84267 + ,245 + ,26 + ,61849 + ,34 + ,7131 + ,27 + ,0 + ,0 + ,0 + ,8812 + ,97 + ,4 + ,2179 + ,10 + ,63952 + ,247 + ,17 + ,8019 + ,16 + ,120111 + ,273 + ,21 + ,39644 + ,93 + ,94127 + ,386 + ,22 + ,23494 + ,22) + ,dim=c(5 + ,144) + ,dimnames=list(c('TimeInRFC' + ,'CompView' + ,'Reviews' + ,'CompChar' + ,'CompBlogs') + ,1:144)) > y <- array(NA,dim=c(5,144),dimnames=list(c('TimeInRFC','CompView','Reviews','CompChar','CompBlogs'),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' > 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] "TimeInRFC" > x[,par1] [1] 150596 154801 7215 122139 221399 441870 134379 140428 103255 271630 [11] 121593 172071 83707 197412 134398 139224 134153 64149 122294 24889 [21] 52197 188915 172874 98575 143546 139780 163784 152479 304108 184024 [31] 151621 164516 120289 214701 196865 0 191678 93107 129352 229143 [41] 177063 126602 93742 152153 95704 139793 76348 188980 172100 146552 [51] 48188 109185 263652 215609 174876 115124 179712 70369 109215 166096 [61] 130414 102057 115310 101181 135228 94982 166919 118169 102361 31970 [71] 200413 103381 94940 101560 144176 71921 126905 131184 60138 84971 [81] 80420 233569 56252 97181 50800 125941 211032 71960 90379 125650 [91] 115572 136266 146715 124626 49176 212926 173884 19349 181141 145502 [101] 45448 58280 115944 94341 59090 27676 120586 88011 0 85610 [111] 94530 117769 107653 71894 3616 0 154806 136061 141822 106515 [121] 43410 146920 88874 111924 60373 19764 121665 108685 124493 11796 [131] 10674 131263 6836 153278 5118 40248 0 100728 84267 7131 [141] 8812 63952 120111 94127 > 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 8812 10674 11796 19349 19764 4 1 1 1 1 1 1 1 1 1 1 24889 27676 31970 40248 43410 45448 48188 49176 50800 52197 56252 1 1 1 1 1 1 1 1 1 1 1 58280 59090 60138 60373 63952 64149 70369 71894 71921 71960 76348 1 1 1 1 1 1 1 1 1 1 1 80420 83707 84267 84971 85610 88011 88874 90379 93107 93742 94127 1 1 1 1 1 1 1 1 1 1 1 94341 94530 94940 94982 95704 97181 98575 100728 101181 101560 102057 1 1 1 1 1 1 1 1 1 1 1 102361 103255 103381 106515 107653 108685 109185 109215 111924 115124 115310 1 1 1 1 1 1 1 1 1 1 1 115572 115944 117769 118169 120111 120289 120586 121593 121665 122139 122294 1 1 1 1 1 1 1 1 1 1 1 124493 124626 125650 125941 126602 126905 129352 130414 131184 131263 134153 1 1 1 1 1 1 1 1 1 1 1 134379 134398 135228 136061 136266 139224 139780 139793 140428 141822 143546 1 1 1 1 1 1 1 1 1 1 1 144176 145502 146552 146715 146920 150596 151621 152153 152479 153278 154801 1 1 1 1 1 1 1 1 1 1 1 154806 163784 164516 166096 166919 172071 172100 172874 173884 174876 177063 1 1 1 1 1 1 1 1 1 1 1 179712 181141 184024 188915 188980 191678 196865 197412 200413 211032 212926 1 1 1 1 1 1 1 1 1 1 1 214701 215609 221399 229143 233569 263652 271630 304108 441870 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "TimeInRFC" "CompView" "Reviews" "CompChar" "CompBlogs" > colnames(x)[par1] [1] "TimeInRFC" > x[,par1] [1] 150596 154801 7215 122139 221399 441870 134379 140428 103255 271630 [11] 121593 172071 83707 197412 134398 139224 134153 64149 122294 24889 [21] 52197 188915 172874 98575 143546 139780 163784 152479 304108 184024 [31] 151621 164516 120289 214701 196865 0 191678 93107 129352 229143 [41] 177063 126602 93742 152153 95704 139793 76348 188980 172100 146552 [51] 48188 109185 263652 215609 174876 115124 179712 70369 109215 166096 [61] 130414 102057 115310 101181 135228 94982 166919 118169 102361 31970 [71] 200413 103381 94940 101560 144176 71921 126905 131184 60138 84971 [81] 80420 233569 56252 97181 50800 125941 211032 71960 90379 125650 [91] 115572 136266 146715 124626 49176 212926 173884 19349 181141 145502 [101] 45448 58280 115944 94341 59090 27676 120586 88011 0 85610 [111] 94530 117769 107653 71894 3616 0 154806 136061 141822 106515 [121] 43410 146920 88874 111924 60373 19764 121665 108685 124493 11796 [131] 10674 131263 6836 153278 5118 40248 0 100728 84267 7131 [141] 8812 63952 120111 94127 > 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/1ikbn1324666133.tab") + } + } > m Conditional inference tree with 8 terminal nodes Response: TimeInRFC Inputs: CompView, Reviews, CompChar, CompBlogs Number of observations: 144 1) CompView <= 395; criterion = 1, statistic = 110.986 2) CompView <= 206; criterion = 1, statistic = 48.184 3) CompView <= 97; criterion = 0.999, statistic = 14.508 4)* weights = 14 3) CompView > 97 5)* weights = 8 2) CompView > 206 6) CompBlogs <= 41; criterion = 0.996, statistic = 11.03 7) CompView <= 310; criterion = 0.977, statistic = 7.633 8)* weights = 18 7) CompView > 310 9)* weights = 8 6) CompBlogs > 41 10)* weights = 21 1) CompView > 395 11) CompView <= 747; criterion = 1, statistic = 42.029 12) CompView <= 569; criterion = 0.993, statistic = 9.791 13)* weights = 35 12) CompView > 569 14)* weights = 26 11) CompView > 747 15)* weights = 14 > postscript(file="/var/wessaorg/rcomp/tmp/2tz5b1324666133.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/3nna11324666133.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 150596 129814.829 20781.17143 2 154801 129814.829 24986.17143 3 7215 7165.071 49.92857 4 122139 162000.192 -39861.19231 5 221399 227012.857 -5613.85714 6 441870 227012.857 214857.14286 7 134379 129814.829 4564.17143 8 140428 109839.667 30588.33333 9 103255 129814.829 -26559.82857 10 271630 227012.857 44617.14286 11 121593 162000.192 -40407.19231 12 172071 162000.192 10070.80769 13 83707 129814.829 -46107.82857 14 197412 227012.857 -29600.85714 15 134398 107068.000 27330.00000 16 139224 129814.829 9409.17143 17 134153 109839.667 24313.33333 18 64149 69381.500 -5232.50000 19 122294 162000.192 -39706.19231 20 24889 46097.750 -21208.75000 21 52197 69381.500 -17184.50000 22 188915 162000.192 26914.80769 23 172874 162000.192 10873.80769 24 98575 129814.829 -31239.82857 25 143546 129814.829 13731.17143 26 139780 129814.829 9965.17143 27 163784 162000.192 1783.80769 28 152479 109839.667 42639.33333 29 304108 227012.857 77095.14286 30 184024 227012.857 -42988.85714 31 151621 129814.829 21806.17143 32 164516 129814.829 34701.17143 33 120289 162000.192 -41711.19231 34 214701 227012.857 -12311.85714 35 196865 162000.192 34864.80769 36 0 7165.071 -7165.07143 37 191678 227012.857 -35334.85714 38 93107 129814.829 -36707.82857 39 129352 129814.829 -462.82857 40 229143 227012.857 2130.14286 41 177063 162000.192 15062.80769 42 126602 162000.192 -35398.19231 43 93742 109839.667 -16097.66667 44 152153 162000.192 -9847.19231 45 95704 109839.667 -14135.66667 46 139793 109839.667 29953.33333 47 76348 46097.750 30250.25000 48 188980 162000.192 26979.80769 49 172100 162000.192 10099.80769 50 146552 227012.857 -80460.85714 51 48188 46097.750 2090.25000 52 109185 109839.667 -654.66667 53 263652 227012.857 36639.14286 54 215609 162000.192 53608.80769 55 174876 162000.192 12875.80769 56 115124 129814.829 -14690.82857 57 179712 129814.829 49897.17143 58 70369 69381.500 987.50000 59 109215 107068.000 2147.00000 60 166096 227012.857 -60916.85714 61 130414 129814.829 599.17143 62 102057 162000.192 -59943.19231 63 115310 109839.667 5470.33333 64 101181 107068.000 -5887.00000 65 135228 107068.000 28160.00000 66 94982 109839.667 -14857.66667 67 166919 129814.829 37104.17143 68 118169 162000.192 -43831.19231 69 102361 109839.667 -7478.66667 70 31970 46097.750 -14127.75000 71 200413 227012.857 -26599.85714 72 103381 109839.667 -6458.66667 73 94940 129814.829 -34874.82857 74 101560 129814.829 -28254.82857 75 144176 162000.192 -17824.19231 76 71921 107068.000 -35147.00000 77 126905 129814.829 -2909.82857 78 131184 162000.192 -30816.19231 79 60138 69381.500 -9243.50000 80 84971 109839.667 -24868.66667 81 80420 109839.667 -29419.66667 82 233569 162000.192 71568.80769 83 56252 69381.500 -13129.50000 84 97181 129814.829 -32633.82857 85 50800 69381.500 -18581.50000 86 125941 129814.829 -3873.82857 87 211032 162000.192 49031.80769 88 71960 69381.500 2578.50000 89 90379 109839.667 -19460.66667 90 125650 129814.829 -4164.82857 91 115572 129814.829 -14242.82857 92 136266 162000.192 -25734.19231 93 146715 129814.829 16900.17143 94 124626 129814.829 -5188.82857 95 49176 69381.500 -20205.50000 96 212926 162000.192 50925.80769 97 173884 129814.829 44069.17143 98 19349 7165.071 12183.92857 99 181141 162000.192 19140.80769 100 145502 227012.857 -81510.85714 101 45448 69381.500 -23933.50000 102 58280 69381.500 -11101.50000 103 115944 107068.000 8876.00000 104 94341 69381.500 24959.50000 105 59090 46097.750 12992.25000 106 27676 46097.750 -18421.75000 107 120586 109839.667 10746.33333 108 88011 69381.500 18629.50000 109 0 7165.071 -7165.07143 110 85610 109839.667 -24229.66667 111 94530 107068.000 -12538.00000 112 117769 129814.829 -12045.82857 113 107653 109839.667 -2186.66667 114 71894 109839.667 -37945.66667 115 3616 7165.071 -3549.07143 116 0 7165.071 -7165.07143 117 154806 109839.667 44966.33333 118 136061 129814.829 6246.17143 119 141822 129814.829 12007.17143 120 106515 69381.500 37133.50000 121 43410 69381.500 -25971.50000 122 146920 129814.829 17105.17143 123 88874 69381.500 19492.50000 124 111924 129814.829 -17890.82857 125 60373 46097.750 14275.25000 126 19764 7165.071 12598.92857 127 121665 129814.829 -8149.82857 128 108685 109839.667 -1154.66667 129 124493 129814.829 -5321.82857 130 11796 7165.071 4630.92857 131 10674 7165.071 3508.92857 132 131263 129814.829 1448.17143 133 6836 7165.071 -329.07143 134 153278 162000.192 -8722.19231 135 5118 7165.071 -2047.07143 136 40248 46097.750 -5849.75000 137 0 7165.071 -7165.07143 138 100728 69381.500 31346.50000 139 84267 69381.500 14885.50000 140 7131 7165.071 -34.07143 141 8812 7165.071 1646.92857 142 63952 69381.500 -5429.50000 143 120111 109839.667 10271.33333 144 94127 107068.000 -12941.00000 > 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/4mnar1324666133.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/5lqea1324666133.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/6rydu1324666133.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/7e8oq1324666133.tab") + } > > try(system("convert tmp/2tz5b1324666133.ps tmp/2tz5b1324666133.png",intern=TRUE)) character(0) > try(system("convert tmp/3nna11324666133.ps tmp/3nna11324666133.png",intern=TRUE)) character(0) > try(system("convert tmp/4mnar1324666133.ps tmp/4mnar1324666133.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.429 0.261 3.685