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(124252 + ,165119 + ,85 + ,1527 + ,104 + ,98956 + ,107269 + ,58 + ,917 + ,111 + ,98073 + ,93497 + ,62 + ,1668 + ,93 + ,106816 + ,100269 + ,108 + ,2283 + ,119 + ,41449 + ,91627 + ,55 + ,992 + ,57 + ,76173 + ,47552 + ,8 + ,577 + ,80 + ,177551 + ,233933 + ,134 + ,3916 + ,107 + ,22807 + ,6853 + ,1 + ,381 + ,22 + ,126938 + ,104380 + ,63 + ,1769 + ,103 + ,61680 + ,98431 + ,77 + ,1606 + ,72 + ,72117 + ,156949 + ,86 + ,1885 + ,123 + ,79738 + ,81817 + ,93 + ,1633 + ,164 + ,57793 + ,59238 + ,44 + ,1433 + ,100 + ,91677 + ,101138 + ,106 + ,2369 + ,143 + ,64631 + ,107158 + ,63 + ,1644 + ,79 + ,106385 + ,155499 + ,160 + ,4197 + ,183 + ,161961 + ,156274 + ,104 + ,1769 + ,123 + ,112669 + ,121777 + ,86 + ,2352 + ,81 + ,114029 + ,105037 + ,92 + ,1217 + ,74 + ,124550 + ,118661 + ,119 + ,2015 + ,158 + ,105416 + ,131187 + ,107 + ,2109 + ,133 + ,72875 + ,145026 + ,86 + ,2448 + ,128 + ,81964 + ,107016 + ,50 + ,1253 + ,84 + ,104880 + ,87242 + ,92 + ,1431 + ,184 + ,76302 + ,91699 + ,123 + ,2582 + ,127 + ,96740 + ,110087 + ,81 + ,2293 + ,128 + ,93071 + ,145447 + ,93 + ,2647 + ,118 + ,78912 + ,143307 + ,113 + ,1709 + ,125 + ,35224 + ,61678 + ,52 + ,1360 + ,89 + ,90694 + ,210080 + ,113 + ,2051 + ,122 + ,125369 + ,165005 + ,109 + ,1858 + ,151 + ,80849 + ,97806 + ,44 + ,1621 + ,122 + ,104434 + ,184471 + ,123 + ,1933 + ,162 + ,65702 + ,27786 + ,38 + ,849 + ,121 + ,108179 + ,184458 + ,111 + ,2640 + ,132 + ,63583 + ,98765 + ,77 + ,2229 + ,110 + ,95066 + ,178441 + ,92 + ,2892 + ,129 + ,62486 + ,100619 + ,74 + ,1664 + ,80 + ,31081 + ,58391 + ,33 + ,917 + ,46 + ,94584 + ,151672 + ,105 + ,2740 + ,127 + ,87408 + ,124437 + ,108 + ,2897 + ,103 + ,68966 + ,79929 + ,66 + ,1413 + ,95 + ,88766 + ,123064 + ,69 + ,1500 + ,100 + ,57139 + ,50466 + ,62 + ,1443 + ,102 + ,90586 + ,100991 + ,50 + ,2369 + ,45 + ,109249 + ,79367 + ,91 + ,4798 + ,116 + ,33032 + ,56968 + ,20 + ,918 + ,66 + ,96056 + ,106257 + ,101 + ,2085 + ,159 + ,146648 + ,178412 + ,129 + ,3655 + ,153 + ,80613 + ,98520 + ,93 + ,1923 + ,131 + ,87026 + ,153670 + ,89 + ,1616 + ,113 + ,5950 + ,15049 + ,8 + ,496 + ,7 + ,131106 + ,174478 + ,79 + ,2306 + ,147 + ,32551 + ,25109 + ,21 + ,744 + ,61 + ,31701 + ,45824 + ,30 + ,1161 + ,41 + ,91072 + ,116772 + ,86 + ,2552 + ,108 + ,159803 + ,189150 + ,116 + ,2273 + ,184 + ,143950 + ,194404 + ,106 + ,3185 + ,115 + ,112368 + ,185881 + ,127 + ,2134 + ,132 + ,82124 + ,67508 + ,75 + ,1863 + ,113 + ,144068 + ,188597 + ,138 + ,3518 + ,141 + ,162627 + ,203618 + ,114 + ,2735 + ,65 + ,55062 + ,87232 + ,55 + ,2151 + ,79 + ,95329 + ,110875 + ,67 + ,2144 + ,121 + ,105612 + ,144756 + ,43 + ,1288 + ,112 + ,62853 + ,129825 + ,88 + ,1540 + ,81 + ,125976 + ,92189 + ,67 + ,1614 + ,116 + ,79146 + ,121158 + ,75 + ,2402 + ,132 + ,108461 + ,96219 + ,114 + ,1955 + ,104 + ,99971 + ,84128 + ,119 + ,1366 + ,80 + ,77826 + ,97960 + ,86 + ,2292 + ,145 + ,22618 + ,23824 + ,22 + ,893 + ,67 + ,84892 + ,103515 + ,67 + ,1935 + ,159 + ,92059 + ,91313 + ,77 + ,1538 + ,82 + ,77993 + ,85407 + ,105 + ,1494 + ,120 + ,104155 + ,95871 + ,119 + ,1994 + ,126 + ,109840 + ,143846 + ,88 + ,1904 + ,118 + ,238712 + ,155387 + ,75 + ,1645 + ,112 + ,67486 + ,74429 + ,112 + ,1700 + ,123 + ,68007 + ,74004 + ,66 + ,1467 + ,98 + ,48194 + ,71987 + ,58 + ,1538 + ,78 + ,134796 + ,150629 + ,132 + ,3320 + ,119 + ,38692 + ,68580 + ,30 + ,1345 + ,99 + ,93587 + ,119855 + ,100 + ,1929 + ,81 + ,56622 + ,55792 + ,49 + ,870 + ,27 + ,15986 + ,25157 + ,26 + ,1713 + ,77 + ,113402 + ,90895 + ,67 + ,1086 + ,118 + ,97967 + ,117510 + ,57 + ,3173 + ,122 + ,74844 + ,144774 + ,95 + ,2234 + ,103 + ,136051 + ,77529 + ,139 + ,2676 + ,129 + ,50548 + ,103123 + ,70 + ,1977 + ,69 + ,112215 + ,104669 + ,134 + ,1782 + ,121 + ,59591 + ,82414 + ,37 + ,1560 + ,81 + ,59938 + ,82390 + ,98 + ,2539 + ,119 + ,137639 + ,128446 + ,58 + ,2118 + ,116 + ,143372 + ,111542 + ,78 + ,1521 + ,123 + ,138599 + ,136048 + ,88 + ,1460 + ,111 + ,174110 + ,197257 + ,142 + ,1865 + ,100 + ,135062 + ,162079 + ,127 + ,3191 + ,197 + ,175681 + ,206286 + ,139 + ,3091 + ,95 + ,130307 + ,109858 + ,108 + ,2232 + ,153 + ,139141 + ,182125 + ,128 + ,2052 + ,118 + ,44244 + ,74168 + ,62 + ,1786 + ,50 + ,43750 + ,19630 + ,13 + ,602 + ,64 + ,48029 + ,88634 + ,89 + ,1966 + ,34 + ,95216 + ,128321 + ,83 + ,1723 + ,76 + ,92288 + ,118936 + ,116 + ,2282 + ,112 + ,94588 + ,127044 + ,157 + ,2338 + ,115 + ,197426 + ,178377 + ,28 + ,923 + ,69 + ,151244 + ,69581 + ,83 + ,1388 + ,108 + ,139206 + ,168019 + ,72 + ,1673 + ,130 + ,106271 + ,113598 + ,134 + ,2074 + ,110 + ,1168 + ,5841 + ,12 + ,398 + ,0 + ,71764 + ,93116 + ,106 + ,1605 + ,83 + ,25162 + ,24610 + ,23 + ,530 + ,30 + ,45635 + ,60611 + ,83 + ,1503 + ,106 + ,101817 + ,226620 + ,125 + ,2622 + ,91 + ,855 + ,6622 + ,4 + ,387 + ,0 + ,100174 + ,121996 + ,71 + ,1842 + ,69 + ,14116 + ,13155 + ,18 + ,449 + ,9 + ,85008 + ,154158 + ,98 + ,2890 + ,123 + ,124254 + ,78489 + ,66 + ,1701 + ,140 + ,105793 + ,22007 + ,44 + ,1401 + ,125 + ,117129 + ,72530 + ,29 + ,1257 + ,81 + ,8773 + ,13983 + ,16 + ,568 + ,21 + ,94747 + ,73397 + ,56 + ,1512 + ,124 + ,107549 + ,143878 + ,112 + ,2359 + ,164 + ,97392 + ,119956 + ,46 + ,1144 + ,139 + ,126893 + ,181558 + ,129 + ,3041 + ,144 + ,118850 + ,208236 + ,139 + ,2117 + ,130 + ,234853 + ,237085 + ,136 + ,2992 + ,168 + ,74783 + ,110297 + ,66 + ,1127 + ,126 + ,66089 + ,61394 + ,42 + ,1045 + ,89 + ,95684 + ,81420 + ,70 + ,2417 + ,137 + ,139537 + ,191154 + ,97 + ,3839 + ,149 + ,144253 + ,11798 + ,49 + ,1412 + ,121 + ,153824 + ,135724 + ,113 + ,3382 + ,133 + ,63995 + ,68614 + ,55 + ,1728 + ,93 + ,84891 + ,139926 + ,100 + ,1506 + ,119 + ,61263 + ,105203 + ,80 + ,1905 + ,102 + ,106221 + ,80338 + ,29 + ,1511 + ,39 + ,113587 + ,121376 + ,95 + ,3602 + ,104 + ,113864 + ,124922 + ,114 + ,1849 + ,111 + ,37238 + ,10901 + ,41 + ,2035 + ,78 + ,119906 + ,135471 + ,128 + ,2503 + ,120 + ,135096 + ,66395 + ,142 + ,1574 + ,169 + ,151611 + ,134041 + ,88 + ,2260 + ,109 + ,144645 + ,153554 + ,142 + ,2045 + ,132 + ,0 + ,0 + ,0 + ,2 + ,0 + ,6023 + ,7953 + ,4 + ,207 + ,0 + ,0 + ,0 + ,0 + ,5 + ,0 + ,0 + ,0 + ,0 + ,8 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,77457 + ,98922 + ,56 + ,1777 + ,78 + ,62464 + ,165395 + ,120 + ,2762 + ,104 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,4 + ,0 + ,1644 + ,4245 + ,7 + ,151 + ,0 + ,6179 + ,21509 + ,12 + ,474 + ,13 + ,3926 + ,7670 + ,0 + ,141 + ,4 + ,42087 + ,15167 + ,37 + ,969 + ,65 + ,0 + ,0 + ,0 + ,29 + ,0 + ,87656 + ,63891 + ,46 + ,1485 + ,55) + ,dim=c(5 + ,164) + ,dimnames=list(c('Karakters' + ,'Seconden' + ,'Blogs' + ,'Pageviews' + ,'LFM') + ,1:164)) > y <- array(NA,dim=c(5,164),dimnames=list(c('Karakters','Seconden','Blogs','Pageviews','LFM'),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 = '5' > par2 = 'quantiles' > par1 = '4' > #'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] "Pageviews" > x[,par1] [1] 1527 917 1668 2283 992 577 3916 381 1769 1606 1885 1633 1433 2369 1644 [16] 4197 1769 2352 1217 2015 2109 2448 1253 1431 2582 2293 2647 1709 1360 2051 [31] 1858 1621 1933 849 2640 2229 2892 1664 917 2740 2897 1413 1500 1443 2369 [46] 4798 918 2085 3655 1923 1616 496 2306 744 1161 2552 2273 3185 2134 1863 [61] 3518 2735 2151 2144 1288 1540 1614 2402 1955 1366 2292 893 1935 1538 1494 [76] 1994 1904 1645 1700 1467 1538 3320 1345 1929 870 1713 1086 3173 2234 2676 [91] 1977 1782 1560 2539 2118 1521 1460 1865 3191 3091 2232 2052 1786 602 1966 [106] 1723 2282 2338 923 1388 1673 2074 398 1605 530 1503 2622 387 1842 449 [121] 2890 1701 1401 1257 568 1512 2359 1144 3041 2117 2992 1127 1045 2417 3839 [136] 1412 3382 1728 1506 1905 1511 3602 1849 2035 2503 1574 2260 2045 2 207 [151] 5 8 0 0 1777 2762 0 4 151 474 141 969 29 1485 > 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,1127) [1127,1605) [1605,1935) [1935,2402) [2402,4798] 33 33 33 33 32 > colnames(x) [1] "Karakters" "Seconden" "Blogs" "Pageviews" "LFM" > colnames(x)[par1] [1] "Pageviews" > x[,par1] [1] [1127,1605) [ 0,1127) [1605,1935) [1935,2402) [ 0,1127) [ 0,1127) [7] [2402,4798] [ 0,1127) [1605,1935) [1605,1935) [1605,1935) [1605,1935) [13] [1127,1605) [1935,2402) [1605,1935) [2402,4798] [1605,1935) [1935,2402) [19] [1127,1605) [1935,2402) [1935,2402) [2402,4798] [1127,1605) [1127,1605) [25] [2402,4798] [1935,2402) [2402,4798] [1605,1935) [1127,1605) [1935,2402) [31] [1605,1935) [1605,1935) [1605,1935) [ 0,1127) [2402,4798] [1935,2402) [37] [2402,4798] [1605,1935) [ 0,1127) [2402,4798] [2402,4798] [1127,1605) [43] [1127,1605) [1127,1605) [1935,2402) [2402,4798] [ 0,1127) [1935,2402) [49] [2402,4798] [1605,1935) [1605,1935) [ 0,1127) [1935,2402) [ 0,1127) [55] [1127,1605) [2402,4798] [1935,2402) [2402,4798] [1935,2402) [1605,1935) [61] [2402,4798] [2402,4798] [1935,2402) [1935,2402) [1127,1605) [1127,1605) [67] [1605,1935) [2402,4798] [1935,2402) [1127,1605) [1935,2402) [ 0,1127) [73] [1935,2402) [1127,1605) [1127,1605) [1935,2402) [1605,1935) [1605,1935) [79] [1605,1935) [1127,1605) [1127,1605) [2402,4798] [1127,1605) [1605,1935) [85] [ 0,1127) [1605,1935) [ 0,1127) [2402,4798] [1935,2402) [2402,4798] [91] [1935,2402) [1605,1935) [1127,1605) [2402,4798] [1935,2402) [1127,1605) [97] [1127,1605) [1605,1935) [2402,4798] [2402,4798] [1935,2402) [1935,2402) [103] [1605,1935) [ 0,1127) [1935,2402) [1605,1935) [1935,2402) [1935,2402) [109] [ 0,1127) [1127,1605) [1605,1935) [1935,2402) [ 0,1127) [1605,1935) [115] [ 0,1127) [1127,1605) [2402,4798] [ 0,1127) [1605,1935) [ 0,1127) [121] [2402,4798] [1605,1935) [1127,1605) [1127,1605) [ 0,1127) [1127,1605) [127] [1935,2402) [1127,1605) [2402,4798] [1935,2402) [2402,4798] [1127,1605) [133] [ 0,1127) [2402,4798] [2402,4798] [1127,1605) [2402,4798] [1605,1935) [139] [1127,1605) [1605,1935) [1127,1605) [2402,4798] [1605,1935) [1935,2402) [145] [2402,4798] [1127,1605) [1935,2402) [1935,2402) [ 0,1127) [ 0,1127) [151] [ 0,1127) [ 0,1127) [ 0,1127) [ 0,1127) [1605,1935) [2402,4798] [157] [ 0,1127) [ 0,1127) [ 0,1127) [ 0,1127) [ 0,1127) [ 0,1127) [163] [ 0,1127) [1127,1605) Levels: [ 0,1127) [1127,1605) [1605,1935) [1935,2402) [2402,4798] > 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/1r57v1324339464.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: as.factor(Pageviews) Inputs: Karakters, Seconden, Blogs, LFM Number of observations: 164 1) Blogs <= 23; criterion = 1, statistic = 102.779 2)* weights = 24 1) Blogs > 23 3) Blogs <= 42; criterion = 1, statistic = 51.171 4)* weights = 12 3) Blogs > 42 5) Blogs <= 89; criterion = 1, statistic = 36.346 6)* weights = 64 5) Blogs > 89 7) Seconden <= 87242; criterion = 0.977, statistic = 12.544 8)* weights = 9 7) Seconden > 87242 9)* weights = 55 > postscript(file="/var/wessaorg/rcomp/tmp/25jef1324339464.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/30zfu1324339464.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,] 1 2 [3,] 3 2 [4,] 4 5 [5,] 1 2 [6,] 1 1 [7,] 5 5 [8,] 1 1 [9,] 3 2 [10,] 3 2 [11,] 3 2 [12,] 3 2 [13,] 2 2 [14,] 4 5 [15,] 3 2 [16,] 5 5 [17,] 3 5 [18,] 4 2 [19,] 2 5 [20,] 4 5 [21,] 4 5 [22,] 5 2 [23,] 2 2 [24,] 2 2 [25,] 5 5 [26,] 4 2 [27,] 5 5 [28,] 3 5 [29,] 2 2 [30,] 4 5 [31,] 3 5 [32,] 3 2 [33,] 3 5 [34,] 1 1 [35,] 5 5 [36,] 4 2 [37,] 5 5 [38,] 3 2 [39,] 1 1 [40,] 5 5 [41,] 5 5 [42,] 2 2 [43,] 2 2 [44,] 2 2 [45,] 4 2 [46,] 5 2 [47,] 1 1 [48,] 4 5 [49,] 5 5 [50,] 3 5 [51,] 3 2 [52,] 1 1 [53,] 4 2 [54,] 1 1 [55,] 2 1 [56,] 5 2 [57,] 4 5 [58,] 5 5 [59,] 4 5 [60,] 3 2 [61,] 5 5 [62,] 5 5 [63,] 4 2 [64,] 4 2 [65,] 2 2 [66,] 2 2 [67,] 3 2 [68,] 5 2 [69,] 4 5 [70,] 2 2 [71,] 4 2 [72,] 1 1 [73,] 4 2 [74,] 2 2 [75,] 2 2 [76,] 4 5 [77,] 3 2 [78,] 3 2 [79,] 3 2 [80,] 2 2 [81,] 2 2 [82,] 5 5 [83,] 2 1 [84,] 3 5 [85,] 1 2 [86,] 3 1 [87,] 1 2 [88,] 5 2 [89,] 4 5 [90,] 5 2 [91,] 4 2 [92,] 3 5 [93,] 2 1 [94,] 5 2 [95,] 4 2 [96,] 2 2 [97,] 2 2 [98,] 3 5 [99,] 5 5 [100,] 5 5 [101,] 4 5 [102,] 4 5 [103,] 3 2 [104,] 1 1 [105,] 4 2 [106,] 3 2 [107,] 4 5 [108,] 4 5 [109,] 1 1 [110,] 2 2 [111,] 3 2 [112,] 4 5 [113,] 1 1 [114,] 3 5 [115,] 1 1 [116,] 2 2 [117,] 5 5 [118,] 1 1 [119,] 3 2 [120,] 1 1 [121,] 5 5 [122,] 3 2 [123,] 2 2 [124,] 2 1 [125,] 1 1 [126,] 2 2 [127,] 4 5 [128,] 2 2 [129,] 5 5 [130,] 4 5 [131,] 5 5 [132,] 2 2 [133,] 1 1 [134,] 5 2 [135,] 5 5 [136,] 2 2 [137,] 5 5 [138,] 3 2 [139,] 2 5 [140,] 3 2 [141,] 2 1 [142,] 5 5 [143,] 3 5 [144,] 4 1 [145,] 5 5 [146,] 2 2 [147,] 4 2 [148,] 4 5 [149,] 1 1 [150,] 1 1 [151,] 1 1 [152,] 1 1 [153,] 1 1 [154,] 1 1 [155,] 3 2 [156,] 5 5 [157,] 1 1 [158,] 1 1 [159,] 1 1 [160,] 1 1 [161,] 1 1 [162,] 1 1 [163,] 1 1 [164,] 2 2 [ 0,1127) [1127,1605) [1605,1935) [1935,2402) [2402,4798] [ 0,1127) 29 4 0 0 0 [1127,1605) 5 26 0 0 2 [1605,1935) 1 22 0 0 10 [1935,2402) 1 13 0 0 19 [2402,4798] 0 8 0 0 24 > postscript(file="/var/wessaorg/rcomp/tmp/4785a1324339464.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/5q0bb1324339464.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/6cdi81324339464.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/7goe31324339464.tab") + } > > try(system("convert tmp/25jef1324339464.ps tmp/25jef1324339464.png",intern=TRUE)) character(0) > try(system("convert tmp/30zfu1324339464.ps tmp/30zfu1324339464.png",intern=TRUE)) character(0) > try(system("convert tmp/4785a1324339464.ps tmp/4785a1324339464.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.967 0.299 3.263