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(0 + ,3289.5 + ,0.66 + ,0.814 + ,0.526 + ,1 + ,6 + ,25299.2 + ,0.384 + ,0.743 + ,0.587 + ,2 + ,0 + ,52.8 + ,NA + ,0.891 + ,0.799 + ,NA + ,0 + ,10335.1 + ,NA + ,0.334 + ,0.464 + ,2 + ,0 + ,62.2 + ,NA + ,0.771 + ,0.676 + ,1 + ,1 + ,32642.4 + ,0.681 + ,0.813 + ,0.612 + ,0 + ,64 + ,17096.2 + ,0.952 + ,0.895 + ,0.779 + ,0 + ,4 + ,7670.5 + ,0.709 + ,0.875 + ,0.793 + ,0 + ,1 + ,256.1 + ,NA + ,0.778 + ,0.778 + ,0 + ,0 + ,492.9 + ,0.602 + ,0.825 + ,0.754 + ,1 + ,0 + ,105256 + ,0.253 + ,0.623 + ,0.277 + ,0 + ,0 + ,259.5 + ,NA + ,0.862 + ,0.72 + ,0 + ,4 + ,9949 + ,0.764 + ,0.884 + ,0.791 + ,0 + ,0 + ,190.2 + ,0.615 + ,0.828 + ,0.54 + ,0 + ,0 + ,4773.1 + ,0.203 + ,0.453 + ,0.342 + ,0 + ,0 + ,558.5 + ,NA + ,0.513 + ,0.415 + ,2 + ,0 + ,6658.5 + ,0.604 + ,0.612 + ,0.476 + ,0 + ,0 + ,4308.2 + ,NA + ,0.737 + ,NA + ,2 + ,0 + ,1382.4 + ,0.497 + ,0.696 + ,0.607 + ,0 + ,12 + ,149650.2 + ,NA + ,0.73 + ,0.608 + ,0 + ,35 + ,NA + ,NA + ,NA + ,0.607 + ,NA + ,0 + ,9324 + ,NA + ,0.45 + ,0.283 + ,1 + ,0 + ,12180.8 + ,0.346 + ,0.525 + ,0.428 + ,2 + ,47 + ,27700.9 + ,0.875 + ,0.904 + ,0.796 + ,0 + ,0 + ,2934.8 + ,0.219 + ,0.455 + ,0.3 + ,1 + ,0 + ,6011.2 + ,NA + ,0.484 + ,0.3 + ,2 + ,0 + ,13187.8 + ,0.677 + ,0.847 + ,0.592 + ,0 + ,1 + ,33203.3 + ,0.39 + ,0.762 + ,0.582 + ,1 + ,0 + ,36406.2 + ,0.235 + ,0.424 + ,NA + ,2 + ,0 + ,3070.2 + ,0.548 + ,0.879 + ,0.587 + ,0 + ,4 + ,4517.2 + ,0.624 + ,0.819 + ,NA + ,1 + ,93 + ,10570.3 + ,0.69 + ,0.859 + ,0.523 + ,2 + ,0 + ,766.7 + ,0.626 + ,0.892 + ,0.747 + ,0 + ,25 + ,10302.7 + ,0.762 + ,0.819 + ,NA + ,NA + ,25 + ,20143.2 + ,NA + ,0.801 + ,NA + ,2 + ,11 + ,5141 + ,0.774 + ,0.866 + ,0.79 + ,0 + ,0 + ,562.3 + ,NA + ,0.495 + ,NA + ,2 + ,0 + ,7194.7 + ,0.499 + ,0.751 + ,0.513 + ,0 + ,0 + ,10260.6 + ,0.486 + ,0.771 + ,0.557 + ,0 + ,0 + ,56843.3 + ,0.376 + ,0.663 + ,0.493 + ,1 + ,0 + ,5332.8 + ,0.386 + ,0.726 + ,0.513 + ,1 + ,0 + ,373.9 + ,NA + ,0.422 + ,0.419 + ,2 + ,6 + ,1567.6 + ,0.716 + ,0.78 + ,0.661 + ,1 + ,7 + ,48333.3 + ,NA + ,0.427 + ,0.245 + ,1 + ,0 + ,728.4 + ,0.674 + ,0.718 + ,0.503 + ,1 + ,11 + ,4986.4 + ,0.74 + ,0.871 + ,0.776 + ,0 + ,66 + ,56708.3 + ,0.666 + ,0.895 + ,0.787 + ,0 + ,0 + ,929 + ,0.484 + ,0.652 + ,0.702 + ,1 + ,235 + ,79098.1 + ,0.721 + ,0.874 + ,0.796 + ,0 + ,1 + ,14793.4 + ,0.406 + ,0.581 + ,0.31 + ,1 + ,43 + ,57214.5 + ,0.688 + ,0.877 + ,0.781 + ,0 + ,10 + ,10160.5 + ,0.671 + ,0.9 + ,0.742 + ,0 + ,0 + ,96.2 + ,NA + ,0.774 + ,0.554 + ,0 + ,0 + ,8923.1 + ,0.296 + ,0.666 + ,0.499 + ,1 + ,0 + ,5759.4 + ,NA + ,0.373 + ,0.292 + ,1 + ,0 + ,724.9 + ,0.541 + ,0.646 + ,0.335 + ,1 + ,0 + ,7124.9 + ,0.294 + ,0.554 + ,0.384 + ,2 + ,0 + ,4889.3 + ,0.405 + ,0.731 + ,0.457 + ,0 + ,0 + ,5793.9 + ,0.687 + ,0.907 + ,0.779 + ,NA + ,86 + ,10376.3 + ,0.661 + ,0.778 + ,0.683 + ,0 + ,0 + ,254.8 + ,0.727 + ,0.917 + ,0.79 + ,0 + ,0 + ,873785.4 + ,0.318 + ,0.605 + ,0.359 + ,1 + ,15 + ,184345.9 + ,0.39 + ,0.664 + ,0.43 + ,1 + ,0 + ,17373.8 + ,0.345 + ,0.749 + ,NA + ,2 + ,7 + ,3531.2 + ,0.76 + ,0.863 + ,0.729 + ,0 + ,4 + ,54870.6 + ,NA + ,0.659 + ,0.592 + ,2 + ,3 + ,4499.9 + ,0.784 + ,0.891 + ,0.739 + ,0 + ,48 + ,56832.3 + ,0.636 + ,0.897 + ,0.781 + ,0 + ,0 + ,NA + ,NA + ,NA + ,0.397 + ,NA + ,7 + ,2364.9 + ,0.592 + ,0.8 + ,0.571 + ,0 + ,42 + ,122251.2 + ,0.761 + ,0.931 + ,0.798 + ,0 + ,0 + ,3415.6 + ,0.526 + ,0.795 + ,0.493 + ,1 + ,20 + ,23447.2 + ,0.408 + ,0.621 + ,0.375 + ,1 + ,82 + ,42980.4 + ,0.738 + ,0.816 + ,0.678 + ,0 + ,0 + ,2087.7 + ,0.514 + ,0.828 + ,0.848 + ,1 + ,0 + ,NA + ,NA + ,NA + ,0.323 + ,NA + ,5 + ,2663.9 + ,0.652 + ,0.772 + ,0.661 + ,1 + ,0 + ,2948.4 + ,NA + ,0.768 + ,0.607 + ,1 + ,0 + ,1639.2 + ,0.431 + ,0.623 + ,0.388 + ,1 + ,0 + ,29 + ,NA + ,0.885 + ,0.886 + ,0 + ,6 + ,3695.9 + ,0.688 + ,0.801 + ,NA + ,0 + ,0 + ,381.2 + ,0.656 + ,0.868 + ,0.86 + ,0 + ,0 + ,11280.6 + ,NA + ,0.485 + ,0.329 + ,1 + ,0 + ,9380.9 + ,0.239 + ,0.428 + ,0.242 + ,2 + ,1 + ,18208.6 + ,0.534 + ,0.789 + ,0.595 + ,1 + ,0 + ,219.5 + ,0.447 + ,0.645 + ,NA + ,2 + ,0 + ,8672.9 + ,0.082 + ,0.382 + ,0.27 + ,0 + ,0 + ,367.5 + ,0.686 + ,0.872 + ,0.713 + ,0 + ,0 + ,1995.5 + ,0.194 + ,0.568 + ,0.4 + ,2 + ,0 + ,1059.5 + ,NA + ,0.78 + ,0.588 + ,0 + ,2 + ,84306.6 + ,0.518 + ,0.802 + ,0.657 + ,1 + ,0 + ,30.9 + ,NA + ,0.902 + ,NA + ,NA + ,2 + ,2192.6 + ,0.58 + ,0.639 + ,0.426 + ,0 + ,8 + ,24781.1 + ,0.254 + ,0.696 + ,0.466 + ,1 + ,0 + ,13547.1 + ,0.116 + ,0.367 + ,0.189 + ,1 + ,0 + ,39268.3 + ,0.258 + ,0.588 + ,0.175 + ,NA + ,4 + ,1414.8 + ,0.524 + ,0.644 + ,0.53 + ,0 + ,0 + ,19081.1 + ,0.257 + ,0.536 + ,0.287 + ,0 + ,29 + ,14891.7 + ,0.814 + ,0.899 + ,0.797 + ,0 + ,18 + ,3398 + ,0.873 + ,0.871 + ,0.745 + ,0 + ,0 + ,NA + ,NA + ,NA + ,0.416 + ,NA + ,0 + ,7788.2 + ,0.079 + ,0.338 + ,0.27 + ,1 + ,7 + ,97552.1 + ,NA + ,0.404 + ,0.364 + ,1 + ,19 + ,4241.5 + ,0.82 + ,0.891 + ,0.823 + ,0 + ,0 + ,1868.1 + ,0.71 + ,0.798 + ,0.718 + ,1 + ,1 + ,111844.7 + ,0.241 + ,0.642 + ,0.411 + ,1 + ,0 + ,2415.9 + ,0.599 + ,0.825 + ,0.581 + ,1 + ,0 + ,4157.7 + ,0.222 + ,0.561 + ,0.4 + ,0 + ,0 + ,4243.9 + ,0.466 + ,0.757 + ,0.532 + ,1 + ,140 + ,1145195.2 + ,0.437 + ,0.78 + ,0.345 + ,2 + ,2 + ,21685.5 + ,NA + ,0.719 + ,0.54 + ,1 + ,1 + ,61628.7 + ,0.578 + ,0.712 + ,0.452 + ,1 + ,37 + ,38056.2 + ,0.676 + ,0.803 + ,NA + ,0 + ,0 + ,9925.5 + ,0.568 + ,0.856 + ,0.729 + ,0 + ,1 + ,NA + ,NA + ,NA + ,0.868 + ,NA + ,40 + ,23206.7 + ,0.705 + ,0.779 + ,0.624 + ,1 + ,0 + ,7109.5 + ,0.217 + ,0.202 + ,0.286 + ,2 + ,0 + ,161.3 + ,NA + ,0.708 + ,NA + ,0 + ,0 + ,161.3 + ,NA + ,0.708 + ,NA + ,0 + ,0 + ,24.1 + ,NA + ,0.925 + ,NA + ,0 + ,0 + ,16139.1 + ,0.57 + ,0.767 + ,0.762 + ,2 + ,0 + ,7241.6 + ,0.247 + ,0.524 + ,0.375 + ,1 + ,0 + ,71 + ,NA + ,0.794 + ,0.698 + ,1 + ,0 + ,3981.6 + ,0.182 + ,0.296 + ,0.258 + ,2 + ,0 + ,3016.6 + ,NA + ,0.877 + ,0.788 + ,1 + ,2 + ,1926.7 + ,0.67 + ,0.837 + ,NA + ,0 + ,0 + ,309.5 + ,NA + ,0.578 + ,NA + ,0 + ,4 + ,36793.9 + ,0.572 + ,0.655 + ,0.622 + ,1 + ,81 + ,38889.2 + ,0.619 + ,0.9 + ,0.756 + ,0 + ,0 + ,17337 + ,0.59 + ,0.781 + ,0.43 + ,1 + ,0 + ,107.4 + ,0.665 + ,0.777 + ,0.536 + ,0 + ,0 + ,26494.2 + ,0.163 + ,0.513 + ,0.315 + ,2 + ,1 + ,406.9 + ,NA + ,0.748 + ,0.567 + ,1 + ,0 + ,862.9 + ,0.451 + ,0.622 + ,0.517 + ,1 + ,23 + ,8558.8 + ,0.759 + ,0.909 + ,0.786 + ,0 + ,5 + ,6673.7 + ,0.762 + ,0.909 + ,0.836 + ,0 + ,0 + ,12324.1 + ,0.425 + ,0.806 + ,0.48 + ,2 + ,1 + ,57072.1 + ,0.417 + ,0.828 + ,0.526 + ,1 + ,0 + ,966.2 + ,0.179 + ,0.522 + ,0.34 + ,0 + ,0 + ,3665.5 + ,0.312 + ,0.521 + ,0.306 + ,2 + ,0 + ,95.2 + ,NA + ,0.782 + ,0.491 + ,1 + ,0 + ,1215.5 + ,0.609 + ,0.771 + ,0.659 + ,0 + ,0 + ,8215.1 + ,0.396 + ,0.767 + ,0.524 + ,1 + ,16 + ,54130.3 + ,0.41 + ,0.679 + ,0.622 + ,1 + ,0 + ,17699.7 + ,0.262 + ,0.431 + ,0.235 + ,2 + ,0 + ,1808.6 + ,0.462 + ,0.817 + ,0.871 + ,1 + ,290 + ,253339.1 + ,0.917 + ,0.871 + ,0.825 + ,0 + ,0 + ,3109.1 + ,0.64 + ,0.828 + ,0.609 + ,0 + ,0 + ,146.6 + ,NA + ,0.679 + ,0.512 + ,0 + ,0 + ,19685.2 + ,0.476 + ,0.805 + ,0.651 + ,1 + ,0 + ,67101.6 + ,0.371 + ,0.719 + ,0.307 + ,NA + ,0 + ,11948.2 + ,0.096 + ,0.571 + ,NA + ,NA + ,0 + ,7860.1 + ,0.406 + ,0.434 + ,0.346 + ,0 + ,0 + ,10469.2 + ,0.451 + ,0.64 + ,0.266 + ,1) + ,dim=c(6 + ,154) + ,dimnames=list(c('Totalpoints' + ,'POP' + ,'Education' + ,'Health' + ,'GNI/Cap' + ,'Democracy') + ,1:154)) > y <- array(NA,dim=c(6,154),dimnames=list(c('Totalpoints','POP','Education','Health','GNI/Cap','Democracy'),1:154)) > 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 = '1' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '1' > #'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] "Totalpoints" > x[,par1] [1] 0 6 0 0 0 1 64 4 1 0 0 0 4 0 0 0 0 0 [19] 0 12 35 0 0 47 0 0 0 1 0 0 4 93 0 25 25 11 [37] 0 0 0 0 0 0 6 7 0 11 66 0 235 1 43 10 0 0 [55] 0 0 0 0 0 86 0 0 15 0 7 4 3 48 0 7 42 0 [73] 20 82 0 0 5 0 0 0 6 0 0 0 1 0 0 0 0 0 [91] 2 0 2 8 0 0 4 0 29 18 0 0 7 19 0 1 0 0 [109] 0 140 2 1 37 0 1 40 0 0 0 0 0 0 0 0 0 2 [127] 0 4 81 0 0 0 1 0 23 5 0 1 0 0 0 0 0 16 [145] 0 0 290 0 0 0 0 0 0 0 > 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 3 4 5 6 7 8 10 11 12 15 16 18 19 20 23 25 29 94 10 4 1 6 2 3 4 1 1 2 1 1 1 1 1 1 1 2 1 35 37 40 42 43 47 48 64 66 81 82 86 93 140 235 290 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "Totalpoints" "POP" "Education" "Health" "GNI.Cap" [6] "Democracy" > colnames(x)[par1] [1] "Totalpoints" > x[,par1] [1] 0 6 0 0 0 1 64 4 1 0 0 0 4 0 0 0 0 0 [19] 0 12 35 0 0 47 0 0 0 1 0 0 4 93 0 25 25 11 [37] 0 0 0 0 0 0 6 7 0 11 66 0 235 1 43 10 0 0 [55] 0 0 0 0 0 86 0 0 15 0 7 4 3 48 0 7 42 0 [73] 20 82 0 0 5 0 0 0 6 0 0 0 1 0 0 0 0 0 [91] 2 0 2 8 0 0 4 0 29 18 0 0 7 19 0 1 0 0 [109] 0 140 2 1 37 0 1 40 0 0 0 0 0 0 0 0 0 2 [127] 0 4 81 0 0 0 1 0 23 5 0 1 0 0 0 0 0 16 [145] 0 0 290 0 0 0 0 0 0 0 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/1fvus1356614127.tab") + } + } > m Conditional inference tree with 6 terminal nodes Response: Totalpoints Inputs: POP, Education, Health, GNI.Cap, Democracy Number of observations: 154 1) POP <= 67101.6; criterion = 1, statistic = 19.379 2) POP <= 10260.6; criterion = 1, statistic = 19.376 3) Education <= 0.727; criterion = 1, statistic = 18.2 4) Education <= 0.665; criterion = 0.974, statistic = 7.759 5)* weights = 77 4) Education > 0.665 6)* weights = 10 3) Education > 0.727 7)* weights = 9 2) POP > 10260.6 8) Education <= 0.59; criterion = 1, statistic = 16.562 9)* weights = 32 8) Education > 0.59 10)* weights = 15 1) POP > 67101.6 11)* weights = 11 > postscript(file="/var/fisher/rcomp/tmp/223q41356614127.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/fisher/rcomp/tmp/3g1d81356614127.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 0 0.7792208 -0.7792208 2 6 3.0312500 2.9687500 3 0 0.7792208 -0.7792208 4 0 3.0312500 -3.0312500 5 0 0.7792208 -0.7792208 6 1 49.4666667 -48.4666667 7 64 49.4666667 14.5333333 8 4 2.8000000 1.2000000 9 1 0.7792208 0.2207792 10 0 0.7792208 -0.7792208 11 0 67.6363636 -67.6363636 12 0 0.7792208 -0.7792208 13 4 11.2222222 -7.2222222 14 0 0.7792208 -0.7792208 15 0 0.7792208 -0.7792208 16 0 0.7792208 -0.7792208 17 0 0.7792208 -0.7792208 18 0 0.7792208 -0.7792208 19 0 0.7792208 -0.7792208 20 12 67.6363636 -55.6363636 21 35 0.7792208 34.2207792 22 0 0.7792208 -0.7792208 23 0 3.0312500 -3.0312500 24 47 49.4666667 -2.4666667 25 0 0.7792208 -0.7792208 26 0 0.7792208 -0.7792208 27 0 49.4666667 -49.4666667 28 1 3.0312500 -2.0312500 29 0 3.0312500 -3.0312500 30 0 0.7792208 -0.7792208 31 4 0.7792208 3.2207792 32 93 49.4666667 43.5333333 33 0 0.7792208 -0.7792208 34 25 49.4666667 -24.4666667 35 25 3.0312500 21.9687500 36 11 11.2222222 -0.2222222 37 0 0.7792208 -0.7792208 38 0 0.7792208 -0.7792208 39 0 0.7792208 -0.7792208 40 0 3.0312500 -3.0312500 41 0 0.7792208 -0.7792208 42 0 0.7792208 -0.7792208 43 6 2.8000000 3.2000000 44 7 3.0312500 3.9687500 45 0 2.8000000 -2.8000000 46 11 11.2222222 -0.2222222 47 66 49.4666667 16.5333333 48 0 0.7792208 -0.7792208 49 235 67.6363636 167.3636364 50 1 3.0312500 -2.0312500 51 43 49.4666667 -6.4666667 52 10 2.8000000 7.2000000 53 0 0.7792208 -0.7792208 54 0 0.7792208 -0.7792208 55 0 0.7792208 -0.7792208 56 0 0.7792208 -0.7792208 57 0 0.7792208 -0.7792208 58 0 0.7792208 -0.7792208 59 0 2.8000000 -2.8000000 60 86 49.4666667 36.5333333 61 0 2.8000000 -2.8000000 62 0 67.6363636 -67.6363636 63 15 67.6363636 -52.6363636 64 0 3.0312500 -3.0312500 65 7 11.2222222 -4.2222222 66 4 3.0312500 0.9687500 67 3 11.2222222 -8.2222222 68 48 49.4666667 -1.4666667 69 0 0.7792208 -0.7792208 70 7 0.7792208 6.2207792 71 42 67.6363636 -25.6363636 72 0 0.7792208 -0.7792208 73 20 3.0312500 16.9687500 74 82 49.4666667 32.5333333 75 0 0.7792208 -0.7792208 76 0 0.7792208 -0.7792208 77 5 0.7792208 4.2207792 78 0 0.7792208 -0.7792208 79 0 0.7792208 -0.7792208 80 0 0.7792208 -0.7792208 81 6 2.8000000 3.2000000 82 0 0.7792208 -0.7792208 83 0 3.0312500 -3.0312500 84 0 0.7792208 -0.7792208 85 1 3.0312500 -2.0312500 86 0 0.7792208 -0.7792208 87 0 0.7792208 -0.7792208 88 0 2.8000000 -2.8000000 89 0 0.7792208 -0.7792208 90 0 0.7792208 -0.7792208 91 2 67.6363636 -65.6363636 92 0 0.7792208 -0.7792208 93 2 0.7792208 1.2207792 94 8 3.0312500 4.9687500 95 0 3.0312500 -3.0312500 96 0 3.0312500 -3.0312500 97 4 0.7792208 3.2207792 98 0 3.0312500 -3.0312500 99 29 49.4666667 -20.4666667 100 18 11.2222222 6.7777778 101 0 0.7792208 -0.7792208 102 0 0.7792208 -0.7792208 103 7 67.6363636 -60.6363636 104 19 11.2222222 7.7777778 105 0 2.8000000 -2.8000000 106 1 67.6363636 -66.6363636 107 0 0.7792208 -0.7792208 108 0 0.7792208 -0.7792208 109 0 0.7792208 -0.7792208 110 140 67.6363636 72.3636364 111 2 3.0312500 -1.0312500 112 1 3.0312500 -2.0312500 113 37 49.4666667 -12.4666667 114 0 0.7792208 -0.7792208 115 1 0.7792208 0.2207792 116 40 49.4666667 -9.4666667 117 0 0.7792208 -0.7792208 118 0 0.7792208 -0.7792208 119 0 0.7792208 -0.7792208 120 0 0.7792208 -0.7792208 121 0 3.0312500 -3.0312500 122 0 0.7792208 -0.7792208 123 0 0.7792208 -0.7792208 124 0 0.7792208 -0.7792208 125 0 0.7792208 -0.7792208 126 2 2.8000000 -0.8000000 127 0 0.7792208 -0.7792208 128 4 3.0312500 0.9687500 129 81 49.4666667 31.5333333 130 0 3.0312500 -3.0312500 131 0 0.7792208 -0.7792208 132 0 3.0312500 -3.0312500 133 1 0.7792208 0.2207792 134 0 0.7792208 -0.7792208 135 23 11.2222222 11.7777778 136 5 11.2222222 -6.2222222 137 0 3.0312500 -3.0312500 138 1 3.0312500 -2.0312500 139 0 0.7792208 -0.7792208 140 0 0.7792208 -0.7792208 141 0 0.7792208 -0.7792208 142 0 0.7792208 -0.7792208 143 0 0.7792208 -0.7792208 144 16 3.0312500 12.9687500 145 0 3.0312500 -3.0312500 146 0 0.7792208 -0.7792208 147 290 67.6363636 222.3636364 148 0 0.7792208 -0.7792208 149 0 0.7792208 -0.7792208 150 0 3.0312500 -3.0312500 151 0 3.0312500 -3.0312500 152 0 3.0312500 -3.0312500 153 0 0.7792208 -0.7792208 154 0 3.0312500 -3.0312500 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/fisher/rcomp/tmp/4i0b21356614127.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/fisher/rcomp/tmp/5zr3u1356614127.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/fisher/rcomp/tmp/6m3d81356614127.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/fisher/rcomp/tmp/7tzt71356614127.tab") + } > > try(system("convert tmp/223q41356614127.ps tmp/223q41356614127.png",intern=TRUE)) character(0) > try(system("convert tmp/3g1d81356614127.ps tmp/3g1d81356614127.png",intern=TRUE)) character(0) > try(system("convert tmp/4i0b21356614127.ps tmp/4i0b21356614127.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.210 0.609 5.844