R version 2.12.1 (2010-12-16) Copyright (C) 2010 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(41 + ,38 + ,14 + ,12 + ,39 + ,32 + ,18 + ,11 + ,30 + ,35 + ,11 + ,14 + ,31 + ,33 + ,12 + ,12 + ,34 + ,37 + ,16 + ,21 + ,35 + ,29 + ,18 + ,12 + ,39 + ,31 + ,14 + ,22 + ,34 + ,36 + ,14 + ,11 + ,36 + ,35 + ,15 + ,10 + ,37 + ,38 + ,15 + ,13 + ,38 + ,31 + ,17 + ,10 + ,36 + ,34 + ,19 + ,8 + ,38 + ,35 + ,10 + ,15 + ,39 + ,38 + ,16 + ,14 + ,33 + ,37 + ,18 + ,10 + ,32 + ,33 + ,14 + ,14 + ,36 + ,32 + ,14 + ,14 + ,38 + ,38 + ,17 + ,11 + ,39 + ,38 + ,14 + ,10 + ,32 + ,32 + ,16 + ,13 + ,32 + ,33 + ,18 + ,7 + ,31 + ,31 + ,11 + ,14 + ,39 + ,38 + ,14 + ,12 + ,37 + ,39 + ,12 + ,14 + ,39 + ,32 + ,17 + ,11 + ,41 + ,32 + ,9 + ,9 + ,36 + ,35 + ,16 + ,11 + ,33 + ,37 + ,14 + ,15 + ,33 + ,33 + ,15 + ,14 + ,34 + ,33 + ,11 + ,13 + ,31 + ,28 + ,16 + ,9 + ,27 + ,32 + ,13 + ,15 + ,37 + ,31 + ,17 + ,10 + ,34 + ,37 + ,15 + ,11 + ,34 + ,30 + ,14 + ,13 + ,32 + ,33 + ,16 + ,8 + ,29 + ,31 + ,9 + ,20 + ,36 + ,33 + ,15 + ,12 + ,29 + ,31 + ,17 + ,10 + ,35 + ,33 + ,13 + ,10 + ,37 + ,32 + ,15 + ,9 + ,34 + ,33 + ,16 + ,14 + ,38 + ,32 + ,16 + ,8 + ,35 + ,33 + ,12 + ,14 + ,38 + ,28 + ,12 + ,11 + ,37 + ,35 + ,11 + ,13 + ,38 + ,39 + ,15 + ,9 + ,33 + ,34 + ,15 + ,11 + ,36 + ,38 + ,17 + ,15 + ,38 + ,32 + ,13 + ,11 + ,32 + ,38 + ,16 + ,10 + ,32 + ,30 + ,14 + ,14 + ,32 + ,33 + ,11 + ,18 + ,34 + ,38 + ,12 + ,14 + ,32 + ,32 + ,12 + ,11 + ,37 + ,32 + ,15 + ,12 + ,39 + ,34 + ,16 + ,13 + ,29 + ,34 + ,15 + ,9 + ,37 + ,36 + ,12 + ,10 + ,35 + ,34 + ,12 + ,15 + ,30 + ,28 + ,8 + ,20 + ,38 + ,34 + ,13 + ,12 + ,34 + ,35 + ,11 + ,12 + ,31 + ,35 + ,14 + ,14 + ,34 + ,31 + ,15 + ,13 + ,35 + ,37 + ,10 + ,11 + ,36 + ,35 + ,11 + ,17 + ,30 + ,27 + ,12 + ,12 + ,39 + ,40 + ,15 + ,13 + ,35 + ,37 + ,15 + ,14 + ,38 + ,36 + ,14 + ,13 + ,31 + ,38 + ,16 + ,15 + ,34 + ,39 + ,15 + ,13 + ,38 + ,41 + ,15 + ,10 + ,34 + ,27 + ,13 + ,11 + ,39 + ,30 + ,12 + ,19 + ,37 + ,37 + ,17 + ,13 + ,34 + ,31 + ,13 + ,17 + ,28 + ,31 + ,15 + ,13 + ,37 + ,27 + ,13 + ,9 + ,33 + ,36 + ,15 + ,11 + ,37 + ,38 + ,16 + ,10 + ,35 + ,37 + ,15 + ,9 + ,37 + ,33 + ,16 + ,12 + ,32 + ,34 + ,15 + ,12 + ,33 + ,31 + ,14 + ,13 + ,38 + ,39 + ,15 + ,13 + ,33 + ,34 + ,14 + ,12 + ,29 + ,32 + ,13 + ,15 + ,33 + ,33 + ,7 + ,22 + ,31 + ,36 + ,17 + ,13 + ,36 + ,32 + ,13 + ,15 + ,35 + ,41 + ,15 + ,13 + ,32 + ,28 + ,14 + ,15 + ,29 + ,30 + ,13 + ,10 + ,39 + ,36 + ,16 + ,11 + ,37 + ,35 + ,12 + ,16 + ,35 + ,31 + ,14 + ,11 + ,37 + ,34 + ,17 + ,11 + ,32 + ,36 + ,15 + ,10 + ,38 + ,36 + ,17 + ,10 + ,37 + ,35 + ,12 + ,16 + ,36 + ,37 + ,16 + ,12 + ,32 + ,28 + ,11 + ,11 + ,33 + ,39 + ,15 + ,16 + ,40 + ,32 + ,9 + ,19 + ,38 + ,35 + ,16 + ,11 + ,41 + ,39 + ,15 + ,16 + ,36 + ,35 + ,10 + ,15 + ,43 + ,42 + ,10 + ,24 + ,30 + ,34 + ,15 + ,14 + ,31 + ,33 + ,11 + ,15 + ,32 + ,41 + ,13 + ,11 + ,32 + ,33 + ,14 + ,15 + ,37 + ,34 + ,18 + ,12 + ,37 + ,32 + ,16 + ,10 + ,33 + ,40 + ,14 + ,14 + ,34 + ,40 + ,14 + ,13 + ,33 + ,35 + ,14 + ,9 + ,38 + ,36 + ,14 + ,15 + ,33 + ,37 + ,12 + ,15 + ,31 + ,27 + ,14 + ,14 + ,38 + ,39 + ,15 + ,11 + ,37 + ,38 + ,15 + ,8 + ,33 + ,31 + ,15 + ,11 + ,31 + ,33 + ,13 + ,11 + ,39 + ,32 + ,17 + ,8 + ,44 + ,39 + ,17 + ,10 + ,33 + ,36 + ,19 + ,11 + ,35 + ,33 + ,15 + ,13 + ,32 + ,33 + ,13 + ,11 + ,28 + ,32 + ,9 + ,20 + ,40 + ,37 + ,15 + ,10 + ,27 + ,30 + ,15 + ,15 + ,37 + ,38 + ,15 + ,12 + ,32 + ,29 + ,16 + ,14 + ,28 + ,22 + ,11 + ,23 + ,34 + ,35 + ,14 + ,14 + ,30 + ,35 + ,11 + ,16 + ,35 + ,34 + ,15 + ,11 + ,31 + ,35 + ,13 + ,12 + ,32 + ,34 + ,15 + ,10 + ,30 + ,34 + ,16 + ,14 + ,30 + ,35 + ,14 + ,12 + ,31 + ,23 + ,15 + ,12 + ,40 + ,31 + ,16 + ,11 + ,32 + ,27 + ,16 + ,12 + ,36 + ,36 + ,11 + ,13 + ,32 + ,31 + ,12 + ,11 + ,35 + ,32 + ,9 + ,19 + ,38 + ,39 + ,16 + ,12 + ,42 + ,37 + ,13 + ,17 + ,34 + ,38 + ,16 + ,9 + ,35 + ,39 + ,12 + ,12 + ,35 + ,34 + ,9 + ,19 + ,33 + ,31 + ,13 + ,18 + ,36 + ,32 + ,13 + ,15 + ,32 + ,37 + ,14 + ,14 + ,33 + ,36 + ,19 + ,11 + ,34 + ,32 + ,13 + ,9 + ,32 + ,35 + ,12 + ,18 + ,34 + ,36 + ,13 + ,16) + ,dim=c(4 + ,162) + ,dimnames=list(c('connected' + ,'seperate' + ,'hapiness' + ,'depression ') + ,1:162)) > y <- array(NA,dim=c(4,162),dimnames=list(c('connected','seperate','hapiness','depression '),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 = '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] "depression." > x[,par1] [1] 12 11 14 12 21 12 22 11 10 13 10 8 15 14 10 14 14 11 10 13 7 14 12 14 11 [26] 9 11 15 14 13 9 15 10 11 13 8 20 12 10 10 9 14 8 14 11 13 9 11 15 11 [51] 10 14 18 14 11 12 13 9 10 15 20 12 12 14 13 11 17 12 13 14 13 15 13 10 11 [76] 19 13 17 13 9 11 10 9 12 12 13 13 12 15 22 13 15 13 15 10 11 16 11 11 10 [101] 10 16 12 11 16 19 11 16 15 24 14 15 11 15 12 10 14 13 9 15 15 14 11 8 11 [126] 11 8 10 11 13 11 20 10 15 12 14 23 14 16 11 12 10 14 12 12 11 12 13 11 19 [151] 12 17 9 12 19 18 15 14 11 9 18 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]) 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 5 10 18 28 21 19 20 16 6 3 3 4 3 1 2 1 1 > colnames(x) [1] "connected" "seperate" "hapiness" "depression." > colnames(x)[par1] [1] "depression." > x[,par1] [1] 12 11 14 12 21 12 22 11 10 13 10 8 15 14 10 14 14 11 10 13 7 14 12 14 11 [26] 9 11 15 14 13 9 15 10 11 13 8 20 12 10 10 9 14 8 14 11 13 9 11 15 11 [51] 10 14 18 14 11 12 13 9 10 15 20 12 12 14 13 11 17 12 13 14 13 15 13 10 11 [76] 19 13 17 13 9 11 10 9 12 12 13 13 12 15 22 13 15 13 15 10 11 16 11 11 10 [101] 10 16 12 11 16 19 11 16 15 24 14 15 11 15 12 10 14 13 9 15 15 14 11 8 11 [126] 11 8 10 11 13 11 20 10 15 12 14 23 14 16 11 12 10 14 12 12 11 12 13 11 19 [151] 12 17 9 12 19 18 15 14 11 9 18 16 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/12knn1323872659.tab") + } + } > m Conditional inference tree with 3 terminal nodes Response: depression. Inputs: connected, seperate, hapiness Number of observations: 162 1) hapiness <= 11; criterion = 1, statistic = 47.688 2)* weights = 24 1) hapiness > 11 3) hapiness <= 14; criterion = 1, statistic = 17.498 4)* weights = 60 3) hapiness > 14 5)* weights = 78 > postscript(file="/var/www/rcomp/tmp/2in1h1323872659.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/www/rcomp/tmp/35ith1323872659.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 12 13.33333 -1.3333333 2 11 11.55128 -0.5512821 3 14 16.33333 -2.3333333 4 12 13.33333 -1.3333333 5 21 11.55128 9.4487179 6 12 11.55128 0.4487179 7 22 13.33333 8.6666667 8 11 13.33333 -2.3333333 9 10 11.55128 -1.5512821 10 13 11.55128 1.4487179 11 10 11.55128 -1.5512821 12 8 11.55128 -3.5512821 13 15 16.33333 -1.3333333 14 14 11.55128 2.4487179 15 10 11.55128 -1.5512821 16 14 13.33333 0.6666667 17 14 13.33333 0.6666667 18 11 11.55128 -0.5512821 19 10 13.33333 -3.3333333 20 13 11.55128 1.4487179 21 7 11.55128 -4.5512821 22 14 16.33333 -2.3333333 23 12 13.33333 -1.3333333 24 14 13.33333 0.6666667 25 11 11.55128 -0.5512821 26 9 16.33333 -7.3333333 27 11 11.55128 -0.5512821 28 15 13.33333 1.6666667 29 14 11.55128 2.4487179 30 13 16.33333 -3.3333333 31 9 11.55128 -2.5512821 32 15 13.33333 1.6666667 33 10 11.55128 -1.5512821 34 11 11.55128 -0.5512821 35 13 13.33333 -0.3333333 36 8 11.55128 -3.5512821 37 20 16.33333 3.6666667 38 12 11.55128 0.4487179 39 10 11.55128 -1.5512821 40 10 13.33333 -3.3333333 41 9 11.55128 -2.5512821 42 14 11.55128 2.4487179 43 8 11.55128 -3.5512821 44 14 13.33333 0.6666667 45 11 13.33333 -2.3333333 46 13 16.33333 -3.3333333 47 9 11.55128 -2.5512821 48 11 11.55128 -0.5512821 49 15 11.55128 3.4487179 50 11 13.33333 -2.3333333 51 10 11.55128 -1.5512821 52 14 13.33333 0.6666667 53 18 16.33333 1.6666667 54 14 13.33333 0.6666667 55 11 13.33333 -2.3333333 56 12 11.55128 0.4487179 57 13 11.55128 1.4487179 58 9 11.55128 -2.5512821 59 10 13.33333 -3.3333333 60 15 13.33333 1.6666667 61 20 16.33333 3.6666667 62 12 13.33333 -1.3333333 63 12 16.33333 -4.3333333 64 14 13.33333 0.6666667 65 13 11.55128 1.4487179 66 11 16.33333 -5.3333333 67 17 16.33333 0.6666667 68 12 13.33333 -1.3333333 69 13 11.55128 1.4487179 70 14 11.55128 2.4487179 71 13 13.33333 -0.3333333 72 15 11.55128 3.4487179 73 13 11.55128 1.4487179 74 10 11.55128 -1.5512821 75 11 13.33333 -2.3333333 76 19 13.33333 5.6666667 77 13 11.55128 1.4487179 78 17 13.33333 3.6666667 79 13 11.55128 1.4487179 80 9 13.33333 -4.3333333 81 11 11.55128 -0.5512821 82 10 11.55128 -1.5512821 83 9 11.55128 -2.5512821 84 12 11.55128 0.4487179 85 12 11.55128 0.4487179 86 13 13.33333 -0.3333333 87 13 11.55128 1.4487179 88 12 13.33333 -1.3333333 89 15 13.33333 1.6666667 90 22 16.33333 5.6666667 91 13 11.55128 1.4487179 92 15 13.33333 1.6666667 93 13 11.55128 1.4487179 94 15 13.33333 1.6666667 95 10 13.33333 -3.3333333 96 11 11.55128 -0.5512821 97 16 13.33333 2.6666667 98 11 13.33333 -2.3333333 99 11 11.55128 -0.5512821 100 10 11.55128 -1.5512821 101 10 11.55128 -1.5512821 102 16 13.33333 2.6666667 103 12 11.55128 0.4487179 104 11 16.33333 -5.3333333 105 16 11.55128 4.4487179 106 19 16.33333 2.6666667 107 11 11.55128 -0.5512821 108 16 11.55128 4.4487179 109 15 16.33333 -1.3333333 110 24 16.33333 7.6666667 111 14 11.55128 2.4487179 112 15 16.33333 -1.3333333 113 11 13.33333 -2.3333333 114 15 13.33333 1.6666667 115 12 11.55128 0.4487179 116 10 11.55128 -1.5512821 117 14 13.33333 0.6666667 118 13 13.33333 -0.3333333 119 9 13.33333 -4.3333333 120 15 13.33333 1.6666667 121 15 13.33333 1.6666667 122 14 13.33333 0.6666667 123 11 11.55128 -0.5512821 124 8 11.55128 -3.5512821 125 11 11.55128 -0.5512821 126 11 13.33333 -2.3333333 127 8 11.55128 -3.5512821 128 10 11.55128 -1.5512821 129 11 11.55128 -0.5512821 130 13 11.55128 1.4487179 131 11 13.33333 -2.3333333 132 20 16.33333 3.6666667 133 10 11.55128 -1.5512821 134 15 11.55128 3.4487179 135 12 11.55128 0.4487179 136 14 11.55128 2.4487179 137 23 16.33333 6.6666667 138 14 13.33333 0.6666667 139 16 16.33333 -0.3333333 140 11 11.55128 -0.5512821 141 12 13.33333 -1.3333333 142 10 11.55128 -1.5512821 143 14 11.55128 2.4487179 144 12 13.33333 -1.3333333 145 12 11.55128 0.4487179 146 11 11.55128 -0.5512821 147 12 11.55128 0.4487179 148 13 16.33333 -3.3333333 149 11 13.33333 -2.3333333 150 19 16.33333 2.6666667 151 12 11.55128 0.4487179 152 17 13.33333 3.6666667 153 9 11.55128 -2.5512821 154 12 13.33333 -1.3333333 155 19 16.33333 2.6666667 156 18 13.33333 4.6666667 157 15 13.33333 1.6666667 158 14 13.33333 0.6666667 159 11 11.55128 -0.5512821 160 9 13.33333 -4.3333333 161 18 13.33333 4.6666667 162 16 13.33333 2.6666667 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/www/rcomp/tmp/4jya31323872659.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/www/rcomp/tmp/52mj01323872659.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/www/rcomp/tmp/63sf91323872659.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/www/rcomp/tmp/71amk1323872659.tab") + } > > try(system("convert tmp/2in1h1323872659.ps tmp/2in1h1323872659.png",intern=TRUE)) character(0) > try(system("convert tmp/35ith1323872659.ps tmp/35ith1323872659.png",intern=TRUE)) character(0) > try(system("convert tmp/4jya31323872659.ps tmp/4jya31323872659.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.668 0.284 4.242