R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(2 + ,7 + ,41 + ,38 + ,13 + ,12 + ,14 + ,12 + ,2 + ,5 + ,39 + ,32 + ,16 + ,11 + ,18 + ,11 + ,2 + ,5 + ,30 + ,35 + ,19 + ,15 + ,11 + ,14 + ,1 + ,5 + ,31 + ,33 + ,15 + ,6 + ,12 + ,12 + ,2 + ,8 + ,34 + ,37 + ,14 + ,13 + ,16 + ,21 + ,2 + ,6 + ,35 + ,29 + ,13 + ,10 + ,18 + ,12 + ,2 + ,5 + ,39 + ,31 + ,19 + ,12 + ,14 + ,22 + ,2 + ,6 + ,34 + ,36 + ,15 + ,14 + ,14 + ,11 + ,2 + ,5 + ,36 + ,35 + ,14 + ,12 + ,15 + ,10 + ,2 + ,4 + ,37 + ,38 + ,15 + ,6 + ,15 + ,13 + ,1 + ,6 + ,38 + ,31 + ,16 + ,10 + ,17 + ,10 + ,2 + ,5 + ,36 + ,34 + ,16 + ,12 + ,19 + ,8 + ,1 + ,5 + ,38 + ,35 + ,16 + ,12 + ,10 + ,15 + ,2 + ,6 + ,39 + ,38 + ,16 + ,11 + ,16 + ,14 + ,2 + ,7 + ,33 + ,37 + ,17 + ,15 + ,18 + ,10 + ,1 + ,6 + ,32 + ,33 + ,15 + ,12 + ,14 + ,14 + ,1 + ,7 + ,36 + ,32 + ,15 + ,10 + ,14 + ,14 + ,2 + ,6 + ,38 + ,38 + ,20 + ,12 + ,17 + ,11 + ,1 + ,8 + ,39 + ,38 + ,18 + ,11 + ,14 + ,10 + ,2 + ,7 + ,32 + ,32 + ,16 + ,12 + ,16 + ,13 + ,1 + ,5 + ,32 + ,33 + ,16 + ,11 + ,18 + ,7 + ,2 + ,5 + ,31 + ,31 + ,16 + ,12 + ,11 + ,14 + ,2 + ,7 + ,39 + ,38 + ,19 + ,13 + ,14 + ,12 + ,2 + ,7 + ,37 + ,39 + ,16 + ,11 + ,12 + ,14 + ,1 + ,5 + ,39 + ,32 + ,17 + ,9 + ,17 + ,11 + ,2 + ,4 + ,41 + ,32 + ,17 + ,13 + ,9 + ,9 + ,1 + ,10 + ,36 + ,35 + ,16 + ,10 + ,16 + ,11 + ,2 + ,6 + ,33 + ,37 + ,15 + ,14 + ,14 + ,15 + ,2 + ,5 + ,33 + ,33 + ,16 + ,12 + ,15 + ,14 + ,1 + ,5 + ,34 + ,33 + ,14 + ,10 + ,11 + ,13 + ,2 + ,5 + ,31 + ,28 + ,15 + ,12 + ,16 + ,9 + ,1 + ,5 + ,27 + ,32 + ,12 + ,8 + ,13 + ,15 + ,2 + ,6 + ,37 + ,31 + ,14 + ,10 + ,17 + ,10 + ,2 + ,5 + ,34 + ,37 + ,16 + ,12 + ,15 + ,11 + ,1 + ,5 + ,34 + ,30 + ,14 + ,12 + ,14 + ,13 + ,1 + ,5 + ,32 + ,33 + ,7 + ,7 + ,16 + ,8 + ,1 + ,5 + ,29 + ,31 + ,10 + ,6 + ,9 + ,20 + ,1 + ,5 + ,36 + ,33 + ,14 + ,12 + ,15 + ,12 + ,2 + ,5 + ,29 + ,31 + ,16 + ,10 + ,17 + ,10 + ,1 + ,5 + ,35 + ,33 + ,16 + ,10 + ,13 + ,10 + ,1 + ,5 + ,37 + ,32 + ,16 + ,10 + ,15 + ,9 + ,2 + ,7 + ,34 + ,33 + ,14 + ,12 + ,16 + ,14 + ,1 + ,5 + ,38 + ,32 + ,20 + ,15 + ,16 + ,8 + ,1 + ,6 + ,35 + ,33 + ,14 + ,10 + ,12 + ,14 + ,2 + ,7 + ,38 + ,28 + ,14 + ,10 + ,12 + ,11 + ,2 + ,7 + ,37 + ,35 + ,11 + ,12 + ,11 + ,13 + ,2 + ,5 + ,38 + ,39 + ,14 + ,13 + ,15 + ,9 + ,2 + ,5 + ,33 + ,34 + ,15 + ,11 + ,15 + ,11 + ,2 + ,4 + ,36 + ,38 + ,16 + ,11 + ,17 + ,15 + ,1 + ,5 + ,38 + ,32 + ,14 + ,12 + ,13 + ,11 + ,2 + ,4 + ,32 + ,38 + ,16 + ,14 + ,16 + ,10 + ,1 + ,5 + ,32 + ,30 + ,14 + ,10 + ,14 + ,14 + ,1 + ,5 + ,32 + ,33 + ,12 + ,12 + ,11 + ,18 + ,2 + ,7 + ,34 + ,38 + ,16 + ,13 + ,12 + ,14 + ,1 + ,5 + ,32 + ,32 + ,9 + ,5 + ,12 + ,11 + ,2 + ,5 + ,37 + ,32 + ,14 + ,6 + ,15 + ,12 + ,2 + ,6 + ,39 + ,34 + ,16 + ,12 + ,16 + ,13 + ,2 + ,4 + ,29 + ,34 + ,16 + ,12 + ,15 + ,9 + ,1 + ,6 + ,37 + ,36 + ,15 + ,11 + ,12 + ,10 + ,2 + ,6 + ,35 + ,34 + ,16 + ,10 + ,12 + ,15 + ,1 + ,5 + ,30 + ,28 + ,12 + ,7 + ,8 + ,20 + ,1 + ,7 + ,38 + ,34 + ,16 + ,12 + ,13 + ,12 + ,2 + ,6 + ,34 + ,35 + ,16 + ,14 + ,11 + ,12 + ,2 + ,8 + ,31 + ,35 + ,14 + ,11 + ,14 + ,14 + ,2 + ,7 + ,34 + ,31 + ,16 + ,12 + ,15 + ,13 + ,1 + ,5 + ,35 + ,37 + ,17 + ,13 + ,10 + ,11 + ,2 + ,6 + ,36 + ,35 + ,18 + ,14 + ,11 + ,17 + ,1 + ,6 + ,30 + ,27 + ,18 + ,11 + ,12 + ,12 + ,2 + ,5 + ,39 + ,40 + ,12 + ,12 + ,15 + ,13 + ,1 + ,5 + ,35 + ,37 + ,16 + ,12 + ,15 + ,14 + ,1 + ,5 + ,38 + ,36 + ,10 + ,8 + ,14 + ,13 + ,2 + ,5 + ,31 + ,38 + ,14 + ,11 + ,16 + ,15 + ,2 + ,4 + ,34 + ,39 + ,18 + ,14 + ,15 + ,13 + ,1 + ,6 + ,38 + ,41 + ,18 + ,14 + ,15 + ,10 + ,1 + ,6 + ,34 + ,27 + ,16 + ,12 + ,13 + ,11 + ,2 + ,6 + ,39 + ,30 + ,17 + ,9 + ,12 + ,19 + ,2 + ,6 + ,37 + ,37 + ,16 + ,13 + ,17 + ,13 + ,2 + ,7 + ,34 + ,31 + ,16 + ,11 + ,13 + ,17 + ,1 + ,5 + ,28 + ,31 + ,13 + ,12 + ,15 + ,13 + ,1 + ,7 + ,37 + ,27 + ,16 + ,12 + ,13 + ,9 + ,1 + ,6 + ,33 + ,36 + ,16 + ,12 + ,15 + ,11 + ,1 + ,5 + ,37 + ,38 + ,20 + ,12 + ,16 + ,10 + ,2 + ,5 + ,35 + ,37 + ,16 + ,12 + ,15 + ,9 + ,1 + ,4 + ,37 + ,33 + ,15 + ,12 + ,16 + ,12 + ,2 + ,8 + ,32 + ,34 + ,15 + ,11 + ,15 + ,12 + ,2 + ,8 + ,33 + ,31 + ,16 + ,10 + ,14 + ,13 + ,1 + ,5 + ,38 + ,39 + ,14 + ,9 + ,15 + ,13 + ,2 + ,5 + ,33 + ,34 + ,16 + ,12 + ,14 + ,12 + ,2 + ,6 + ,29 + ,32 + ,16 + ,12 + ,13 + ,15 + ,2 + ,4 + ,33 + ,33 + ,15 + ,12 + ,7 + ,22 + ,2 + ,5 + ,31 + ,36 + ,12 + ,9 + ,17 + ,13 + ,2 + ,5 + ,36 + ,32 + ,17 + ,15 + ,13 + ,15 + ,2 + ,5 + ,35 + ,41 + ,16 + ,12 + ,15 + ,13 + ,2 + ,5 + ,32 + ,28 + ,15 + ,12 + ,14 + ,15 + ,2 + ,6 + ,29 + ,30 + ,13 + ,12 + ,13 + ,10 + ,2 + ,6 + ,39 + ,36 + ,16 + ,10 + ,16 + ,11 + ,2 + ,5 + ,37 + ,35 + ,16 + ,13 + ,12 + ,16 + ,2 + ,6 + ,35 + ,31 + ,16 + ,9 + ,14 + ,11 + ,1 + ,5 + ,37 + ,34 + ,16 + ,12 + ,17 + ,11 + ,1 + ,7 + ,32 + ,36 + ,14 + ,10 + ,15 + ,10 + ,2 + ,5 + ,38 + ,36 + ,16 + ,14 + ,17 + ,10 + ,1 + ,6 + ,37 + ,35 + ,16 + ,11 + ,12 + ,16 + ,2 + ,6 + ,36 + ,37 + ,20 + ,15 + ,16 + ,12 + ,1 + ,6 + ,32 + ,28 + ,15 + ,11 + ,11 + ,11 + ,2 + ,4 + ,33 + ,39 + ,16 + ,11 + ,15 + ,16 + ,1 + ,5 + ,40 + ,32 + ,13 + ,12 + ,9 + ,19 + ,2 + ,5 + ,38 + ,35 + ,17 + ,12 + ,16 + ,11 + ,1 + ,7 + ,41 + ,39 + ,16 + ,12 + ,15 + ,16 + ,1 + ,6 + ,36 + ,35 + ,16 + ,11 + ,10 + ,15 + ,2 + ,9 + ,43 + ,42 + ,12 + ,7 + ,10 + ,24 + ,2 + ,6 + ,30 + ,34 + ,16 + ,12 + ,15 + ,14 + ,2 + ,6 + ,31 + ,33 + ,16 + ,14 + ,11 + ,15 + ,2 + ,5 + ,32 + ,41 + ,17 + ,11 + ,13 + ,11 + ,1 + ,6 + ,32 + ,33 + ,13 + ,11 + ,14 + ,15 + ,2 + ,5 + ,37 + ,34 + ,12 + ,10 + ,18 + ,12 + ,1 + ,8 + ,37 + ,32 + ,18 + ,13 + ,16 + ,10 + ,2 + ,7 + ,33 + ,40 + ,14 + ,13 + ,14 + ,14 + ,2 + ,5 + ,34 + ,40 + ,14 + ,8 + ,14 + ,13 + ,2 + ,7 + ,33 + ,35 + ,13 + ,11 + ,14 + ,9 + ,2 + ,6 + ,38 + ,36 + ,16 + ,12 + ,14 + ,15 + ,2 + ,6 + ,33 + ,37 + ,13 + ,11 + ,12 + ,15 + ,2 + ,9 + ,31 + ,27 + ,16 + ,13 + ,14 + ,14 + ,2 + ,7 + ,38 + ,39 + ,13 + ,12 + ,15 + ,11 + ,2 + ,6 + ,37 + ,38 + ,16 + ,14 + ,15 + ,8 + ,2 + ,5 + ,33 + ,31 + ,15 + ,13 + ,15 + ,11 + ,2 + ,5 + ,31 + ,33 + ,16 + ,15 + ,13 + ,11 + ,1 + ,6 + ,39 + ,32 + ,15 + ,10 + ,17 + ,8 + ,2 + ,6 + ,44 + ,39 + ,17 + ,11 + ,17 + ,10 + ,2 + ,7 + ,33 + ,36 + ,15 + ,9 + ,19 + ,11 + ,2 + ,5 + ,35 + ,33 + ,12 + ,11 + ,15 + ,13 + ,1 + ,5 + ,32 + ,33 + ,16 + ,10 + ,13 + ,11 + ,1 + ,5 + ,28 + ,32 + ,10 + ,11 + ,9 + ,20 + ,2 + ,6 + ,40 + ,37 + ,16 + ,8 + ,15 + ,10 + ,1 + ,4 + ,27 + ,30 + ,12 + ,11 + ,15 + ,15 + ,1 + ,5 + ,37 + ,38 + ,14 + ,12 + ,15 + ,12 + ,2 + ,7 + ,32 + ,29 + ,15 + ,12 + ,16 + ,14 + ,1 + ,5 + ,28 + ,22 + ,13 + ,9 + ,11 + ,23 + ,1 + ,7 + ,34 + ,35 + ,15 + ,11 + ,14 + ,14 + ,2 + ,7 + ,30 + ,35 + ,11 + ,10 + ,11 + ,16 + ,2 + ,6 + ,35 + ,34 + ,12 + ,8 + ,15 + ,11 + ,1 + ,5 + ,31 + ,35 + ,8 + ,9 + ,13 + ,12 + ,2 + ,8 + ,32 + ,34 + ,16 + ,8 + ,15 + ,10 + ,1 + ,5 + ,30 + ,34 + ,15 + ,9 + ,16 + ,14 + ,2 + ,5 + ,30 + ,35 + ,17 + ,15 + ,14 + ,12 + ,1 + ,5 + ,31 + ,23 + ,16 + ,11 + ,15 + ,12 + ,2 + ,6 + ,40 + ,31 + ,10 + ,8 + ,16 + ,11 + ,2 + ,4 + ,32 + ,27 + ,18 + ,13 + ,16 + ,12 + ,1 + ,5 + ,36 + ,36 + ,13 + ,12 + ,11 + ,13 + ,1 + ,5 + ,32 + ,31 + ,16 + ,12 + ,12 + ,11 + ,1 + ,7 + ,35 + ,32 + ,13 + ,9 + ,9 + ,19 + ,2 + ,6 + ,38 + ,39 + ,10 + ,7 + ,16 + ,12 + ,2 + ,7 + ,42 + ,37 + ,15 + ,13 + ,13 + ,17 + ,1 + ,10 + ,34 + ,38 + ,16 + ,9 + ,16 + ,9 + ,2 + ,6 + ,35 + ,39 + ,16 + ,6 + ,12 + ,12 + ,2 + ,8 + ,35 + ,34 + ,14 + ,8 + ,9 + ,19 + ,2 + ,4 + ,33 + ,31 + ,10 + ,8 + ,13 + ,18 + ,2 + ,5 + ,36 + ,32 + ,17 + ,15 + ,13 + ,15 + ,2 + ,6 + ,32 + ,37 + ,13 + ,6 + ,14 + ,14 + ,2 + ,7 + ,33 + ,36 + ,15 + ,9 + ,19 + ,11 + ,2 + ,7 + ,34 + ,32 + ,16 + ,11 + ,13 + ,9 + ,2 + ,6 + ,32 + ,35 + ,12 + ,8 + ,12 + ,18 + ,2 + ,6 + ,34 + ,36 + ,13 + ,8 + ,13 + ,16) + ,dim=c(8 + ,162) + ,dimnames=list(c('Gender' + ,'Age' + ,'Connected' + ,'Separate' + ,'Learning' + ,'Software' + ,'Happiness' + ,'Depression') + ,1:162)) > y <- array(NA,dim=c(8,162),dimnames=list(c('Gender','Age','Connected','Separate','Learning','Software','Happiness','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 = '3' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '3' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., 2012, Recursive Partitioning (Regression Trees) (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_regression_trees.wasp/ > #Source of accompanying publication: > # > 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 Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, as.Date.numeric Loading required package: sandwich Loading required package: strucchange Loading required package: vcd Loading required package: MASS Loading required package: colorspace > library(Hmisc) Hmisc library by Frank E Harrell Jr Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview') to see overall documentation. NOTE:Hmisc no longer redefines [.factor to drop unused levels when subsetting. To get the old behavior of Hmisc type dropUnusedLevels(). 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] "Connected" > x[,par1] [1] 41 39 30 31 34 35 39 34 36 37 38 36 38 39 33 32 36 38 39 32 32 31 39 37 39 [26] 41 36 33 33 34 31 27 37 34 34 32 29 36 29 35 37 34 38 35 38 37 38 33 36 38 [51] 32 32 32 34 32 37 39 29 37 35 30 38 34 31 34 35 36 30 39 35 38 31 34 38 34 [76] 39 37 34 28 37 33 37 35 37 32 33 38 33 29 33 31 36 35 32 29 39 37 35 37 32 [101] 38 37 36 32 33 40 38 41 36 43 30 31 32 32 37 37 33 34 33 38 33 31 38 37 33 [126] 31 39 44 33 35 32 28 40 27 37 32 28 34 30 35 31 32 30 30 31 40 32 36 32 35 [151] 38 42 34 35 35 33 36 32 33 34 32 34 > 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]) 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 2 3 5 7 11 21 16 17 14 12 18 16 11 3 3 1 1 1 > colnames(x) [1] "Gender" "Age" "Connected" "Separate" "Learning" [6] "Software" "Happiness" "Depression" > colnames(x)[par1] [1] "Connected" > x[,par1] [1] 41 39 30 31 34 35 39 34 36 37 38 36 38 39 33 32 36 38 39 32 32 31 39 37 39 [26] 41 36 33 33 34 31 27 37 34 34 32 29 36 29 35 37 34 38 35 38 37 38 33 36 38 [51] 32 32 32 34 32 37 39 29 37 35 30 38 34 31 34 35 36 30 39 35 38 31 34 38 34 [76] 39 37 34 28 37 33 37 35 37 32 33 38 33 29 33 31 36 35 32 29 39 37 35 37 32 [101] 38 37 36 32 33 40 38 41 36 43 30 31 32 32 37 37 33 34 33 38 33 31 38 37 33 [126] 31 39 44 33 35 32 28 40 27 37 32 28 34 30 35 31 32 30 30 31 40 32 36 32 35 [151] 38 42 34 35 35 33 36 32 33 34 32 34 > 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/1mds71354832463.tab") + } + } > m Conditional inference tree with 2 terminal nodes Response: Connected Inputs: Gender, Age, Separate, Learning, Software, Happiness, Depression Number of observations: 162 1) Separate <= 35; criterion = 1, statistic = 21.822 2)* weights = 105 1) Separate > 35 3)* weights = 57 > postscript(file="/var/wessaorg/rcomp/tmp/2q0tw1354832463.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/37vnv1354832463.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 41 36.07018 4.92982456 2 39 33.83810 5.16190476 3 30 33.83810 -3.83809524 4 31 33.83810 -2.83809524 5 34 36.07018 -2.07017544 6 35 33.83810 1.16190476 7 39 33.83810 5.16190476 8 34 36.07018 -2.07017544 9 36 33.83810 2.16190476 10 37 36.07018 0.92982456 11 38 33.83810 4.16190476 12 36 33.83810 2.16190476 13 38 33.83810 4.16190476 14 39 36.07018 2.92982456 15 33 36.07018 -3.07017544 16 32 33.83810 -1.83809524 17 36 33.83810 2.16190476 18 38 36.07018 1.92982456 19 39 36.07018 2.92982456 20 32 33.83810 -1.83809524 21 32 33.83810 -1.83809524 22 31 33.83810 -2.83809524 23 39 36.07018 2.92982456 24 37 36.07018 0.92982456 25 39 33.83810 5.16190476 26 41 33.83810 7.16190476 27 36 33.83810 2.16190476 28 33 36.07018 -3.07017544 29 33 33.83810 -0.83809524 30 34 33.83810 0.16190476 31 31 33.83810 -2.83809524 32 27 33.83810 -6.83809524 33 37 33.83810 3.16190476 34 34 36.07018 -2.07017544 35 34 33.83810 0.16190476 36 32 33.83810 -1.83809524 37 29 33.83810 -4.83809524 38 36 33.83810 2.16190476 39 29 33.83810 -4.83809524 40 35 33.83810 1.16190476 41 37 33.83810 3.16190476 42 34 33.83810 0.16190476 43 38 33.83810 4.16190476 44 35 33.83810 1.16190476 45 38 33.83810 4.16190476 46 37 33.83810 3.16190476 47 38 36.07018 1.92982456 48 33 33.83810 -0.83809524 49 36 36.07018 -0.07017544 50 38 33.83810 4.16190476 51 32 36.07018 -4.07017544 52 32 33.83810 -1.83809524 53 32 33.83810 -1.83809524 54 34 36.07018 -2.07017544 55 32 33.83810 -1.83809524 56 37 33.83810 3.16190476 57 39 33.83810 5.16190476 58 29 33.83810 -4.83809524 59 37 36.07018 0.92982456 60 35 33.83810 1.16190476 61 30 33.83810 -3.83809524 62 38 33.83810 4.16190476 63 34 33.83810 0.16190476 64 31 33.83810 -2.83809524 65 34 33.83810 0.16190476 66 35 36.07018 -1.07017544 67 36 33.83810 2.16190476 68 30 33.83810 -3.83809524 69 39 36.07018 2.92982456 70 35 36.07018 -1.07017544 71 38 36.07018 1.92982456 72 31 36.07018 -5.07017544 73 34 36.07018 -2.07017544 74 38 36.07018 1.92982456 75 34 33.83810 0.16190476 76 39 33.83810 5.16190476 77 37 36.07018 0.92982456 78 34 33.83810 0.16190476 79 28 33.83810 -5.83809524 80 37 33.83810 3.16190476 81 33 36.07018 -3.07017544 82 37 36.07018 0.92982456 83 35 36.07018 -1.07017544 84 37 33.83810 3.16190476 85 32 33.83810 -1.83809524 86 33 33.83810 -0.83809524 87 38 36.07018 1.92982456 88 33 33.83810 -0.83809524 89 29 33.83810 -4.83809524 90 33 33.83810 -0.83809524 91 31 36.07018 -5.07017544 92 36 33.83810 2.16190476 93 35 36.07018 -1.07017544 94 32 33.83810 -1.83809524 95 29 33.83810 -4.83809524 96 39 36.07018 2.92982456 97 37 33.83810 3.16190476 98 35 33.83810 1.16190476 99 37 33.83810 3.16190476 100 32 36.07018 -4.07017544 101 38 36.07018 1.92982456 102 37 33.83810 3.16190476 103 36 36.07018 -0.07017544 104 32 33.83810 -1.83809524 105 33 36.07018 -3.07017544 106 40 33.83810 6.16190476 107 38 33.83810 4.16190476 108 41 36.07018 4.92982456 109 36 33.83810 2.16190476 110 43 36.07018 6.92982456 111 30 33.83810 -3.83809524 112 31 33.83810 -2.83809524 113 32 36.07018 -4.07017544 114 32 33.83810 -1.83809524 115 37 33.83810 3.16190476 116 37 33.83810 3.16190476 117 33 36.07018 -3.07017544 118 34 36.07018 -2.07017544 119 33 33.83810 -0.83809524 120 38 36.07018 1.92982456 121 33 36.07018 -3.07017544 122 31 33.83810 -2.83809524 123 38 36.07018 1.92982456 124 37 36.07018 0.92982456 125 33 33.83810 -0.83809524 126 31 33.83810 -2.83809524 127 39 33.83810 5.16190476 128 44 36.07018 7.92982456 129 33 36.07018 -3.07017544 130 35 33.83810 1.16190476 131 32 33.83810 -1.83809524 132 28 33.83810 -5.83809524 133 40 36.07018 3.92982456 134 27 33.83810 -6.83809524 135 37 36.07018 0.92982456 136 32 33.83810 -1.83809524 137 28 33.83810 -5.83809524 138 34 33.83810 0.16190476 139 30 33.83810 -3.83809524 140 35 33.83810 1.16190476 141 31 33.83810 -2.83809524 142 32 33.83810 -1.83809524 143 30 33.83810 -3.83809524 144 30 33.83810 -3.83809524 145 31 33.83810 -2.83809524 146 40 33.83810 6.16190476 147 32 33.83810 -1.83809524 148 36 36.07018 -0.07017544 149 32 33.83810 -1.83809524 150 35 33.83810 1.16190476 151 38 36.07018 1.92982456 152 42 36.07018 5.92982456 153 34 36.07018 -2.07017544 154 35 36.07018 -1.07017544 155 35 33.83810 1.16190476 156 33 33.83810 -0.83809524 157 36 33.83810 2.16190476 158 32 36.07018 -4.07017544 159 33 36.07018 -3.07017544 160 34 33.83810 0.16190476 161 32 33.83810 -1.83809524 162 34 36.07018 -2.07017544 > 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/4prx31354832464.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/5b3mg1354832464.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/6apj31354832464.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/795ct1354832464.tab") + } > > try(system("convert tmp/2q0tw1354832463.ps tmp/2q0tw1354832463.png",intern=TRUE)) character(0) > try(system("convert tmp/37vnv1354832463.ps tmp/37vnv1354832463.png",intern=TRUE)) character(0) > try(system("convert tmp/4prx31354832464.ps tmp/4prx31354832464.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.713 0.662 7.850