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(56 + ,79 + ,30 + ,112285 + ,21 + ,56 + ,58 + ,28 + ,84786 + ,23 + ,54 + ,60 + ,38 + ,83123 + ,22 + ,92 + ,121 + ,25 + ,119182 + ,22 + ,44 + ,43 + ,26 + ,116174 + ,21 + ,33 + ,69 + ,25 + ,57635 + ,22 + ,84 + ,78 + ,38 + ,66198 + ,21 + ,55 + ,44 + ,30 + ,57793 + ,21 + ,154 + ,158 + ,47 + ,97668 + ,21 + ,53 + ,102 + ,30 + ,133824 + ,21 + ,119 + ,77 + ,31 + ,101481 + ,23 + ,41 + ,82 + ,23 + ,99645 + ,21 + ,58 + ,101 + ,36 + ,99052 + ,21 + ,75 + ,80 + ,30 + ,67654 + ,22 + ,33 + ,50 + ,25 + ,65553 + ,22 + ,100 + ,73 + ,31 + ,82753 + ,21 + ,112 + ,81 + ,31 + ,85323 + ,22 + ,73 + ,105 + ,33 + ,72654 + ,23 + ,40 + ,47 + ,25 + ,30727 + ,22 + ,60 + ,94 + ,35 + ,117478 + ,22 + ,62 + ,44 + ,42 + ,74007 + ,21 + ,77 + ,107 + ,33 + ,101494 + ,21 + ,99 + ,84 + ,36 + ,79215 + ,21 + ,17 + ,0 + ,0 + ,1423 + ,20 + ,30 + ,33 + ,14 + ,31081 + ,21 + ,76 + ,42 + ,17 + ,22996 + ,25 + ,146 + ,96 + ,32 + ,83122 + ,21 + ,56 + ,56 + ,35 + ,60578 + ,21 + ,107 + ,57 + ,20 + ,39992 + ,20 + ,58 + ,59 + ,28 + ,79892 + ,24 + ,34 + ,39 + ,28 + ,49810 + ,23 + ,119 + ,76 + ,34 + ,100708 + ,21 + ,66 + ,91 + ,39 + ,82875 + ,24 + ,66 + ,76 + ,28 + ,72260 + ,21 + ,24 + ,8 + ,4 + ,5950 + ,23 + ,259 + ,79 + ,39 + ,115762 + ,23 + ,41 + ,76 + ,29 + ,80670 + ,21 + ,68 + ,101 + ,44 + ,143558 + ,22 + ,168 + ,94 + ,21 + ,117105 + ,20 + ,43 + ,27 + ,16 + ,23789 + ,18 + ,105 + ,123 + ,35 + ,105195 + ,22 + ,94 + ,105 + ,23 + ,149193 + ,21 + ,57 + ,41 + ,29 + ,95260 + ,21 + ,53 + ,72 + ,25 + ,55183 + ,23 + ,103 + ,67 + ,27 + ,106671 + ,22 + ,121 + ,75 + ,36 + ,73511 + ,21 + ,62 + ,114 + ,28 + ,92945 + ,21 + ,32 + ,22 + ,23 + ,22618 + ,21 + ,45 + ,69 + ,28 + ,83737 + ,22 + ,46 + ,105 + ,34 + ,69094 + ,21 + ,75 + ,88 + ,28 + ,95536 + ,21 + ,88 + ,73 + ,34 + ,225920 + ,23 + ,53 + ,62 + ,33 + ,61370 + ,21 + ,78 + ,100 + ,35 + ,84651 + ,22 + ,45 + ,24 + ,24 + ,15986 + ,22 + ,46 + ,67 + ,29 + ,95364 + ,20 + ,41 + ,46 + ,20 + ,26706 + ,21 + ,144 + ,57 + ,29 + ,89691 + ,21 + ,91 + ,135 + ,37 + ,126846 + ,21 + ,63 + ,124 + ,33 + ,102860 + ,21 + ,53 + ,33 + ,25 + ,51715 + ,22 + ,62 + ,98 + ,32 + ,55801 + ,21 + ,63 + ,58 + ,29 + ,111813 + ,24 + ,32 + ,68 + ,28 + ,120293 + ,22 + ,62 + ,131 + ,31 + ,161647 + ,24 + ,117 + ,110 + ,52 + ,115929 + ,21 + ,34 + ,37 + ,21 + ,24266 + ,22 + ,92 + ,130 + ,24 + ,162901 + ,22 + ,93 + ,93 + ,41 + ,109825 + ,21 + ,54 + ,118 + ,33 + ,129838 + ,24 + ,144 + ,39 + ,32 + ,37510 + ,21 + ,109 + ,81 + ,31 + ,87771 + ,22 + ,75 + ,51 + ,18 + ,44418 + ,19 + ,50 + ,28 + ,23 + ,192565 + ,22 + ,61 + ,40 + ,17 + ,35232 + ,23 + ,55 + ,56 + ,20 + ,40909 + ,20 + ,77 + ,27 + ,12 + ,13294 + ,20 + ,72 + ,83 + ,30 + ,140867 + ,23 + ,53 + ,28 + ,13 + ,44332 + ,20 + ,42 + ,59 + ,22 + ,61056 + ,20 + ,71 + ,133 + ,42 + ,101338 + ,23 + ,10 + ,12 + ,1 + ,1168 + ,25 + ,65 + ,106 + ,32 + ,65567 + ,21 + ,66 + ,44 + ,25 + ,32334 + ,22 + ,41 + ,71 + ,36 + ,40735 + ,21 + ,86 + ,116 + ,31 + ,91413 + ,22 + ,16 + ,4 + ,0 + ,855 + ,22 + ,42 + ,62 + ,24 + ,97068 + ,23 + ,19 + ,12 + ,13 + ,44339 + ,21 + ,19 + ,18 + ,8 + ,14116 + ,21 + ,45 + ,14 + ,13 + ,10288 + ,20 + ,65 + ,60 + ,19 + ,65622 + ,19 + ,95 + ,98 + ,33 + ,76643 + ,22 + ,64 + ,32 + ,38 + ,92696 + ,21 + ,38 + ,25 + ,24 + ,94785 + ,21 + ,65 + ,100 + ,43 + ,93815 + ,21 + ,52 + ,46 + ,43 + ,86687 + ,21 + ,62 + ,45 + ,14 + ,34553 + ,21 + ,65 + ,129 + ,41 + ,105547 + ,21 + ,95 + ,136 + ,45 + ,213688 + ,22 + ,29 + ,59 + ,31 + ,71220 + ,22 + ,247 + ,63 + ,31 + ,91721 + ,22 + ,29 + ,14 + ,30 + ,111194 + ,22 + ,118 + ,36 + ,16 + ,51009 + ,18 + ,110 + ,113 + ,37 + ,135777 + ,21 + ,67 + ,47 + ,30 + ,51513 + ,23 + ,42 + ,92 + ,35 + ,74163 + ,21 + ,64 + ,50 + ,20 + ,33416 + ,19 + ,81 + ,41 + ,18 + ,83305 + ,19 + ,95 + ,91 + ,31 + ,98952 + ,23 + ,67 + ,111 + ,31 + ,102372 + ,21 + ,63 + ,41 + ,21 + ,37238 + ,21 + ,83 + ,120 + ,39 + ,103772 + ,21 + ,32 + ,25 + ,18 + ,21399 + ,21 + ,83 + ,131 + ,39 + ,130115 + ,20 + ,31 + ,45 + ,14 + ,24874 + ,19 + ,67 + ,29 + ,7 + ,34988 + ,21 + ,66 + ,58 + ,17 + ,45549 + ,22 + ,70 + ,47 + ,30 + ,64466 + ,21 + ,103 + ,109 + ,37 + ,54990 + ,25 + ,34 + ,37 + ,32 + ,34777 + ,23 + ,40 + ,15 + ,17 + ,27114 + ,19 + ,31 + ,7 + ,24 + ,37636 + ,19 + ,42 + ,54 + ,22 + ,65461 + ,19 + ,46 + ,54 + ,12 + ,30080 + ,19 + ,33 + ,14 + ,19 + ,24094 + ,19 + ,18 + ,16 + ,13 + ,69008 + ,20 + ,35 + ,32 + ,15 + ,46090 + ,19 + ,66 + ,38 + ,15 + ,34029 + ,19 + ,60 + ,22 + ,17 + ,46300 + ,19 + ,54 + ,32 + ,16 + ,40662 + ,19 + ,53 + ,32 + ,18 + ,28987 + ,19 + ,39 + ,37 + ,17 + ,30594 + ,20 + ,45 + ,32 + ,16 + ,27913 + ,19 + ,36 + ,0 + ,23 + ,42744 + ,19 + ,28 + ,5 + ,22 + ,12934 + ,18 + ,30 + ,10 + ,13 + ,41385 + ,19 + ,22 + ,27 + ,16 + ,18653 + ,19 + ,31 + ,29 + ,20 + ,30976 + ,21 + ,55 + ,25 + ,22 + ,63339 + ,18 + ,54 + ,55 + ,17 + ,25568 + ,18 + ,14 + ,5 + ,17 + ,4154 + ,21 + ,81 + ,43 + ,12 + ,19474 + ,20 + ,43 + ,34 + ,17 + ,39067 + ,19 + ,30 + ,35 + ,23 + ,65892 + ,21 + ,23 + ,0 + ,17 + ,4143 + ,21 + ,38 + ,37 + ,14 + ,28579 + ,20 + ,53 + ,26 + ,21 + ,38084 + ,24 + ,45 + ,38 + ,18 + ,27717 + ,22 + ,39 + ,23 + ,18 + ,32928 + ,21 + ,24 + ,30 + ,17 + ,19499 + ,21 + ,35 + ,18 + ,15 + ,36874 + ,19 + ,151 + ,28 + ,21 + ,48259 + ,18 + ,30 + ,21 + ,14 + ,28207 + ,19 + ,57 + ,50 + ,15 + ,45833 + ,19 + ,40 + ,12 + ,15 + ,29156 + ,19 + ,77 + ,27 + ,22 + ,45588 + ,20 + ,35 + ,41 + ,21 + ,45097 + ,18 + ,63 + ,12 + ,18 + ,28394 + ,19 + ,44 + ,21 + ,17 + ,18632 + ,19 + ,19 + ,8 + ,4 + ,2325 + ,20 + ,13 + ,26 + ,10 + ,25139 + ,20 + ,42 + ,27 + ,16 + ,27975 + ,21 + ,42 + ,37 + ,18 + ,21792 + ,20 + ,49 + ,29 + ,12 + ,26263 + ,21 + ,30 + ,32 + ,16 + ,23686 + ,18 + ,49 + ,35 + ,21 + ,49303 + ,19 + ,12 + ,10 + ,2 + ,5752 + ,19 + ,20 + ,17 + ,17 + ,20055 + ,19 + ,27 + ,10 + ,16 + ,20154 + ,19 + ,14 + ,17 + ,16 + ,19540 + ,19) + ,dim=c(5 + ,171) + ,dimnames=list(c('log' + ,'blog' + ,'PR' + ,'size' + ,'age ') + ,1:171)) > y <- array(NA,dim=c(5,171),dimnames=list(c('log','blog','PR','size','age '),1:171)) > 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 = '3' > #'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] "PR" > x[,par1] [1] 30 28 38 25 26 25 38 30 47 30 31 23 36 30 25 31 31 33 25 35 42 33 36 0 14 [26] 17 32 35 20 28 28 34 39 28 4 39 29 44 21 16 35 23 29 25 27 36 28 23 28 34 [51] 28 34 33 35 24 29 20 29 37 33 25 32 29 28 31 52 21 24 41 33 32 31 18 23 17 [76] 20 12 30 13 22 42 1 32 25 36 31 0 24 13 8 13 19 33 38 24 43 43 14 41 45 [101] 31 31 30 16 37 30 35 20 18 31 31 21 39 18 39 14 7 17 30 37 32 17 24 22 12 [126] 19 13 15 15 17 16 18 17 16 23 22 13 16 20 22 17 17 12 17 23 17 14 21 18 18 [151] 17 15 21 14 15 15 22 21 18 17 4 10 16 18 12 16 21 2 17 16 16 > 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 1 2 4 7 8 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2 1 1 2 1 1 1 4 5 5 5 9 13 8 2 5 7 5 6 5 7 1 1 8 5 8 31 32 33 34 35 36 37 38 39 41 42 43 44 45 47 52 10 5 6 3 5 4 3 3 4 2 2 2 1 1 1 1 > colnames(x) [1] "log" "blog" "PR" "size" "age." > colnames(x)[par1] [1] "PR" > x[,par1] [1] 30 28 38 25 26 25 38 30 47 30 31 23 36 30 25 31 31 33 25 35 42 33 36 0 14 [26] 17 32 35 20 28 28 34 39 28 4 39 29 44 21 16 35 23 29 25 27 36 28 23 28 34 [51] 28 34 33 35 24 29 20 29 37 33 25 32 29 28 31 52 21 24 41 33 32 31 18 23 17 [76] 20 12 30 13 22 42 1 32 25 36 31 0 24 13 8 13 19 33 38 24 43 43 14 41 45 [101] 31 31 30 16 37 30 35 20 18 31 31 21 39 18 39 14 7 17 30 37 32 17 24 22 12 [126] 19 13 15 15 17 16 18 17 16 23 22 13 16 20 22 17 17 12 17 23 17 14 21 18 18 [151] 17 15 21 14 15 15 22 21 18 17 4 10 16 18 12 16 21 2 17 16 16 > 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/1x9241323870246.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: PR Inputs: log, blog, size, age. Number of observations: 171 1) blog <= 58; criterion = 1, statistic = 95.305 2) size <= 51009; criterion = 1, statistic = 36.619 3) size <= 5950; criterion = 1, statistic = 21.773 4)* weights = 8 3) size > 5950 5)* weights = 71 2) size > 51009 6)* weights = 22 1) blog > 58 7) blog <= 88; criterion = 0.999, statistic = 14.197 8)* weights = 32 7) blog > 88 9)* weights = 38 > postscript(file="/var/wessaorg/rcomp/tmp/2hzm81323870246.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/30xpo1323870246.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 30 30.09375 -0.09375000 2 28 27.90909 0.09090909 3 38 30.09375 7.90625000 4 25 34.97368 -9.97368421 5 26 27.90909 -1.90909091 6 25 30.09375 -5.09375000 7 38 30.09375 7.90625000 8 30 27.90909 2.09090909 9 47 34.97368 12.02631579 10 30 34.97368 -4.97368421 11 31 30.09375 0.90625000 12 23 30.09375 -7.09375000 13 36 34.97368 1.02631579 14 30 30.09375 -0.09375000 15 25 27.90909 -2.90909091 16 31 30.09375 0.90625000 17 31 30.09375 0.90625000 18 33 34.97368 -1.97368421 19 25 17.63380 7.36619718 20 35 34.97368 0.02631579 21 42 27.90909 14.09090909 22 33 34.97368 -1.97368421 23 36 30.09375 5.90625000 24 0 5.62500 -5.62500000 25 14 17.63380 -3.63380282 26 17 17.63380 -0.63380282 27 32 34.97368 -2.97368421 28 35 27.90909 7.09090909 29 20 17.63380 2.36619718 30 28 30.09375 -2.09375000 31 28 17.63380 10.36619718 32 34 30.09375 3.90625000 33 39 34.97368 4.02631579 34 28 30.09375 -2.09375000 35 4 5.62500 -1.62500000 36 39 30.09375 8.90625000 37 29 30.09375 -1.09375000 38 44 34.97368 9.02631579 39 21 34.97368 -13.97368421 40 16 17.63380 -1.63380282 41 35 34.97368 0.02631579 42 23 34.97368 -11.97368421 43 29 27.90909 1.09090909 44 25 30.09375 -5.09375000 45 27 30.09375 -3.09375000 46 36 30.09375 5.90625000 47 28 34.97368 -6.97368421 48 23 17.63380 5.36619718 49 28 30.09375 -2.09375000 50 34 34.97368 -0.97368421 51 28 30.09375 -2.09375000 52 34 30.09375 3.90625000 53 33 30.09375 2.90625000 54 35 34.97368 0.02631579 55 24 17.63380 6.36619718 56 29 30.09375 -1.09375000 57 20 17.63380 2.36619718 58 29 27.90909 1.09090909 59 37 34.97368 2.02631579 60 33 34.97368 -1.97368421 61 25 27.90909 -2.90909091 62 32 34.97368 -2.97368421 63 29 27.90909 1.09090909 64 28 30.09375 -2.09375000 65 31 34.97368 -3.97368421 66 52 34.97368 17.02631579 67 21 17.63380 3.36619718 68 24 34.97368 -10.97368421 69 41 34.97368 6.02631579 70 33 34.97368 -1.97368421 71 32 17.63380 14.36619718 72 31 30.09375 0.90625000 73 18 17.63380 0.36619718 74 23 27.90909 -4.90909091 75 17 17.63380 -0.63380282 76 20 17.63380 2.36619718 77 12 17.63380 -5.63380282 78 30 30.09375 -0.09375000 79 13 17.63380 -4.63380282 80 22 30.09375 -8.09375000 81 42 34.97368 7.02631579 82 1 5.62500 -4.62500000 83 32 34.97368 -2.97368421 84 25 17.63380 7.36619718 85 36 30.09375 5.90625000 86 31 34.97368 -3.97368421 87 0 5.62500 -5.62500000 88 24 30.09375 -6.09375000 89 13 17.63380 -4.63380282 90 8 17.63380 -9.63380282 91 13 17.63380 -4.63380282 92 19 30.09375 -11.09375000 93 33 34.97368 -1.97368421 94 38 27.90909 10.09090909 95 24 27.90909 -3.90909091 96 43 34.97368 8.02631579 97 43 27.90909 15.09090909 98 14 17.63380 -3.63380282 99 41 34.97368 6.02631579 100 45 34.97368 10.02631579 101 31 30.09375 0.90625000 102 31 30.09375 0.90625000 103 30 27.90909 2.09090909 104 16 17.63380 -1.63380282 105 37 34.97368 2.02631579 106 30 27.90909 2.09090909 107 35 34.97368 0.02631579 108 20 17.63380 2.36619718 109 18 27.90909 -9.90909091 110 31 34.97368 -3.97368421 111 31 34.97368 -3.97368421 112 21 17.63380 3.36619718 113 39 34.97368 4.02631579 114 18 17.63380 0.36619718 115 39 34.97368 4.02631579 116 14 17.63380 -3.63380282 117 7 17.63380 -10.63380282 118 17 17.63380 -0.63380282 119 30 27.90909 2.09090909 120 37 34.97368 2.02631579 121 32 17.63380 14.36619718 122 17 17.63380 -0.63380282 123 24 17.63380 6.36619718 124 22 27.90909 -5.90909091 125 12 17.63380 -5.63380282 126 19 17.63380 1.36619718 127 13 27.90909 -14.90909091 128 15 17.63380 -2.63380282 129 15 17.63380 -2.63380282 130 17 17.63380 -0.63380282 131 16 17.63380 -1.63380282 132 18 17.63380 0.36619718 133 17 17.63380 -0.63380282 134 16 17.63380 -1.63380282 135 23 17.63380 5.36619718 136 22 17.63380 4.36619718 137 13 17.63380 -4.63380282 138 16 17.63380 -1.63380282 139 20 17.63380 2.36619718 140 22 27.90909 -5.90909091 141 17 17.63380 -0.63380282 142 17 5.62500 11.37500000 143 12 17.63380 -5.63380282 144 17 17.63380 -0.63380282 145 23 27.90909 -4.90909091 146 17 5.62500 11.37500000 147 14 17.63380 -3.63380282 148 21 17.63380 3.36619718 149 18 17.63380 0.36619718 150 18 17.63380 0.36619718 151 17 17.63380 -0.63380282 152 15 17.63380 -2.63380282 153 21 17.63380 3.36619718 154 14 17.63380 -3.63380282 155 15 17.63380 -2.63380282 156 15 17.63380 -2.63380282 157 22 17.63380 4.36619718 158 21 17.63380 3.36619718 159 18 17.63380 0.36619718 160 17 17.63380 -0.63380282 161 4 5.62500 -1.62500000 162 10 17.63380 -7.63380282 163 16 17.63380 -1.63380282 164 18 17.63380 0.36619718 165 12 17.63380 -5.63380282 166 16 17.63380 -1.63380282 167 21 17.63380 3.36619718 168 2 5.62500 -3.62500000 169 17 17.63380 -0.63380282 170 16 17.63380 -1.63380282 171 16 17.63380 -1.63380282 > 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/4m0nr1323870246.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/5vn9m1323870246.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/684301323870246.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/743981323870246.tab") + } > > try(system("convert tmp/2hzm81323870246.ps tmp/2hzm81323870246.png",intern=TRUE)) character(0) > try(system("convert tmp/30xpo1323870246.ps tmp/30xpo1323870246.png",intern=TRUE)) character(0) > try(system("convert tmp/4m0nr1323870246.ps tmp/4m0nr1323870246.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.461 0.252 3.712