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(1 + ,1 + ,23 + ,17 + ,23 + ,1 + ,1 + ,24 + ,17 + ,20 + ,1 + ,1 + ,22 + ,18 + ,20 + ,1 + ,2 + ,20 + ,21 + ,21 + ,1 + ,1 + ,24 + ,20 + ,24 + ,1 + ,1 + ,27 + ,28 + ,22 + ,1 + ,2 + ,28 + ,19 + ,23 + ,1 + ,1 + ,27 + ,22 + ,20 + ,1 + ,1 + ,24 + ,16 + ,25 + ,1 + ,1 + ,23 + ,18 + ,23 + ,1 + ,2 + ,24 + ,25 + ,27 + ,1 + ,2 + ,27 + ,17 + ,27 + ,1 + ,1 + ,27 + ,14 + ,22 + ,1 + ,1 + ,28 + ,11 + ,24 + ,1 + ,1 + ,27 + ,27 + ,25 + ,1 + ,2 + ,23 + ,20 + ,22 + ,1 + ,1 + ,24 + ,22 + ,28 + ,1 + ,2 + ,28 + ,22 + ,28 + ,1 + ,2 + ,27 + ,21 + ,27 + ,1 + ,1 + ,25 + ,23 + ,25 + ,1 + ,2 + ,19 + ,17 + ,16 + ,1 + ,1 + ,24 + ,24 + ,28 + ,1 + ,1 + ,20 + ,14 + ,21 + ,1 + ,2 + ,28 + ,17 + ,24 + ,1 + ,1 + ,26 + ,23 + ,27 + ,1 + ,1 + ,23 + ,24 + ,14 + ,1 + ,1 + ,23 + ,24 + ,14 + ,1 + ,1 + ,20 + ,8 + ,27 + ,1 + ,2 + ,11 + ,22 + ,20 + ,1 + ,1 + ,24 + ,23 + ,21 + ,1 + ,2 + ,25 + ,25 + ,22 + ,1 + ,1 + ,23 + ,21 + ,21 + ,1 + ,1 + ,18 + ,24 + ,12 + ,1 + ,2 + ,20 + ,15 + ,20 + ,1 + ,2 + ,20 + ,22 + ,24 + ,1 + ,2 + ,24 + ,21 + ,19 + ,1 + ,1 + ,23 + ,25 + ,28 + ,1 + ,2 + ,25 + ,16 + ,23 + ,1 + ,2 + ,28 + ,28 + ,27 + ,1 + ,1 + ,26 + ,23 + ,22 + ,1 + ,1 + ,26 + ,21 + ,27 + ,1 + ,1 + ,23 + ,21 + ,26 + ,1 + ,1 + ,22 + ,26 + ,22 + ,1 + ,2 + ,24 + ,22 + ,21 + ,1 + ,2 + ,21 + ,21 + ,19 + ,1 + ,1 + ,20 + ,18 + ,24 + ,1 + ,2 + ,22 + ,12 + ,19 + ,1 + ,2 + ,20 + ,25 + ,26 + ,1 + ,1 + ,25 + ,17 + ,22 + ,1 + ,2 + ,20 + ,24 + ,28 + ,1 + ,1 + ,22 + ,15 + ,21 + ,1 + ,1 + ,23 + ,13 + ,23 + ,1 + ,1 + ,25 + ,26 + ,28 + ,1 + ,1 + ,23 + ,16 + ,10 + ,1 + ,2 + ,23 + ,24 + ,24 + ,1 + ,1 + ,22 + ,21 + ,21 + ,1 + ,1 + ,24 + ,20 + ,21 + ,1 + ,1 + ,25 + ,14 + ,24 + ,1 + ,2 + ,21 + ,25 + ,24 + ,1 + ,2 + ,12 + ,25 + ,25 + ,1 + ,1 + ,17 + ,20 + ,25 + ,1 + ,1 + ,20 + ,22 + ,23 + ,1 + ,1 + ,23 + ,20 + ,21 + ,1 + ,2 + ,23 + ,26 + ,16 + ,1 + ,1 + ,20 + ,18 + ,17 + ,1 + ,2 + ,28 + ,22 + ,25 + ,1 + ,2 + ,24 + ,24 + ,24 + ,1 + ,2 + ,24 + ,17 + ,23 + ,1 + ,1 + ,24 + ,24 + ,25 + ,1 + ,1 + ,24 + ,20 + ,23 + ,1 + ,1 + ,28 + ,19 + ,28 + ,1 + ,2 + ,25 + ,20 + ,26 + ,1 + ,2 + ,21 + ,15 + ,22 + ,1 + ,1 + ,25 + ,23 + ,19 + ,1 + ,1 + ,25 + ,26 + ,26 + ,1 + ,1 + ,18 + ,22 + ,18 + ,1 + ,1 + ,17 + ,20 + ,18 + ,1 + ,2 + ,26 + ,24 + ,25 + ,1 + ,2 + ,28 + ,26 + ,27 + ,1 + ,2 + ,21 + ,21 + ,12 + ,1 + ,2 + ,27 + ,25 + ,15 + ,1 + ,1 + ,22 + ,13 + ,21 + ,1 + ,0 + ,21 + ,20 + ,23 + ,1 + ,1 + ,25 + ,22 + ,22 + ,1 + ,2 + ,22 + ,23 + ,21 + ,1 + ,2 + ,23 + ,28 + ,24 + ,1 + ,1 + ,26 + ,22 + ,27 + ,1 + ,1 + ,19 + ,20 + ,22 + ,1 + ,1 + ,25 + ,6 + ,28 + ,1 + ,1 + ,21 + ,21 + ,26 + ,1 + ,1 + ,13 + ,20 + ,10 + ,1 + ,2 + ,24 + ,18 + ,19 + ,1 + ,1 + ,25 + ,23 + ,22 + ,1 + ,1 + ,26 + ,20 + ,21 + ,1 + ,1 + ,25 + ,24 + ,24 + ,1 + ,1 + ,25 + ,22 + ,25 + ,1 + ,2 + ,22 + ,21 + ,21 + ,1 + ,1 + ,21 + ,18 + ,20 + ,1 + ,2 + ,23 + ,21 + ,21 + ,0 + ,2 + ,25 + ,23 + ,24 + ,0 + ,1 + ,24 + ,23 + ,23 + ,0 + ,2 + ,21 + ,15 + ,18 + ,0 + ,1 + ,21 + ,21 + ,24 + ,0 + ,1 + ,25 + ,24 + ,24 + ,0 + ,2 + ,22 + ,23 + ,19 + ,0 + ,1 + ,20 + ,21 + ,20 + ,0 + ,2 + ,20 + ,21 + ,18 + ,0 + ,1 + ,23 + ,20 + ,20 + ,0 + ,1 + ,28 + ,11 + ,27 + ,0 + ,1 + ,23 + ,22 + ,23 + ,0 + ,1 + ,28 + ,27 + ,26 + ,0 + ,1 + ,24 + ,25 + ,23 + ,0 + ,1 + ,18 + ,18 + ,17 + ,0 + ,1 + ,20 + ,20 + ,21 + ,0 + ,1 + ,28 + ,24 + ,25 + ,0 + ,2 + ,21 + ,10 + ,23 + ,0 + ,1 + ,21 + ,27 + ,27 + ,0 + ,1 + ,25 + ,21 + ,24 + ,0 + ,2 + ,19 + ,21 + ,20 + ,0 + ,1 + ,18 + ,18 + ,27 + ,0 + ,1 + ,21 + ,15 + ,21 + ,0 + ,1 + ,22 + ,24 + ,24 + ,0 + ,1 + ,24 + ,22 + ,21 + ,0 + ,1 + ,15 + ,14 + ,15 + ,0 + ,1 + ,28 + ,28 + ,25 + ,0 + ,2 + ,26 + ,18 + ,25 + ,0 + ,1 + ,23 + ,26 + ,22 + ,0 + ,1 + ,26 + ,17 + ,24 + ,0 + ,2 + ,20 + ,19 + ,21 + ,0 + ,2 + ,22 + ,22 + ,22 + ,0 + ,1 + ,20 + ,18 + ,23 + ,0 + ,2 + ,23 + ,24 + ,22 + ,0 + ,2 + ,22 + ,15 + ,20 + ,0 + ,2 + ,24 + ,18 + ,23 + ,0 + ,2 + ,23 + ,26 + ,25 + ,0 + ,1 + ,22 + ,11 + ,23 + ,0 + ,1 + ,26 + ,26 + ,22 + ,0 + ,2 + ,23 + ,21 + ,25 + ,0 + ,2 + ,27 + ,23 + ,26 + ,0 + ,1 + ,23 + ,23 + ,22 + ,0 + ,1 + ,21 + ,15 + ,24 + ,0 + ,1 + ,26 + ,22 + ,24 + ,0 + ,1 + ,23 + ,26 + ,25 + ,0 + ,2 + ,21 + ,16 + ,20 + ,0 + ,1 + ,27 + ,20 + ,26 + ,0 + ,1 + ,19 + ,18 + ,21 + ,0 + ,2 + ,23 + ,22 + ,26 + ,0 + ,2 + ,25 + ,16 + ,21 + ,0 + ,2 + ,23 + ,19 + ,22 + ,0 + ,2 + ,22 + ,20 + ,16 + ,0 + ,1 + ,22 + ,19 + ,26 + ,0 + ,1 + ,25 + ,23 + ,28 + ,0 + ,1 + ,25 + ,24 + ,18 + ,0 + ,2 + ,28 + ,25 + ,25 + ,0 + ,2 + ,28 + ,21 + ,23 + ,0 + ,2 + ,20 + ,21 + ,21 + ,0 + ,1 + ,25 + ,23 + ,20 + ,0 + ,1 + ,19 + ,27 + ,25 + ,0 + ,1 + ,25 + ,23 + ,22 + ,0 + ,1 + ,22 + ,18 + ,21 + ,0 + ,2 + ,18 + ,16 + ,16 + ,0 + ,1 + ,20 + ,16 + ,18) + ,dim=c(5 + ,162) + ,dimnames=list(c('Pop' + ,'Gender' + ,'E1' + ,'E2' + ,'E3') + ,1:162)) > y <- array(NA,dim=c(5,162),dimnames=list(c('Pop','Gender','E1','E2','E3'),1:162)) > 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 = '5' > 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] "E3" > x[,par1] [1] 23 20 20 21 24 22 23 20 25 23 27 27 22 24 25 22 28 28 27 25 16 28 21 24 27 [26] 14 14 27 20 21 22 21 12 20 24 19 28 23 27 22 27 26 22 21 19 24 19 26 22 28 [51] 21 23 28 10 24 21 21 24 24 25 25 23 21 16 17 25 24 23 25 23 28 26 22 19 26 [76] 18 18 25 27 12 15 21 23 22 21 24 27 22 28 26 10 19 22 21 24 25 21 20 21 24 [101] 23 18 24 24 19 20 18 20 27 23 26 23 17 21 25 23 27 24 20 27 21 24 21 15 25 [126] 25 22 24 21 22 23 22 20 23 25 23 22 25 26 22 24 24 25 20 26 21 26 21 22 16 [151] 26 28 18 25 23 21 20 25 22 21 16 18 > 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]) 10 12 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 2 2 2 4 2 6 6 12 22 18 17 19 17 10 12 9 > colnames(x) [1] "Pop" "Gender" "E1" "E2" "E3" > colnames(x)[par1] [1] "E3" > x[,par1] [1] 23 20 20 21 24 22 23 20 25 23 27 27 22 24 25 22 28 28 27 25 16 28 21 24 27 [26] 14 14 27 20 21 22 21 12 20 24 19 28 23 27 22 27 26 22 21 19 24 19 26 22 28 [51] 21 23 28 10 24 21 21 24 24 25 25 23 21 16 17 25 24 23 25 23 28 26 22 19 26 [76] 18 18 25 27 12 15 21 23 22 21 24 27 22 28 26 10 19 22 21 24 25 21 20 21 24 [101] 23 18 24 24 19 20 18 20 27 23 26 23 17 21 25 23 27 24 20 27 21 24 21 15 25 [126] 25 22 24 21 22 23 22 20 23 25 23 22 25 26 22 24 24 25 20 26 21 26 21 22 16 [151] 26 28 18 25 23 21 20 25 22 21 16 18 > 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/1ecov1323722923.tab") + } + } > m Conditional inference tree with 2 terminal nodes Response: E3 Inputs: Pop, Gender, E1, E2 Number of observations: 162 1) E1 <= 23; criterion = 1, statistic = 27.859 2)* weights = 88 1) E1 > 23 3)* weights = 74 > postscript(file="/var/wessaorg/rcomp/tmp/2q2251323722923.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/3t3v91323722923.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 23 21.15909 1.8409091 2 20 23.86486 -3.8648649 3 20 21.15909 -1.1590909 4 21 21.15909 -0.1590909 5 24 23.86486 0.1351351 6 22 23.86486 -1.8648649 7 23 23.86486 -0.8648649 8 20 23.86486 -3.8648649 9 25 23.86486 1.1351351 10 23 21.15909 1.8409091 11 27 23.86486 3.1351351 12 27 23.86486 3.1351351 13 22 23.86486 -1.8648649 14 24 23.86486 0.1351351 15 25 23.86486 1.1351351 16 22 21.15909 0.8409091 17 28 23.86486 4.1351351 18 28 23.86486 4.1351351 19 27 23.86486 3.1351351 20 25 23.86486 1.1351351 21 16 21.15909 -5.1590909 22 28 23.86486 4.1351351 23 21 21.15909 -0.1590909 24 24 23.86486 0.1351351 25 27 23.86486 3.1351351 26 14 21.15909 -7.1590909 27 14 21.15909 -7.1590909 28 27 21.15909 5.8409091 29 20 21.15909 -1.1590909 30 21 23.86486 -2.8648649 31 22 23.86486 -1.8648649 32 21 21.15909 -0.1590909 33 12 21.15909 -9.1590909 34 20 21.15909 -1.1590909 35 24 21.15909 2.8409091 36 19 23.86486 -4.8648649 37 28 21.15909 6.8409091 38 23 23.86486 -0.8648649 39 27 23.86486 3.1351351 40 22 23.86486 -1.8648649 41 27 23.86486 3.1351351 42 26 21.15909 4.8409091 43 22 21.15909 0.8409091 44 21 23.86486 -2.8648649 45 19 21.15909 -2.1590909 46 24 21.15909 2.8409091 47 19 21.15909 -2.1590909 48 26 21.15909 4.8409091 49 22 23.86486 -1.8648649 50 28 21.15909 6.8409091 51 21 21.15909 -0.1590909 52 23 21.15909 1.8409091 53 28 23.86486 4.1351351 54 10 21.15909 -11.1590909 55 24 21.15909 2.8409091 56 21 21.15909 -0.1590909 57 21 23.86486 -2.8648649 58 24 23.86486 0.1351351 59 24 21.15909 2.8409091 60 25 21.15909 3.8409091 61 25 21.15909 3.8409091 62 23 21.15909 1.8409091 63 21 21.15909 -0.1590909 64 16 21.15909 -5.1590909 65 17 21.15909 -4.1590909 66 25 23.86486 1.1351351 67 24 23.86486 0.1351351 68 23 23.86486 -0.8648649 69 25 23.86486 1.1351351 70 23 23.86486 -0.8648649 71 28 23.86486 4.1351351 72 26 23.86486 2.1351351 73 22 21.15909 0.8409091 74 19 23.86486 -4.8648649 75 26 23.86486 2.1351351 76 18 21.15909 -3.1590909 77 18 21.15909 -3.1590909 78 25 23.86486 1.1351351 79 27 23.86486 3.1351351 80 12 21.15909 -9.1590909 81 15 23.86486 -8.8648649 82 21 21.15909 -0.1590909 83 23 21.15909 1.8409091 84 22 23.86486 -1.8648649 85 21 21.15909 -0.1590909 86 24 21.15909 2.8409091 87 27 23.86486 3.1351351 88 22 21.15909 0.8409091 89 28 23.86486 4.1351351 90 26 21.15909 4.8409091 91 10 21.15909 -11.1590909 92 19 23.86486 -4.8648649 93 22 23.86486 -1.8648649 94 21 23.86486 -2.8648649 95 24 23.86486 0.1351351 96 25 23.86486 1.1351351 97 21 21.15909 -0.1590909 98 20 21.15909 -1.1590909 99 21 21.15909 -0.1590909 100 24 23.86486 0.1351351 101 23 23.86486 -0.8648649 102 18 21.15909 -3.1590909 103 24 21.15909 2.8409091 104 24 23.86486 0.1351351 105 19 21.15909 -2.1590909 106 20 21.15909 -1.1590909 107 18 21.15909 -3.1590909 108 20 21.15909 -1.1590909 109 27 23.86486 3.1351351 110 23 21.15909 1.8409091 111 26 23.86486 2.1351351 112 23 23.86486 -0.8648649 113 17 21.15909 -4.1590909 114 21 21.15909 -0.1590909 115 25 23.86486 1.1351351 116 23 21.15909 1.8409091 117 27 21.15909 5.8409091 118 24 23.86486 0.1351351 119 20 21.15909 -1.1590909 120 27 21.15909 5.8409091 121 21 21.15909 -0.1590909 122 24 21.15909 2.8409091 123 21 23.86486 -2.8648649 124 15 21.15909 -6.1590909 125 25 23.86486 1.1351351 126 25 23.86486 1.1351351 127 22 21.15909 0.8409091 128 24 23.86486 0.1351351 129 21 21.15909 -0.1590909 130 22 21.15909 0.8409091 131 23 21.15909 1.8409091 132 22 21.15909 0.8409091 133 20 21.15909 -1.1590909 134 23 23.86486 -0.8648649 135 25 21.15909 3.8409091 136 23 21.15909 1.8409091 137 22 23.86486 -1.8648649 138 25 21.15909 3.8409091 139 26 23.86486 2.1351351 140 22 21.15909 0.8409091 141 24 21.15909 2.8409091 142 24 23.86486 0.1351351 143 25 21.15909 3.8409091 144 20 21.15909 -1.1590909 145 26 23.86486 2.1351351 146 21 21.15909 -0.1590909 147 26 21.15909 4.8409091 148 21 23.86486 -2.8648649 149 22 21.15909 0.8409091 150 16 21.15909 -5.1590909 151 26 21.15909 4.8409091 152 28 23.86486 4.1351351 153 18 23.86486 -5.8648649 154 25 23.86486 1.1351351 155 23 23.86486 -0.8648649 156 21 21.15909 -0.1590909 157 20 23.86486 -3.8648649 158 25 21.15909 3.8409091 159 22 23.86486 -1.8648649 160 21 21.15909 -0.1590909 161 16 21.15909 -5.1590909 162 18 21.15909 -3.1590909 > 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/4to6t1323722923.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/5lo4g1323722923.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/6ulya1323722923.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/7y0me1323722923.tab") + } > > try(system("convert tmp/2q2251323722923.ps tmp/2q2251323722923.png",intern=TRUE)) character(0) > try(system("convert tmp/3t3v91323722923.ps tmp/3t3v91323722923.png",intern=TRUE)) character(0) > try(system("convert tmp/4to6t1323722923.ps tmp/4to6t1323722923.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.023 0.283 3.362