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(176508 + ,12 + ,60 + ,38 + ,146 + ,165446 + ,0 + ,69 + ,25 + ,93 + ,237213 + ,0 + ,78 + ,38 + ,140 + ,133131 + ,7 + ,44 + ,30 + ,99 + ,324799 + ,0 + ,158 + ,47 + ,181 + ,236785 + ,3 + ,77 + ,31 + ,116 + ,344297 + ,1 + ,80 + ,30 + ,108 + ,174724 + ,0 + ,123 + ,34 + ,129 + ,174415 + ,0 + ,73 + ,31 + ,118 + ,223632 + ,0 + ,105 + ,33 + ,125 + ,124817 + ,0 + ,47 + ,25 + ,95 + ,325107 + ,0 + ,84 + ,36 + ,136 + ,7176 + ,0 + ,0 + ,0 + ,0 + ,265769 + ,2 + ,96 + ,32 + ,124 + ,175824 + ,0 + ,57 + ,20 + ,80 + ,111665 + ,4 + ,39 + ,28 + ,104 + ,362301 + ,2 + ,76 + ,34 + ,125 + ,168809 + ,0 + ,76 + ,28 + ,118 + ,24188 + ,0 + ,8 + ,4 + ,12 + ,329267 + ,8 + ,79 + ,39 + ,144 + ,218946 + ,1 + ,76 + ,29 + ,108 + ,244052 + ,5 + ,101 + ,44 + ,166 + ,341570 + ,1 + ,94 + ,21 + ,80 + ,256462 + ,0 + ,123 + ,35 + ,127 + ,196553 + ,2 + ,41 + ,29 + ,111 + ,174184 + ,0 + ,72 + ,25 + ,98 + ,187559 + ,8 + ,75 + ,36 + ,135 + ,73566 + ,6 + ,22 + ,23 + ,88 + ,182999 + ,6 + ,73 + ,34 + ,129 + ,152299 + ,0 + ,62 + ,33 + ,122 + ,346485 + ,0 + ,118 + ,38 + ,147 + ,193339 + ,2 + ,100 + ,35 + ,87 + ,122774 + ,0 + ,24 + ,24 + ,90 + ,112611 + ,0 + ,46 + ,20 + ,78 + ,286468 + ,1 + ,57 + ,29 + ,111 + ,148446 + ,1 + ,135 + ,37 + ,141 + ,140344 + ,6 + ,33 + ,25 + ,93 + ,220516 + ,1 + ,98 + ,32 + ,124 + ,243060 + ,4 + ,58 + ,29 + ,112 + ,162765 + ,2 + ,68 + ,28 + ,108 + ,232138 + ,0 + ,131 + ,31 + ,117 + ,85574 + ,0 + ,37 + ,21 + ,78 + ,232317 + ,0 + ,118 + ,33 + ,126 + ,164709 + ,0 + ,81 + ,31 + ,115 + ,220801 + ,1 + ,51 + ,18 + ,72 + ,92661 + ,1 + ,40 + ,17 + ,45 + ,133328 + ,0 + ,56 + ,20 + ,78 + ,61361 + ,0 + ,27 + ,12 + ,39 + ,100750 + ,0 + ,83 + ,30 + ,119 + ,101523 + ,0 + ,59 + ,22 + ,88 + ,243511 + ,0 + ,133 + ,42 + ,155 + ,22938 + ,0 + ,12 + ,1 + ,0 + ,152474 + ,0 + ,106 + ,32 + ,123 + ,132487 + ,0 + ,71 + ,36 + ,136 + ,21054 + ,0 + ,4 + ,0 + ,0 + ,209641 + ,5 + ,62 + ,24 + ,88 + ,46698 + ,0 + ,14 + ,13 + ,52 + ,131698 + ,0 + ,60 + ,19 + ,75 + ,244749 + ,2 + ,98 + ,33 + ,124 + ,272458 + ,0 + ,100 + ,43 + ,162 + ,108043 + ,1 + ,45 + ,14 + ,54 + ,351067 + ,3 + ,136 + ,45 + ,170 + ,229242 + ,4 + ,63 + ,31 + ,120 + ,84207 + ,11 + ,14 + ,30 + ,112 + ,250047 + ,0 + ,41 + ,18 + ,71 + ,299775 + ,9 + ,91 + ,31 + ,120 + ,173260 + ,3 + ,41 + ,21 + ,79 + ,92499 + ,0 + ,25 + ,18 + ,71 + ,74408 + ,4 + ,29 + ,7 + ,28 + ,181633 + ,2 + ,47 + ,30 + ,110 + ,271856 + ,1 + ,109 + ,37 + ,147 + ,95227 + ,0 + ,37 + ,32 + ,111 + ,139942 + ,0 + ,54 + ,22 + ,88 + ,72880 + ,0 + ,14 + ,19 + ,76 + ,65475 + ,2 + ,16 + ,13 + ,51 + ,71965 + ,1 + ,32 + ,15 + ,59 + ,181528 + ,0 + ,32 + ,16 + ,61 + ,134019 + ,0 + ,32 + ,18 + ,67 + ,56375 + ,7 + ,10 + ,13 + ,49 + ,65490 + ,3 + ,27 + ,16 + ,62 + ,76302 + ,0 + ,29 + ,20 + ,76 + ,104011 + ,6 + ,25 + ,22 + ,88 + ,30989 + ,0 + ,5 + ,17 + ,68 + ,63123 + ,1 + ,34 + ,17 + ,68 + ,74914 + ,0 + ,35 + ,23 + ,90 + ,81437 + ,0 + ,37 + ,14 + ,54 + ,65745 + ,0 + ,26 + ,21 + ,77 + ,56653 + ,0 + ,38 + ,18 + ,68 + ,158399 + ,0 + ,23 + ,18 + ,72 + ,73624 + ,0 + ,30 + ,17 + ,64 + ,91899 + ,0 + ,18 + ,15 + ,59 + ,139526 + ,0 + ,28 + ,21 + ,84 + ,86678 + ,0 + ,12 + ,15 + ,59 + ,150580 + ,0 + ,27 + ,22 + ,83 + ,99611 + ,0 + ,41 + ,21 + ,81 + ,31706 + ,0 + ,26 + ,10 + ,32 + ,89806 + ,0 + ,27 + ,16 + ,62 + ,19764 + ,1 + ,10 + ,2 + ,8 + ,64187 + ,0 + ,10 + ,16 + ,61 + ,72535 + ,0 + ,17 + ,16 + ,64 + ,210907 + ,3 + ,79 + ,30 + ,115 + ,120982 + ,4 + ,58 + ,28 + ,109 + ,385534 + ,0 + ,121 + ,25 + ,96 + ,149061 + ,5 + ,43 + ,26 + ,100 + ,230964 + ,4 + ,102 + ,30 + ,116 + ,135473 + ,0 + ,82 + ,23 + ,88 + ,215147 + ,0 + ,101 + ,36 + ,135 + ,153935 + ,5 + ,50 + ,25 + ,89 + ,225548 + ,5 + ,81 + ,31 + ,118 + ,210767 + ,3 + ,94 + ,35 + ,135 + ,170266 + ,4 + ,44 + ,42 + ,154 + ,294424 + ,2 + ,107 + ,33 + ,127 + ,106408 + ,1 + ,33 + ,14 + ,46 + ,96560 + ,0 + ,42 + ,17 + ,54 + ,149112 + ,6 + ,56 + ,35 + ,128 + ,152871 + ,5 + ,59 + ,28 + ,97 + ,183167 + ,0 + ,91 + ,39 + ,149 + ,103597 + ,1 + ,27 + ,16 + ,60 + ,235800 + ,8 + ,105 + ,23 + ,84 + ,143246 + ,5 + ,67 + ,27 + ,105 + ,187681 + ,2 + ,114 + ,28 + ,107 + ,167488 + ,2 + ,69 + ,28 + ,104 + ,143756 + ,0 + ,105 + ,34 + ,132 + ,243199 + ,3 + ,88 + ,28 + ,108 + ,130585 + ,5 + ,67 + ,29 + ,109 + ,182079 + ,2 + ,124 + ,33 + ,124 + ,265318 + ,10 + ,110 + ,52 + ,199 + ,310839 + ,9 + ,130 + ,24 + ,91 + ,225060 + ,7 + ,93 + ,41 + ,158 + ,144966 + ,0 + ,39 + ,32 + ,122 + ,99466 + ,0 + ,28 + ,23 + ,91 + ,102010 + ,3 + ,28 + ,13 + ,50 + ,99923 + ,0 + ,44 + ,25 + ,99 + ,317394 + ,1 + ,116 + ,31 + ,117 + ,22648 + ,0 + ,12 + ,13 + ,39 + ,31414 + ,0 + ,18 + ,8 + ,25 + ,128423 + ,8 + ,32 + ,38 + ,145 + ,97839 + ,2 + ,25 + ,24 + ,87 + ,328107 + ,3 + ,129 + ,41 + ,159 + ,158015 + ,0 + ,59 + ,31 + ,119 + ,120445 + ,0 + ,36 + ,16 + ,59 + ,324598 + ,0 + ,113 + ,37 + ,136 + ,131069 + ,4 + ,47 + ,30 + ,107 + ,204271 + ,0 + ,92 + ,35 + ,130 + ,116048 + ,0 + ,50 + ,20 + ,75 + ,195838 + ,1 + ,111 + ,31 + ,116 + ,254488 + ,10 + ,120 + ,39 + ,150 + ,224330 + ,1 + ,131 + ,39 + ,144 + ,135781 + ,2 + ,45 + ,14 + ,47 + ,81240 + ,0 + ,58 + ,17 + ,68 + ,98146 + ,0 + ,15 + ,17 + ,68 + ,59194 + ,6 + ,7 + ,24 + ,80 + ,118612 + ,2 + ,54 + ,12 + ,48 + ,135131 + ,0 + ,38 + ,15 + ,60 + ,108446 + ,1 + ,22 + ,17 + ,68 + ,121848 + ,0 + ,37 + ,17 + ,64 + ,81872 + ,0 + ,32 + ,16 + ,64 + ,58981 + ,7 + ,0 + ,23 + ,91 + ,53515 + ,2 + ,5 + ,22 + ,88 + ,98104 + ,2 + ,55 + ,17 + ,66 + ,135458 + ,3 + ,43 + ,12 + ,48 + ,31774 + ,1 + ,0 + ,17 + ,66 + ,51567 + ,2 + ,21 + ,14 + ,56 + ,102538 + ,1 + ,50 + ,15 + ,58 + ,99373 + ,1 + ,12 + ,18 + ,72 + ,86230 + ,0 + ,21 + ,17 + ,61 + ,30837 + ,0 + ,8 + ,4 + ,15 + ,64175 + ,0 + ,37 + ,18 + ,72 + ,59382 + ,0 + ,29 + ,12 + ,41 + ,119308 + ,0 + ,32 + ,16 + ,61 + ,76702 + ,0 + ,35 + ,21 + ,67 + ,84105 + ,0 + ,17 + ,17 + ,66) + ,dim=c(5 + ,172) + ,dimnames=list(c('Tijd' + ,'Gedeelde_compendia' + ,'Aantal_blogs' + ,'Reviews' + ,'Reviews+120') + ,1:172)) > y <- array(NA,dim=c(5,172),dimnames=list(c('Tijd','Gedeelde_compendia','Aantal_blogs','Reviews','Reviews+120'),1:172)) > 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 = '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] "Tijd" > x[,par1] [1] 176508 165446 237213 133131 324799 236785 344297 174724 174415 223632 [11] 124817 325107 7176 265769 175824 111665 362301 168809 24188 329267 [21] 218946 244052 341570 256462 196553 174184 187559 73566 182999 152299 [31] 346485 193339 122774 112611 286468 148446 140344 220516 243060 162765 [41] 232138 85574 232317 164709 220801 92661 133328 61361 100750 101523 [51] 243511 22938 152474 132487 21054 209641 46698 131698 244749 272458 [61] 108043 351067 229242 84207 250047 299775 173260 92499 74408 181633 [71] 271856 95227 139942 72880 65475 71965 181528 134019 56375 65490 [81] 76302 104011 30989 63123 74914 81437 65745 56653 158399 73624 [91] 91899 139526 86678 150580 99611 31706 89806 19764 64187 72535 [101] 210907 120982 385534 149061 230964 135473 215147 153935 225548 210767 [111] 170266 294424 106408 96560 149112 152871 183167 103597 235800 143246 [121] 187681 167488 143756 243199 130585 182079 265318 310839 225060 144966 [131] 99466 102010 99923 317394 22648 31414 128423 97839 328107 158015 [141] 120445 324598 131069 204271 116048 195838 254488 224330 135781 81240 [151] 98146 59194 118612 135131 108446 121848 81872 58981 53515 98104 [161] 135458 31774 51567 102538 99373 86230 30837 64175 59382 119308 [171] 76702 84105 > 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]) [ 7176,135781) [135781,385534] 86 86 > colnames(x) [1] "Tijd" "Gedeelde_compendia" "Aantal_blogs" [4] "Reviews" "Reviews.120" > colnames(x)[par1] [1] "Tijd" > x[,par1] [1] [135781,385534] [135781,385534] [135781,385534] [ 7176,135781) [5] [135781,385534] [135781,385534] [135781,385534] [135781,385534] [9] [135781,385534] [135781,385534] [ 7176,135781) [135781,385534] [13] [ 7176,135781) [135781,385534] [135781,385534] [ 7176,135781) [17] [135781,385534] [135781,385534] [ 7176,135781) [135781,385534] [21] [135781,385534] [135781,385534] [135781,385534] [135781,385534] [25] [135781,385534] [135781,385534] [135781,385534] [ 7176,135781) [29] [135781,385534] [135781,385534] [135781,385534] [135781,385534] [33] [ 7176,135781) [ 7176,135781) [135781,385534] [135781,385534] [37] [135781,385534] [135781,385534] [135781,385534] [135781,385534] [41] [135781,385534] [ 7176,135781) [135781,385534] [135781,385534] [45] [135781,385534] [ 7176,135781) [ 7176,135781) [ 7176,135781) [49] [ 7176,135781) [ 7176,135781) [135781,385534] [ 7176,135781) [53] [135781,385534] [ 7176,135781) [ 7176,135781) [135781,385534] [57] [ 7176,135781) [ 7176,135781) [135781,385534] [135781,385534] [61] [ 7176,135781) [135781,385534] [135781,385534] [ 7176,135781) [65] [135781,385534] [135781,385534] [135781,385534] [ 7176,135781) [69] [ 7176,135781) [135781,385534] [135781,385534] [ 7176,135781) [73] [135781,385534] [ 7176,135781) [ 7176,135781) [ 7176,135781) [77] [135781,385534] [ 7176,135781) [ 7176,135781) [ 7176,135781) [81] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [85] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [89] [135781,385534] [ 7176,135781) [ 7176,135781) [135781,385534] [93] [ 7176,135781) [135781,385534] [ 7176,135781) [ 7176,135781) [97] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [101] [135781,385534] [ 7176,135781) [135781,385534] [135781,385534] [105] [135781,385534] [ 7176,135781) [135781,385534] [135781,385534] [109] [135781,385534] [135781,385534] [135781,385534] [135781,385534] [113] [ 7176,135781) [ 7176,135781) [135781,385534] [135781,385534] [117] [135781,385534] [ 7176,135781) [135781,385534] [135781,385534] [121] [135781,385534] [135781,385534] [135781,385534] [135781,385534] [125] [ 7176,135781) [135781,385534] [135781,385534] [135781,385534] [129] [135781,385534] [135781,385534] [ 7176,135781) [ 7176,135781) [133] [ 7176,135781) [135781,385534] [ 7176,135781) [ 7176,135781) [137] [ 7176,135781) [ 7176,135781) [135781,385534] [135781,385534] [141] [ 7176,135781) [135781,385534] [ 7176,135781) [135781,385534] [145] [ 7176,135781) [135781,385534] [135781,385534] [135781,385534] [149] [135781,385534] [ 7176,135781) [ 7176,135781) [ 7176,135781) [153] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [157] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [161] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [165] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) [169] [ 7176,135781) [ 7176,135781) [ 7176,135781) [ 7176,135781) Levels: [ 7176,135781) [135781,385534] > 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/1kb0a1323773622.tab") + } + } > m Conditional inference tree with 4 terminal nodes Response: as.factor(Tijd) Inputs: Gedeelde_compendia, Aantal_blogs, Reviews, Reviews.120 Number of observations: 172 1) Aantal_blogs <= 56; criterion = 1, statistic = 90.313 2) Reviews.120 <= 68; criterion = 0.999, statistic = 13.523 3)* weights = 52 2) Reviews.120 > 68 4)* weights = 43 1) Aantal_blogs > 56 5) Reviews <= 23; criterion = 0.993, statistic = 9.77 6)* weights = 7 5) Reviews > 23 7)* weights = 70 > postscript(file="/var/wessaorg/rcomp/tmp/29k321323773622.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/3owra1323773622.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 2 [3,] 2 2 [4,] 1 1 [5,] 2 2 [6,] 2 2 [7,] 2 2 [8,] 2 2 [9,] 2 2 [10,] 2 2 [11,] 1 1 [12,] 2 2 [13,] 1 1 [14,] 2 2 [15,] 2 1 [16,] 1 1 [17,] 2 2 [18,] 2 2 [19,] 1 1 [20,] 2 2 [21,] 2 2 [22,] 2 2 [23,] 2 1 [24,] 2 2 [25,] 2 1 [26,] 2 2 [27,] 2 2 [28,] 1 1 [29,] 2 2 [30,] 2 2 [31,] 2 2 [32,] 2 2 [33,] 1 1 [34,] 1 1 [35,] 2 2 [36,] 2 2 [37,] 2 1 [38,] 2 2 [39,] 2 2 [40,] 2 2 [41,] 2 2 [42,] 1 1 [43,] 2 2 [44,] 2 2 [45,] 2 1 [46,] 1 1 [47,] 1 1 [48,] 1 1 [49,] 1 2 [50,] 1 1 [51,] 2 2 [52,] 1 1 [53,] 2 2 [54,] 1 2 [55,] 1 1 [56,] 2 2 [57,] 1 1 [58,] 1 1 [59,] 2 2 [60,] 2 2 [61,] 1 1 [62,] 2 2 [63,] 2 2 [64,] 1 1 [65,] 2 1 [66,] 2 2 [67,] 2 1 [68,] 1 1 [69,] 1 1 [70,] 2 1 [71,] 2 2 [72,] 1 1 [73,] 2 1 [74,] 1 1 [75,] 1 1 [76,] 1 1 [77,] 2 1 [78,] 1 1 [79,] 1 1 [80,] 1 1 [81,] 1 1 [82,] 1 1 [83,] 1 1 [84,] 1 1 [85,] 1 1 [86,] 1 1 [87,] 1 1 [88,] 1 1 [89,] 2 1 [90,] 1 1 [91,] 1 1 [92,] 2 1 [93,] 1 1 [94,] 2 1 [95,] 1 1 [96,] 1 1 [97,] 1 1 [98,] 1 1 [99,] 1 1 [100,] 1 1 [101,] 2 2 [102,] 1 2 [103,] 2 2 [104,] 2 1 [105,] 2 2 [106,] 1 1 [107,] 2 2 [108,] 2 1 [109,] 2 2 [110,] 2 2 [111,] 2 1 [112,] 2 2 [113,] 1 1 [114,] 1 1 [115,] 2 1 [116,] 2 2 [117,] 2 2 [118,] 1 1 [119,] 2 1 [120,] 2 2 [121,] 2 2 [122,] 2 2 [123,] 2 2 [124,] 2 2 [125,] 1 2 [126,] 2 2 [127,] 2 2 [128,] 2 2 [129,] 2 2 [130,] 2 1 [131,] 1 1 [132,] 1 1 [133,] 1 1 [134,] 2 2 [135,] 1 1 [136,] 1 1 [137,] 1 1 [138,] 1 1 [139,] 2 2 [140,] 2 2 [141,] 1 1 [142,] 2 2 [143,] 1 1 [144,] 2 2 [145,] 1 1 [146,] 2 2 [147,] 2 2 [148,] 2 2 [149,] 2 1 [150,] 1 1 [151,] 1 1 [152,] 1 1 [153,] 1 1 [154,] 1 1 [155,] 1 1 [156,] 1 1 [157,] 1 1 [158,] 1 1 [159,] 1 1 [160,] 1 1 [161,] 1 1 [162,] 1 1 [163,] 1 1 [164,] 1 1 [165,] 1 1 [166,] 1 1 [167,] 1 1 [168,] 1 1 [169,] 1 1 [170,] 1 1 [171,] 1 1 [172,] 1 1 [ 7176,135781) [135781,385534] [ 7176,135781) 82 4 [135781,385534] 20 66 > postscript(file="/var/wessaorg/rcomp/tmp/4vfqv1323773622.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/5jgff1323773622.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/6w3dw1323773622.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/7prt41323773622.tab") + } > > try(system("convert tmp/29k321323773622.ps tmp/29k321323773622.png",intern=TRUE)) character(0) > try(system("convert tmp/3owra1323773622.ps tmp/3owra1323773622.png",intern=TRUE)) character(0) > try(system("convert tmp/4vfqv1323773622.ps tmp/4vfqv1323773622.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.619 0.240 2.853