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(112285 + ,56 + ,144 + ,94 + ,146283 + ,30 + ,84786 + ,56 + ,103 + ,103 + ,98364 + ,28 + ,83123 + ,54 + ,98 + ,93 + ,86146 + ,38 + ,101193 + ,89 + ,135 + ,103 + ,96933 + ,30 + ,38361 + ,40 + ,61 + ,51 + ,79234 + ,22 + ,68504 + ,25 + ,39 + ,70 + ,42551 + ,26 + ,119182 + ,92 + ,150 + ,91 + ,195663 + ,25 + ,22807 + ,18 + ,5 + ,22 + ,6853 + ,18 + ,116174 + ,44 + ,84 + ,93 + ,95757 + ,26 + ,57635 + ,33 + ,80 + ,60 + ,85584 + ,25 + ,66198 + ,84 + ,130 + ,123 + ,143983 + ,38 + ,71701 + ,88 + ,82 + ,148 + ,75851 + ,44 + ,57793 + ,55 + ,60 + ,90 + ,59238 + ,30 + ,80444 + ,60 + ,131 + ,124 + ,93163 + ,40 + ,53855 + ,66 + ,84 + ,70 + ,96037 + ,34 + ,97668 + ,154 + ,140 + ,168 + ,151511 + ,47 + ,133824 + ,53 + ,151 + ,115 + ,136368 + ,30 + ,101481 + ,119 + ,91 + ,71 + ,112642 + ,31 + ,99645 + ,41 + ,138 + ,66 + ,94728 + ,23 + ,114789 + ,61 + ,150 + ,134 + ,105499 + ,36 + ,99052 + ,58 + ,124 + ,117 + ,121527 + ,36 + ,67654 + ,75 + ,119 + ,108 + ,127766 + ,30 + ,65553 + ,33 + ,73 + ,84 + ,98958 + ,25 + ,97500 + ,40 + ,110 + ,156 + ,77900 + ,39 + ,69112 + ,92 + ,123 + ,120 + ,85646 + ,34 + ,82753 + ,100 + ,90 + ,114 + ,98579 + ,31 + ,85323 + ,112 + ,116 + ,94 + ,130767 + ,31 + ,72654 + ,73 + ,113 + ,120 + ,131741 + ,33 + ,30727 + ,40 + ,56 + ,81 + ,53907 + ,25 + ,77873 + ,45 + ,115 + ,110 + ,178812 + ,33 + ,117478 + ,60 + ,119 + ,133 + ,146761 + ,35 + ,74007 + ,62 + ,129 + ,122 + ,82036 + ,42 + ,90183 + ,75 + ,127 + ,158 + ,163253 + ,43 + ,61542 + ,31 + ,27 + ,109 + ,27032 + ,30 + ,101494 + ,77 + ,175 + ,124 + ,171975 + ,33 + ,55813 + ,46 + ,64 + ,92 + ,86572 + ,32 + ,79215 + ,99 + ,96 + ,126 + ,159676 + ,36 + ,55461 + ,66 + ,84 + ,70 + ,85371 + ,28 + ,31081 + ,30 + ,41 + ,37 + ,58391 + ,14 + ,83122 + ,146 + ,126 + ,120 + ,136815 + ,32 + ,70106 + ,67 + ,105 + ,93 + ,120642 + ,30 + ,60578 + ,56 + ,80 + ,95 + ,69107 + ,35 + ,79892 + ,58 + ,73 + ,90 + ,108016 + ,28 + ,49810 + ,34 + ,57 + ,80 + ,46341 + ,28 + ,71570 + ,61 + ,40 + ,31 + ,78348 + ,39 + ,100708 + ,119 + ,68 + ,110 + ,79336 + ,34 + ,33032 + ,42 + ,21 + ,66 + ,56968 + ,26 + ,82875 + ,66 + ,127 + ,138 + ,93176 + ,39 + ,139077 + ,89 + ,154 + ,133 + ,161632 + ,39 + ,71595 + ,44 + ,116 + ,113 + ,87850 + ,33 + ,72260 + ,66 + ,102 + ,100 + ,127969 + ,28 + ,115762 + ,259 + ,148 + ,140 + ,155135 + ,39 + ,32551 + ,17 + ,21 + ,61 + ,25109 + ,18 + ,31701 + ,64 + ,35 + ,41 + ,45824 + ,14 + ,80670 + ,41 + ,112 + ,96 + ,102996 + ,29 + ,143558 + ,68 + ,137 + ,164 + ,160604 + ,44 + ,120733 + ,132 + ,230 + ,102 + ,162647 + ,28 + ,105195 + ,105 + ,181 + ,124 + ,174141 + ,35 + ,73107 + ,71 + ,71 + ,99 + ,60622 + ,28 + ,132068 + ,112 + ,147 + ,129 + ,179566 + ,38 + ,149193 + ,94 + ,190 + ,62 + ,184301 + ,23 + ,46821 + ,82 + ,64 + ,73 + ,75661 + ,36 + ,87011 + ,70 + ,105 + ,114 + ,96144 + ,32 + ,95260 + ,57 + ,107 + ,99 + ,129847 + ,29 + ,55183 + ,53 + ,94 + ,70 + ,117286 + ,25 + ,106671 + ,103 + ,116 + ,104 + ,71180 + ,27 + ,73511 + ,121 + ,106 + ,116 + ,109377 + ,36 + ,92945 + ,62 + ,143 + ,91 + ,85298 + ,28 + ,78664 + ,52 + ,81 + ,74 + ,73631 + ,23 + ,70054 + ,52 + ,89 + ,138 + ,86767 + ,40 + ,22618 + ,32 + ,26 + ,67 + ,23824 + ,23 + ,74011 + ,62 + ,84 + ,151 + ,93487 + ,40 + ,83737 + ,45 + ,113 + ,72 + ,82981 + ,28 + ,69094 + ,46 + ,120 + ,120 + ,73815 + ,34 + ,93133 + ,63 + ,110 + ,115 + ,94552 + ,33 + ,95536 + ,75 + ,134 + ,105 + ,132190 + ,28 + ,62133 + ,46 + ,96 + ,108 + ,66363 + ,30 + ,61370 + ,53 + ,78 + ,98 + ,67808 + ,33 + ,43836 + ,37 + ,51 + ,69 + ,61724 + ,22 + ,106117 + ,90 + ,121 + ,111 + ,131722 + ,38 + ,38692 + ,63 + ,38 + ,99 + ,68580 + ,26 + ,84651 + ,78 + ,145 + ,71 + ,106175 + ,35 + ,56622 + ,25 + ,59 + ,27 + ,55792 + ,8 + ,15986 + ,45 + ,27 + ,69 + ,25157 + ,24 + ,95364 + ,46 + ,91 + ,107 + ,76669 + ,29 + ,89691 + ,144 + ,68 + ,107 + ,105805 + ,29 + ,67267 + ,82 + ,58 + ,93 + ,129484 + ,45 + ,126846 + ,91 + ,150 + ,129 + ,72413 + ,37 + ,41140 + ,71 + ,74 + ,69 + ,87831 + ,33 + ,102860 + ,63 + ,181 + ,118 + ,96971 + ,33 + ,51715 + ,53 + ,65 + ,73 + ,71299 + ,25 + ,55801 + ,62 + ,97 + ,119 + ,77494 + ,32 + ,111813 + ,63 + ,121 + ,104 + ,120336 + ,29 + ,120293 + ,32 + ,99 + ,107 + ,93913 + ,28 + ,138599 + ,39 + ,152 + ,99 + ,136048 + ,28 + ,161647 + ,62 + ,188 + ,90 + ,181248 + ,31 + ,115929 + ,117 + ,138 + ,197 + ,146123 + ,52 + ,162901 + ,92 + ,254 + ,85 + ,186646 + ,24 + ,109825 + ,93 + ,87 + ,139 + ,102255 + ,41 + ,129838 + ,54 + ,178 + ,106 + ,168237 + ,33 + ,37510 + ,144 + ,51 + ,50 + ,64219 + ,32 + ,43750 + ,14 + ,49 + ,64 + ,19630 + ,19 + ,40652 + ,61 + ,73 + ,31 + ,76825 + ,20 + ,87771 + ,109 + ,176 + ,63 + ,115338 + ,31 + ,85872 + ,38 + ,94 + ,92 + ,109427 + ,31 + ,89275 + ,73 + ,120 + ,106 + ,118168 + ,32 + ,140867 + ,72 + ,58 + ,93 + ,68370 + ,30 + ,120662 + ,50 + ,98 + ,114 + ,146304 + ,31 + ,101338 + ,71 + ,130 + ,110 + ,103950 + ,42 + ,65567 + ,65 + ,101 + ,83 + ,84396 + ,32 + ,25162 + ,25 + ,31 + ,30 + ,24610 + ,11 + ,40735 + ,41 + ,120 + ,98 + ,55515 + ,36 + ,91413 + ,86 + ,195 + ,82 + ,209056 + ,31 + ,97068 + ,42 + ,89 + ,60 + ,115814 + ,24 + ,14116 + ,19 + ,39 + ,9 + ,13155 + ,8 + ,76643 + ,95 + ,106 + ,115 + ,142775 + ,33 + ,110681 + ,49 + ,83 + ,140 + ,68847 + ,40 + ,92696 + ,64 + ,37 + ,120 + ,20112 + ,38 + ,94785 + ,38 + ,77 + ,66 + ,61023 + ,24 + ,83209 + ,32 + ,56 + ,124 + ,65176 + ,35 + ,93815 + ,65 + ,132 + ,152 + ,132432 + ,43 + ,86687 + ,52 + ,144 + ,139 + ,112494 + ,43 + ,105547 + ,65 + ,153 + ,144 + ,170875 + ,41 + ,103487 + ,83 + ,143 + ,120 + ,180759 + ,38 + ,71220 + ,29 + ,79 + ,114 + ,100226 + ,31 + ,56926 + ,33 + ,39 + ,78 + ,54454 + ,28 + ,91721 + ,247 + ,95 + ,119 + ,78876 + ,31 + ,115168 + ,139 + ,169 + ,141 + ,170745 + ,40 + ,111194 + ,29 + ,12 + ,101 + ,6940 + ,30 + ,135777 + ,110 + ,134 + ,133 + ,122037 + ,37 + ,51513 + ,67 + ,69 + ,83 + ,53782 + ,30 + ,74163 + ,42 + ,119 + ,116 + ,127748 + ,35 + ,51633 + ,65 + ,119 + ,90 + ,86839 + ,32 + ,75345 + ,94 + ,75 + ,36 + ,44830 + ,27 + ,98952 + ,95 + ,103 + ,97 + ,103300 + ,31 + ,102372 + ,67 + ,197 + ,98 + ,112283 + ,31 + ,37238 + ,63 + ,16 + ,78 + ,10901 + ,21 + ,103772 + ,83 + ,140 + ,117 + ,120691 + ,39 + ,123969 + ,45 + ,89 + ,148 + ,58106 + ,41 + ,135400 + ,70 + ,125 + ,105 + ,122422 + ,32 + ,130115 + ,83 + ,167 + ,132 + ,139296 + ,39 + ,64466 + ,70 + ,96 + ,73 + ,89455 + ,30 + ,54990 + ,103 + ,151 + ,86 + ,147866 + ,37 + ,34777 + ,34 + ,23 + ,48 + ,14336 + ,32 + ,73224 + ,48 + ,61 + ,46 + ,53608 + ,24) + ,dim=c(6 + ,145) + ,dimnames=list(c('totsize' + ,'logins' + ,'tothyperlinks' + ,'feedback_messages_p120' + ,'totseconds(tekstverwerker)' + ,'compendiums_reviewed') + ,1:145)) > y <- array(NA,dim=c(6,145),dimnames=list(c('totsize','logins','tothyperlinks','feedback_messages_p120','totseconds(tekstverwerker)','compendiums_reviewed'),1:145)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'yes' > par3 = '2' > par2 = 'quantiles' > 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] "totsize" > x[,par1] [1] 112285 84786 83123 101193 38361 68504 119182 22807 116174 57635 [11] 66198 71701 57793 80444 53855 97668 133824 101481 99645 114789 [21] 99052 67654 65553 97500 69112 82753 85323 72654 30727 77873 [31] 117478 74007 90183 61542 101494 55813 79215 55461 31081 83122 [41] 70106 60578 79892 49810 71570 100708 33032 82875 139077 71595 [51] 72260 115762 32551 31701 80670 143558 120733 105195 73107 132068 [61] 149193 46821 87011 95260 55183 106671 73511 92945 78664 70054 [71] 22618 74011 83737 69094 93133 95536 62133 61370 43836 106117 [81] 38692 84651 56622 15986 95364 89691 67267 126846 41140 102860 [91] 51715 55801 111813 120293 138599 161647 115929 162901 109825 129838 [101] 37510 43750 40652 87771 85872 89275 140867 120662 101338 65567 [111] 25162 40735 91413 97068 14116 76643 110681 92696 94785 83209 [121] 93815 86687 105547 103487 71220 56926 91721 115168 111194 135777 [131] 51513 74163 51633 75345 98952 102372 37238 103772 123969 135400 [141] 130115 64466 54990 34777 73224 > 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]) [14116, 83123) [83123,162901] 73 72 > colnames(x) [1] "totsize" "logins" [3] "tothyperlinks" "feedback_messages_p120" [5] "totseconds.tekstverwerker." "compendiums_reviewed" > colnames(x)[par1] [1] "totsize" > x[,par1] [1] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [14116, 83123) [6] [14116, 83123) [83123,162901] [14116, 83123) [83123,162901] [14116, 83123) [11] [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [16] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [21] [83123,162901] [14116, 83123) [14116, 83123) [83123,162901] [14116, 83123) [26] [14116, 83123) [83123,162901] [14116, 83123) [14116, 83123) [14116, 83123) [31] [83123,162901] [14116, 83123) [83123,162901] [14116, 83123) [83123,162901] [36] [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [41] [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [46] [83123,162901] [14116, 83123) [14116, 83123) [83123,162901] [14116, 83123) [51] [14116, 83123) [83123,162901] [14116, 83123) [14116, 83123) [14116, 83123) [56] [83123,162901] [83123,162901] [83123,162901] [14116, 83123) [83123,162901] [61] [83123,162901] [14116, 83123) [83123,162901] [83123,162901] [14116, 83123) [66] [83123,162901] [14116, 83123) [83123,162901] [14116, 83123) [14116, 83123) [71] [14116, 83123) [14116, 83123) [83123,162901] [14116, 83123) [83123,162901] [76] [83123,162901] [14116, 83123) [14116, 83123) [14116, 83123) [83123,162901] [81] [14116, 83123) [83123,162901] [14116, 83123) [14116, 83123) [83123,162901] [86] [83123,162901] [14116, 83123) [83123,162901] [14116, 83123) [83123,162901] [91] [14116, 83123) [14116, 83123) [83123,162901] [83123,162901] [83123,162901] [96] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [101] [14116, 83123) [14116, 83123) [14116, 83123) [83123,162901] [83123,162901] [106] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [14116, 83123) [111] [14116, 83123) [14116, 83123) [83123,162901] [83123,162901] [14116, 83123) [116] [14116, 83123) [83123,162901] [83123,162901] [83123,162901] [83123,162901] [121] [83123,162901] [83123,162901] [83123,162901] [83123,162901] [14116, 83123) [126] [14116, 83123) [83123,162901] [83123,162901] [83123,162901] [83123,162901] [131] [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) [83123,162901] [136] [83123,162901] [14116, 83123) [83123,162901] [83123,162901] [83123,162901] [141] [83123,162901] [14116, 83123) [14116, 83123) [14116, 83123) [14116, 83123) Levels: [14116, 83123) [83123,162901] > 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/1e04w1324655702.tab") + } + } m.ct.i.pred m.ct.i.actu 1 2 1 565 94 2 230 412 [1] 0.8573596 [1] 0.6417445 [1] 0.7509608 m.ct.x.pred m.ct.x.actu 1 2 1 56 15 2 34 44 [1] 0.7887324 [1] 0.5641026 [1] 0.6711409 > m Conditional inference tree with 3 terminal nodes Response: as.factor(totsize) Inputs: logins, tothyperlinks, feedback_messages_p120, totseconds.tekstverwerker., compendiums_reviewed Number of observations: 145 1) tothyperlinks <= 131; criterion = 1, statistic = 44.728 2) feedback_messages_p120 <= 90; criterion = 0.998, statistic = 13.026 3)* weights = 43 2) feedback_messages_p120 > 90 4)* weights = 65 1) tothyperlinks > 131 5)* weights = 37 > postscript(file="/var/wessaorg/rcomp/tmp/22y7h1324655702.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/38ukm1324655702.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) + } > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } [,1] [,2] [1,] 2 2 [2,] 2 1 [3,] 2 1 [4,] 2 2 [5,] 1 1 [6,] 1 1 [7,] 2 2 [8,] 1 1 [9,] 2 1 [10,] 1 1 [11,] 1 1 [12,] 1 1 [13,] 1 1 [14,] 1 1 [15,] 1 1 [16,] 2 2 [17,] 2 2 [18,] 2 1 [19,] 2 2 [20,] 2 2 [21,] 2 1 [22,] 1 1 [23,] 1 1 [24,] 2 1 [25,] 1 1 [26,] 1 1 [27,] 2 1 [28,] 1 1 [29,] 1 1 [30,] 1 1 [31,] 2 1 [32,] 1 1 [33,] 2 1 [34,] 1 1 [35,] 2 2 [36,] 1 1 [37,] 1 1 [38,] 1 1 [39,] 1 1 [40,] 1 1 [41,] 1 1 [42,] 1 1 [43,] 1 1 [44,] 1 1 [45,] 1 1 [46,] 2 1 [47,] 1 1 [48,] 1 1 [49,] 2 2 [50,] 1 1 [51,] 1 1 [52,] 2 2 [53,] 1 1 [54,] 1 1 [55,] 1 1 [56,] 2 2 [57,] 2 2 [58,] 2 2 [59,] 1 1 [60,] 2 2 [61,] 2 2 [62,] 1 1 [63,] 2 1 [64,] 2 1 [65,] 1 1 [66,] 2 1 [67,] 1 1 [68,] 2 2 [69,] 1 1 [70,] 1 1 [71,] 1 1 [72,] 1 1 [73,] 2 1 [74,] 1 1 [75,] 2 1 [76,] 2 2 [77,] 1 1 [78,] 1 1 [79,] 1 1 [80,] 2 1 [81,] 1 1 [82,] 2 2 [83,] 1 1 [84,] 1 1 [85,] 2 1 [86,] 2 1 [87,] 1 1 [88,] 2 2 [89,] 1 1 [90,] 2 2 [91,] 1 1 [92,] 1 1 [93,] 2 1 [94,] 2 1 [95,] 2 2 [96,] 2 2 [97,] 2 2 [98,] 2 2 [99,] 2 1 [100,] 2 2 [101,] 1 1 [102,] 1 1 [103,] 1 1 [104,] 2 2 [105,] 2 1 [106,] 2 1 [107,] 2 1 [108,] 2 1 [109,] 2 1 [110,] 1 1 [111,] 1 1 [112,] 1 1 [113,] 2 2 [114,] 2 1 [115,] 1 1 [116,] 1 1 [117,] 2 1 [118,] 2 1 [119,] 2 1 [120,] 2 1 [121,] 2 2 [122,] 2 2 [123,] 2 2 [124,] 2 2 [125,] 1 1 [126,] 1 1 [127,] 2 1 [128,] 2 2 [129,] 2 1 [130,] 2 2 [131,] 1 1 [132,] 1 1 [133,] 1 1 [134,] 1 1 [135,] 2 1 [136,] 2 2 [137,] 1 1 [138,] 2 2 [139,] 2 1 [140,] 2 1 [141,] 2 2 [142,] 1 1 [143,] 1 2 [144,] 1 1 [145,] 1 1 [14116, 83123) [83123,162901] [14116, 83123) 72 1 [83123,162901] 36 36 > postscript(file="/var/wessaorg/rcomp/tmp/46jyv1324655702.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/5waom1324655702.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/6dnpa1324655702.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/7in1y1324655702.tab") + } > > try(system("convert tmp/22y7h1324655702.ps tmp/22y7h1324655702.png",intern=TRUE)) character(0) > try(system("convert tmp/38ukm1324655702.ps tmp/38ukm1324655702.png",intern=TRUE)) character(0) > try(system("convert tmp/46jyv1324655702.ps tmp/46jyv1324655702.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.466 0.242 3.707