R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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. Natural language support but running in an English locale 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 + ,5 + ,2 + ,3 + ,3 + ,4 + ,4 + ,2 + ,4 + ,2 + ,4 + ,3 + ,4 + ,4 + ,4 + ,4 + ,2 + ,4 + ,2 + ,5 + ,4 + ,2 + ,4 + ,2 + ,2 + ,2 + ,2 + ,4 + ,3 + ,2 + ,2 + ,2 + ,3 + ,2 + ,4 + ,4 + ,5 + ,1 + ,3 + ,2 + ,4 + ,5 + ,3 + ,5 + ,1 + ,2 + ,1 + ,4 + ,4 + ,3 + ,4 + ,3 + ,3 + ,3 + ,4 + ,3 + ,3 + ,3 + ,2 + ,3 + ,2 + ,4 + ,4 + ,2 + ,4 + ,1 + ,3 + ,2 + ,2 + ,4 + ,4 + ,4 + ,4 + ,3 + ,3 + ,3 + ,4 + ,4 + ,2 + ,2 + ,4 + ,2 + ,4 + ,4 + ,3 + ,3 + ,3 + ,2 + ,2 + ,3 + ,4 + ,3 + ,3 + ,2 + ,2 + ,2 + ,4 + ,2 + ,4 + ,4 + ,1 + ,1 + ,3 + ,4 + ,3 + ,4 + ,5 + ,1 + ,1 + ,1 + ,4 + ,4 + ,3 + ,4 + ,2 + ,3 + ,3 + ,4 + ,3 + ,3 + ,2 + ,2 + ,2 + ,2 + ,2 + ,2 + ,3 + ,4 + ,2 + ,2 + ,3 + ,4 + ,4 + ,4 + ,4 + ,2 + ,3 + ,4 + ,4 + ,3 + ,2 + ,4 + ,1 + ,4 + ,2 + ,4 + ,3 + ,5 + ,4 + ,2 + ,4 + ,3 + ,3 + ,4 + ,4 + ,4 + ,4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+ ,2 + ,3 + ,4 + ,3 + ,2 + ,2 + ,2 + ,4 + ,4 + ,4 + ,3 + ,2 + ,4 + ,4 + ,4 + ,2 + ,5 + ,3 + ,5 + ,2 + ,5 + ,2 + ,5 + ,3 + ,1 + ,2 + ,4 + ,1 + ,2 + ,1 + ,4 + ,4 + ,4 + ,3 + ,3 + ,3 + ,2 + ,4 + ,5 + ,3 + ,4 + ,2 + ,4 + ,3 + ,4 + ,4 + ,3 + ,3 + ,2 + ,4 + ,2 + ,5 + ,3 + ,3 + ,2 + ,2 + ,4 + ,2 + ,3 + ,4 + ,3 + ,2 + ,1 + ,1 + ,3 + ,2 + ,3 + ,4 + ,4 + ,4 + ,4 + ,2 + ,4 + ,4 + ,4 + ,3 + ,2 + ,4 + ,1 + ,3 + ,4 + ,4 + ,4 + ,2 + ,3 + ,2 + ,4 + ,4 + ,4 + ,4 + ,3 + ,1 + ,1 + ,5 + ,5 + ,4 + ,2 + ,1 + ,2 + ,2 + ,3 + ,2 + ,5 + ,5 + ,4 + ,2 + ,3 + ,3 + ,3 + ,3 + ,4 + ,2 + ,2 + ,2 + ,3 + ,3 + ,3 + ,4 + ,2 + ,3 + ,2 + ,5 + ,4 + ,4 + ,4 + ,4 + ,3 + ,2 + ,4 + ,4 + ,4 + ,3 + ,4 + ,3 + ,4 + ,2 + ,3) + ,dim=c(7 + ,159) + ,dimnames=list(c('standards' + ,'organization' + ,'punished' + ,'secondrate' + ,'mistakes' + ,'competent' + ,'neat') + ,1:159)) > y <- array(NA,dim=c(7,159),dimnames=list(c('standards','organization','punished','secondrate','mistakes','competent','neat'),1:159)) > 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 = '7' > #'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 Attaching package: 'zoo' The following object(s) are masked from package:base : 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) 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] "neat" > x[,par1] [1] 4 4 4 4 4 5 4 3 4 4 4 4 4 2 3 4 3 2 4 3 3 4 3 3 4 4 4 4 4 4 5 4 4 4 3 4 3 [38] 4 4 3 5 4 3 3 3 4 4 4 4 4 4 4 5 3 3 5 5 4 4 3 4 4 5 4 4 5 4 3 4 4 4 4 4 4 [75] 4 3 4 3 5 4 5 5 4 4 4 4 4 5 4 3 4 3 4 4 4 4 4 3 3 3 3 3 2 3 5 2 2 3 3 3 4 [112] 4 3 2 3 4 2 4 4 2 3 3 3 4 4 4 3 4 4 4 2 4 5 4 4 4 3 1 4 3 3 3 1 4 5 4 3 4 [149] 3 4 4 4 5 2 3 3 4 4 3 > 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]) 1 2 3 4 5 2 10 45 86 16 > colnames(x) [1] "standards" "organization" "punished" "secondrate" "mistakes" [6] "competent" "neat" > colnames(x)[par1] [1] "neat" > x[,par1] [1] 4 4 4 4 4 5 4 3 4 4 4 4 4 2 3 4 3 2 4 3 3 4 3 3 4 4 4 4 4 4 5 4 4 4 3 4 3 [38] 4 4 3 5 4 3 3 3 4 4 4 4 4 4 4 5 3 3 5 5 4 4 3 4 4 5 4 4 5 4 3 4 4 4 4 4 4 [75] 4 3 4 3 5 4 5 5 4 4 4 4 4 5 4 3 4 3 4 4 4 4 4 3 3 3 3 3 2 3 5 2 2 3 3 3 4 [112] 4 3 2 3 4 2 4 4 2 3 3 3 4 4 4 3 4 4 4 2 4 5 4 4 4 3 1 4 3 3 3 1 4 5 4 3 4 [149] 3 4 4 4 5 2 3 3 4 4 3 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/html/freestat/rcomp/tmp/17ib11292851292.tab") + } + } > m Conditional inference tree with 3 terminal nodes Response: neat Inputs: standards, organization, punished, secondrate, mistakes, competent Number of observations: 159 1) organization <= 2; criterion = 1, statistic = 20.692 2)* weights = 15 1) organization > 2 3) organization <= 4; criterion = 0.99, statistic = 9.883 4)* weights = 114 3) organization > 4 5)* weights = 30 > postscript(file="/var/www/html/freestat/rcomp/tmp/27ib11292851292.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/html/freestat/rcomp/tmp/37ib11292851292.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 4 4.100000 -0.10000000 2 4 3.631579 0.36842105 3 4 3.631579 0.36842105 4 4 3.631579 0.36842105 5 4 2.933333 1.06666667 6 5 4.100000 0.90000000 7 4 4.100000 -0.10000000 8 3 3.631579 -0.63157895 9 4 3.631579 0.36842105 10 4 3.631579 0.36842105 11 4 3.631579 0.36842105 12 4 2.933333 1.06666667 13 4 3.631579 0.36842105 14 2 3.631579 -1.63157895 15 3 3.631579 -0.63157895 16 4 4.100000 -0.10000000 17 3 3.631579 -0.63157895 18 2 2.933333 -0.93333333 19 4 3.631579 0.36842105 20 3 3.631579 -0.63157895 21 3 3.631579 -0.63157895 22 4 3.631579 0.36842105 23 3 3.631579 -0.63157895 24 3 3.631579 -0.63157895 25 4 4.100000 -0.10000000 26 4 3.631579 0.36842105 27 4 3.631579 0.36842105 28 4 3.631579 0.36842105 29 4 3.631579 0.36842105 30 4 3.631579 0.36842105 31 5 3.631579 1.36842105 32 4 3.631579 0.36842105 33 4 2.933333 1.06666667 34 4 3.631579 0.36842105 35 3 3.631579 -0.63157895 36 4 4.100000 -0.10000000 37 3 4.100000 -1.10000000 38 4 3.631579 0.36842105 39 4 3.631579 0.36842105 40 3 3.631579 -0.63157895 41 5 4.100000 0.90000000 42 4 3.631579 0.36842105 43 3 3.631579 -0.63157895 44 3 4.100000 -1.10000000 45 3 3.631579 -0.63157895 46 4 4.100000 -0.10000000 47 4 3.631579 0.36842105 48 4 3.631579 0.36842105 49 4 3.631579 0.36842105 50 4 3.631579 0.36842105 51 4 3.631579 0.36842105 52 4 3.631579 0.36842105 53 5 3.631579 1.36842105 54 3 2.933333 0.06666667 55 3 3.631579 -0.63157895 56 5 4.100000 0.90000000 57 5 3.631579 1.36842105 58 4 3.631579 0.36842105 59 4 4.100000 -0.10000000 60 3 3.631579 -0.63157895 61 4 4.100000 -0.10000000 62 4 3.631579 0.36842105 63 5 4.100000 0.90000000 64 4 3.631579 0.36842105 65 4 3.631579 0.36842105 66 5 4.100000 0.90000000 67 4 3.631579 0.36842105 68 3 3.631579 -0.63157895 69 4 4.100000 -0.10000000 70 4 3.631579 0.36842105 71 4 3.631579 0.36842105 72 4 3.631579 0.36842105 73 4 4.100000 -0.10000000 74 4 4.100000 -0.10000000 75 4 4.100000 -0.10000000 76 3 3.631579 -0.63157895 77 4 3.631579 0.36842105 78 3 4.100000 -1.10000000 79 5 4.100000 0.90000000 80 4 3.631579 0.36842105 81 5 4.100000 0.90000000 82 5 3.631579 1.36842105 83 4 3.631579 0.36842105 84 4 3.631579 0.36842105 85 4 3.631579 0.36842105 86 4 3.631579 0.36842105 87 4 3.631579 0.36842105 88 5 4.100000 0.90000000 89 4 3.631579 0.36842105 90 3 3.631579 -0.63157895 91 4 3.631579 0.36842105 92 3 4.100000 -1.10000000 93 4 3.631579 0.36842105 94 4 3.631579 0.36842105 95 4 4.100000 -0.10000000 96 4 4.100000 -0.10000000 97 4 3.631579 0.36842105 98 3 3.631579 -0.63157895 99 3 3.631579 -0.63157895 100 3 3.631579 -0.63157895 101 3 3.631579 -0.63157895 102 3 3.631579 -0.63157895 103 2 3.631579 -1.63157895 104 3 3.631579 -0.63157895 105 5 4.100000 0.90000000 106 2 2.933333 -0.93333333 107 2 3.631579 -1.63157895 108 3 2.933333 0.06666667 109 3 3.631579 -0.63157895 110 3 4.100000 -1.10000000 111 4 3.631579 0.36842105 112 4 3.631579 0.36842105 113 3 3.631579 -0.63157895 114 2 3.631579 -1.63157895 115 3 3.631579 -0.63157895 116 4 3.631579 0.36842105 117 2 2.933333 -0.93333333 118 4 2.933333 1.06666667 119 4 3.631579 0.36842105 120 2 3.631579 -1.63157895 121 3 3.631579 -0.63157895 122 3 3.631579 -0.63157895 123 3 3.631579 -0.63157895 124 4 4.100000 -0.10000000 125 4 3.631579 0.36842105 126 4 3.631579 0.36842105 127 3 3.631579 -0.63157895 128 4 3.631579 0.36842105 129 4 3.631579 0.36842105 130 4 3.631579 0.36842105 131 2 3.631579 -1.63157895 132 4 3.631579 0.36842105 133 5 3.631579 1.36842105 134 4 3.631579 0.36842105 135 4 3.631579 0.36842105 136 4 3.631579 0.36842105 137 3 3.631579 -0.63157895 138 1 3.631579 -2.63157895 139 4 3.631579 0.36842105 140 3 2.933333 0.06666667 141 3 2.933333 0.06666667 142 3 3.631579 -0.63157895 143 1 2.933333 -1.93333333 144 4 3.631579 0.36842105 145 5 3.631579 1.36842105 146 4 3.631579 0.36842105 147 3 3.631579 -0.63157895 148 4 2.933333 1.06666667 149 3 2.933333 0.06666667 150 4 3.631579 0.36842105 151 4 3.631579 0.36842105 152 4 3.631579 0.36842105 153 5 3.631579 1.36842105 154 2 2.933333 -0.93333333 155 3 4.100000 -1.10000000 156 3 3.631579 -0.63157895 157 4 3.631579 0.36842105 158 4 3.631579 0.36842105 159 3 3.631579 -0.63157895 > 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/html/freestat/rcomp/tmp/4hsb41292851292.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/html/freestat/rcomp/tmp/5d18v1292851292.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/html/freestat/rcomp/tmp/66bqg1292851292.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/html/freestat/rcomp/tmp/7stol1292851292.tab") + } > > try(system("convert tmp/27ib11292851292.ps tmp/27ib11292851292.png",intern=TRUE)) character(0) > try(system("convert tmp/37ib11292851292.ps tmp/37ib11292851292.png",intern=TRUE)) character(0) > try(system("convert tmp/4hsb41292851292.ps tmp/4hsb41292851292.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.496 0.756 4.697