R version 2.12.0 (2010-10-15) 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(40 + ,1 + ,27 + ,5 + ,26 + ,49 + ,35 + ,45 + ,1 + ,36 + ,4 + ,25 + ,45 + ,34 + ,38 + ,1 + ,25 + ,4 + ,17 + ,54 + ,13 + ,28 + ,1 + ,27 + ,3 + ,37 + ,36 + ,35 + ,NA + ,2 + ,25 + ,3 + ,35 + ,36 + ,28 + ,38 + ,2 + ,44 + ,3 + ,15 + ,53 + ,32 + ,39 + ,1 + ,50 + ,4 + ,27 + ,46 + ,35 + ,37 + ,1 + ,41 + ,4 + ,36 + ,42 + ,36 + ,30 + ,1 + ,48 + ,5 + ,25 + ,41 + ,27 + ,30 + ,2 + ,43 + ,4 + ,30 + ,45 + ,29 + ,30 + ,2 + ,47 + ,2 + ,27 + ,47 + ,27 + ,26 + ,2 + ,41 + ,3 + ,33 + ,42 + ,28 + ,29 + ,1 + ,44 + ,2 + ,29 + ,45 + ,29 + ,31 + ,2 + ,47 + ,5 + ,30 + ,40 + ,28 + ,27 + ,2 + ,40 + ,3 + ,25 + ,45 + ,30 + ,25 + ,2 + ,46 + ,3 + ,23 + ,40 + ,25 + ,39 + ,1 + ,28 + ,3 + ,26 + ,42 + ,15 + ,35 + ,1 + ,56 + ,3 + ,24 + ,45 + ,33 + ,27 + ,2 + ,49 + ,4 + ,35 + ,47 + ,31 + ,40 + ,2 + ,25 + ,4 + ,39 + ,31 + ,37 + ,34 + ,2 + ,41 + ,4 + ,23 + ,46 + ,37 + ,32 + ,2 + ,26 + ,3 + ,32 + ,34 + ,34 + ,34 + ,1 + ,50 + ,5 + ,29 + ,43 + ,32 + ,38 + ,1 + ,47 + ,4 + ,26 + ,45 + ,21 + ,21 + ,1 + ,52 + ,2 + ,21 + ,42 + ,25 + ,33 + ,2 + ,37 + ,5 + ,35 + ,51 + ,32 + ,27 + ,2 + ,41 + ,3 + ,23 + ,44 + ,28 + ,35 + ,1 + ,45 + ,4 + ,21 + ,47 + ,22 + ,33 + ,2 + ,26 + ,4 + ,28 + ,47 + ,25 + ,36 + ,1 + ,NA + ,3 + ,30 + ,41 + ,26 + ,NA + ,1 + ,52 + ,4 + ,21 + ,44 + ,34 + ,37 + ,1 + ,46 + ,2 + ,29 + ,51 + ,34 + ,37 + ,1 + ,58 + ,3 + ,28 + ,46 + ,36 + ,37 + ,1 + ,54 + ,5 + ,19 + ,47 + ,36 + ,32 + ,1 + ,29 + ,3 + ,26 + ,46 + ,26 + ,25 + ,2 + ,50 + ,3 + ,33 + ,38 + ,26 + ,31 + ,1 + ,43 + ,2 + ,34 + ,50 + ,34 + ,33 + ,2 + ,30 + ,3 + ,33 + ,48 + ,33 + ,18 + ,2 + ,47 + ,2 + ,40 + ,36 + ,31 + ,42 + ,1 + ,45 + ,3 + ,24 + ,51 + ,33 + ,26 + ,2 + ,48 + ,1 + ,35 + ,35 + ,22 + ,26 + ,2 + ,48 + ,3 + ,35 + ,49 + ,29 + ,32 + ,2 + ,26 + ,4 + ,32 + ,38 + ,24 + ,31 + ,1 + ,46 + ,5 + ,20 + ,47 + ,37 + ,29 + ,2 + ,NA + ,3 + ,35 + ,36 + ,32 + ,35 + ,2 + ,50 + ,3 + ,35 + ,47 + ,23 + ,44 + ,1 + ,25 + ,4 + ,21 + ,46 + ,29 + ,35 + ,1 + ,47 + ,2 + ,33 + ,43 + ,35 + ,30 + ,2 + ,47 + ,2 + ,40 + ,53 + ,20 + ,32 + ,1 + ,41 + ,3 + ,22 + ,55 + ,28 + ,24 + ,2 + ,45 + ,2 + ,35 + ,39 + ,26 + ,34 + ,2 + ,41 + ,4 + ,20 + ,55 + ,36 + ,27 + ,2 + ,45 + ,5 + ,28 + ,41 + ,26 + ,31 + ,2 + ,40 + ,3 + ,46 + ,33 + ,33 + ,38 + ,1 + ,29 + ,4 + ,18 + ,52 + ,25 + ,41 + ,2 + ,34 + ,5 + ,22 + ,42 + ,29 + ,40 + ,1 + ,45 + ,5 + ,20 + ,56 + ,32 + ,25 + ,2 + ,52 + ,3 + ,25 + ,46 + ,35 + ,19 + ,2 + ,41 + ,4 + ,31 + ,33 + ,24 + ,33 + ,2 + ,48 + ,3 + ,21 + ,51 + ,31 + ,27 + ,2 + ,45 + ,3 + ,23 + ,46 + ,29 + ,45 + ,1 + ,54 + ,2 + ,26 + ,46 + ,27 + ,27 + ,2 + ,25 + ,3 + ,34 + ,50 + ,29 + ,30 + ,2 + ,26 + ,4 + ,31 + ,46 + ,29 + ,42 + ,1 + ,28 + ,4 + ,23 + ,51 + ,27 + ,21 + ,2 + ,50 + ,4 + ,31 + ,48 + ,34 + ,32 + ,2 + ,48 + ,4 + ,26 + ,44 + ,32 + ,31 + ,2 + ,51 + ,3 + ,36 + ,38 + ,31 + ,36 + ,2 + ,53 + ,3 + ,28 + ,42 + ,31 + ,34 + ,1 + ,37 + ,3 + ,34 + ,39 + ,31 + ,11 + ,1 + ,56 + ,2 + ,25 + ,45 + ,16 + ,35 + ,1 + ,43 + ,3 + ,33 + ,31 + ,25 + ,39 + ,1 + ,34 + ,3 + ,46 + ,29 + ,27 + ,32 + ,1 + ,42 + ,3 + ,24 + ,48 + ,32 + ,28 + ,2 + ,32 + ,3 + ,32 + ,38 + ,28 + ,45 + ,2 + ,31 + ,5 + ,33 + ,55 + ,25 + ,18 + ,1 + ,46 + ,3 + ,42 + ,32 + ,25 + ,35 + ,2 + ,30 + ,5 + ,17 + ,51 + ,36 + ,35 + ,2 + ,47 + ,4 + ,36 + ,53 + ,36 + ,36 + ,2 + ,33 + ,4 + ,40 + ,47 + ,36 + ,34 + ,1 + ,25 + ,4 + ,30 + ,45 + ,27 + ,34 + ,1 + ,25 + ,5 + ,19 + ,33 + ,29 + ,38 + ,2 + ,21 + ,4 + ,33 + ,49 + ,32 + ,28 + ,2 + ,36 + ,5 + ,35 + ,46 + ,29 + ,23 + ,2 + ,50 + ,3 + ,23 + ,42 + ,31 + ,37 + ,2 + ,48 + ,3 + ,15 + ,56 + ,34 + ,29 + ,2 + ,48 + ,2 + ,38 + ,35 + ,27 + ,28 + ,1 + ,25 + ,3 + ,37 + ,40 + ,28 + ,30 + ,1 + ,48 + ,4 + ,23 + ,44 + ,32 + ,24 + ,2 + ,49 + ,5 + ,41 + ,46 + ,33 + ,36 + ,1 + ,27 + ,5 + ,34 + ,46 + ,29 + ,40 + ,1 + ,28 + ,3 + ,38 + ,39 + ,32 + ,37 + ,2 + ,43 + ,2 + ,45 + ,35 + ,35 + ,27 + ,2 + ,48 + ,3 + ,27 + ,48 + ,33 + ,25 + ,2 + ,48 + ,4 + ,46 + ,42 + ,27 + ,22 + ,1 + ,25 + ,1 + ,26 + ,39 + ,16 + ,21 + ,2 + ,49 + ,4 + ,44 + ,39 + ,32 + ,28 + ,1 + ,26 + ,3 + ,36 + ,41 + ,26 + ,34 + ,1 + ,51 + ,3 + ,20 + ,52 + ,32 + ,32 + ,2 + ,25 + ,4 + ,44 + ,45 + ,38 + ,23 + ,1 + ,29 + ,3 + ,27 + ,42 + ,24 + ,29 + ,1 + ,29 + ,4 + ,27 + ,44 + ,26 + ,35 + ,1 + ,43 + ,2 + ,41 + ,33 + ,19 + ,31 + ,2 + ,46 + ,3 + ,30 + ,42 + ,37 + ,36 + ,1 + ,44 + ,3 + ,33 + ,46 + ,25 + ,32 + ,1 + ,25 + ,3 + ,37 + ,45 + ,24 + ,35 + ,1 + ,51 + ,2 + ,30 + ,40 + ,23 + ,45 + ,1 + ,42 + ,5 + ,20 + ,48 + ,28 + ,29 + ,2 + ,53 + ,5 + ,44 + ,32 + ,38 + ,41 + ,1 + ,25 + ,4 + ,20 + ,53 + ,28 + ,36 + ,2 + ,49 + ,2 + ,33 + ,39 + ,28 + ,37 + ,1 + ,51 + ,3 + ,31 + ,45 + ,26 + ,25 + ,2 + ,20 + ,3 + ,23 + ,36 + ,21 + ,36 + ,2 + ,44 + ,3 + ,33 + ,38 + ,35 + ,34 + ,2 + ,38 + ,4 + ,33 + ,49 + ,31 + ,33 + ,1 + ,46 + ,5 + ,32 + ,46 + ,34 + ,32 + ,2 + ,42 + ,4 + ,25 + ,43 + ,30 + ,40 + ,1 + ,29 + ,NA + ,22 + ,37 + ,30 + ,27 + ,2 + ,46 + ,4 + ,16 + ,48 + ,24 + ,24 + ,2 + ,49 + ,2 + ,36 + ,45 + ,27 + ,26 + ,2 + ,51 + ,3 + ,35 + ,32 + ,26 + ,NA + ,1 + ,38 + ,3 + ,25 + ,46 + ,30 + ,13 + ,1 + ,41 + ,1 + ,27 + ,20 + ,15 + ,22 + ,2 + ,47 + ,3 + ,32 + ,42 + ,28 + ,29 + ,2 + ,44 + ,3 + ,36 + ,45 + ,34 + ,30 + ,2 + ,47 + ,3 + ,51 + ,29 + ,29 + ,24 + ,2 + ,46 + ,3 + ,30 + ,51 + ,26 + ,NA + ,1 + ,44 + ,4 + ,20 + ,55 + ,31 + ,26 + ,2 + ,28 + ,3 + ,29 + ,50 + ,28 + ,37 + ,2 + ,47 + ,4 + ,26 + ,44 + ,33 + ,36 + ,2 + ,28 + ,4 + ,20 + ,41 + ,32 + ,38 + ,1 + ,41 + ,5 + ,40 + ,40 + ,33 + ,34 + ,2 + ,45 + ,4 + ,29 + ,47 + ,31 + ,35 + ,2 + ,46 + ,4 + ,32 + ,42 + ,37 + ,32 + ,1 + ,46 + ,4 + ,33 + ,40 + ,27 + ,44 + ,2 + ,22 + ,3 + ,32 + ,51 + ,19 + ,40 + ,2 + ,33 + ,3 + ,34 + ,43 + ,27 + ,24 + ,1 + ,41 + ,4 + ,24 + ,45 + ,31 + ,36 + ,2 + ,47 + ,5 + ,25 + ,41 + ,38 + ,20 + ,1 + ,25 + ,3 + ,41 + ,41 + ,22 + ,28 + ,2 + ,42 + ,3 + ,39 + ,37 + ,35 + ,18 + ,2 + ,47 + ,3 + ,21 + ,46 + ,35 + ,23 + ,2 + ,50 + ,3 + ,38 + ,38 + ,30 + ,28 + ,1 + ,55 + ,5 + ,28 + ,39 + ,41 + ,30 + ,1 + ,21 + ,3 + ,37 + ,45 + ,25 + ,30 + ,1 + ,NA + ,3 + ,26 + ,46 + ,28 + ,43 + ,1 + ,52 + ,3 + ,30 + ,39 + ,45 + ,20 + ,2 + ,49 + ,4 + ,25 + ,21 + ,21 + ,37 + ,2 + ,46 + ,4 + ,38 + ,31 + ,33 + ,24 + ,1 + ,NA + ,4 + ,31 + ,35 + ,25 + ,33 + ,2 + ,45 + ,3 + ,31 + ,49 + ,29 + ,43 + ,2 + ,52 + ,3 + ,27 + ,40 + ,31 + ,27 + ,1 + ,NA + ,3 + ,21 + ,45 + ,29 + ,22 + ,2 + ,40 + ,4 + ,26 + ,46 + ,31 + ,28 + ,2 + ,49 + ,4 + ,37 + ,45 + ,31 + ,18 + ,1 + ,38 + ,5 + ,28 + ,34 + ,25 + ,38 + ,1 + ,32 + ,5 + ,29 + ,41 + ,27 + ,23 + ,2 + ,46 + ,4 + ,33 + ,43 + ,26 + ,38 + ,2 + ,32 + ,3 + ,41 + ,45 + ,26 + ,21 + ,2 + ,41 + ,3 + ,19 + ,48 + ,23 + ,25 + ,2 + ,43 + ,3 + ,37 + ,43 + ,27 + ,NA + ,1 + ,44 + ,4 + ,36 + ,45 + ,24 + ,30 + ,1 + ,47 + ,5 + ,27 + ,45 + ,35 + ,25 + ,2 + ,28 + ,3 + ,33 + ,34 + ,24 + ,17 + ,1 + ,52 + ,1 + ,29 + ,40 + ,32 + ,26 + ,1 + ,27 + ,2 + ,42 + ,40 + ,24 + ,39 + ,2 + ,45 + ,5 + ,27 + ,55 + ,24 + ,27 + ,1 + ,27 + ,4 + ,47 + ,44 + ,38 + ,33 + ,1 + ,25 + ,4 + ,17 + ,44 + ,36 + ,47 + ,1 + ,28 + ,4 + ,34 + ,48 + ,24 + ,37 + ,1 + ,25 + ,3 + ,32 + ,51 + ,18 + ,34 + ,1 + ,52 + ,4 + ,25 + ,49 + ,34 + ,24 + ,1 + ,44 + ,3 + ,27 + ,33 + ,23 + ,25 + ,2 + ,43 + ,3 + ,37 + ,43 + ,35 + ,20 + ,2 + ,47 + ,4 + ,34 + ,44 + ,22 + ,34 + ,2 + ,52 + ,4 + ,27 + ,44 + ,34 + ,22 + ,2 + ,40 + ,2 + ,37 + ,41 + ,28 + ,39 + ,1 + ,42 + ,3 + ,32 + ,45 + ,34 + ,33 + ,1 + ,45 + ,5 + ,26 + ,44 + ,32 + ,35 + ,1 + ,45 + ,2 + ,29 + ,44 + ,24 + ,26 + ,1 + ,50 + ,5 + ,28 + ,40 + ,34 + ,32 + ,1 + ,49 + ,3 + ,19 + ,48 + ,33 + ,22 + ,1 + ,52 + ,2 + ,46 + ,49 + ,33 + ,39 + ,2 + ,48 + ,3 + ,31 + ,46 + ,29 + ,35 + ,2 + ,51 + ,3 + ,42 + ,49 + ,38 + ,21 + ,2 + ,49 + ,4 + ,33 + ,55 + ,24 + ,27 + ,2 + ,31 + ,4 + ,39 + ,51 + ,25 + ,31 + ,2 + ,43 + ,3 + ,27 + ,46 + ,37 + ,20 + ,2 + ,31 + ,3 + ,35 + ,37 + ,33 + ,28 + ,2 + ,28 + ,4 + ,23 + ,43 + ,30 + ,26 + ,2 + ,43 + ,4 + ,32 + ,41 + ,22 + ,36 + ,2 + ,31 + ,3 + ,22 + ,45 + ,28 + ,16 + ,2 + ,51 + ,3 + ,17 + ,39 + ,24 + ,34 + ,2 + ,58 + ,4 + ,35 + ,38 + ,33 + ,30 + ,2 + ,25 + ,5 + ,34 + ,41 + ,37) + ,dim=c(7 + ,195) + ,dimnames=list(c('Intrinsieke_waarden' + ,'geslacht' + ,'leeftijd' + ,'opleiding' + ,'Neuroticisme' + ,'Extraversie' + ,'Openheid ') + ,1:195)) > y <- array(NA,dim=c(7,195),dimnames=list(c('Intrinsieke_waarden','geslacht','leeftijd','opleiding','Neuroticisme','Extraversie','Openheid '),1:195)) > 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' > #'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] "Intrinsieke_waarden" > x[,par1] [1] 40 45 38 28 38 39 37 30 30 30 26 29 31 27 25 39 35 27 40 34 32 34 38 21 33 [26] 27 35 33 36 37 37 37 32 25 31 33 18 42 26 26 32 31 29 35 44 35 30 32 24 34 [51] 27 31 38 41 40 25 19 33 27 45 27 30 42 21 32 31 36 34 11 35 39 32 28 45 18 [76] 35 35 36 34 34 38 28 23 37 29 28 30 24 36 40 37 27 25 22 21 28 34 32 23 29 [101] 35 31 36 32 35 45 29 41 36 37 25 36 34 33 32 40 27 24 26 13 22 29 30 24 26 [126] 37 36 38 34 35 32 44 40 24 36 20 28 18 23 28 30 30 43 20 37 24 33 43 27 22 [151] 28 18 38 23 38 21 25 30 25 17 26 39 27 33 47 37 34 24 25 20 34 22 39 33 35 [176] 26 32 22 39 35 21 27 31 20 28 26 36 16 34 30 > 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]) 11 13 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 1 1 1 1 4 1 4 5 5 4 7 8 8 11 9 6 11 7 11 8 12 12 10 10 8 6 40 41 42 43 44 45 47 6 2 2 2 2 4 1 > colnames(x) [1] "Intrinsieke_waarden" "geslacht" "leeftijd" [4] "opleiding" "Neuroticisme" "Extraversie" [7] "Openheid." > colnames(x)[par1] [1] "Intrinsieke_waarden" > x[,par1] [1] 40 45 38 28 38 39 37 30 30 30 26 29 31 27 25 39 35 27 40 34 32 34 38 21 33 [26] 27 35 33 36 37 37 37 32 25 31 33 18 42 26 26 32 31 29 35 44 35 30 32 24 34 [51] 27 31 38 41 40 25 19 33 27 45 27 30 42 21 32 31 36 34 11 35 39 32 28 45 18 [76] 35 35 36 34 34 38 28 23 37 29 28 30 24 36 40 37 27 25 22 21 28 34 32 23 29 [101] 35 31 36 32 35 45 29 41 36 37 25 36 34 33 32 40 27 24 26 13 22 29 30 24 26 [126] 37 36 38 34 35 32 44 40 24 36 20 28 18 23 28 30 30 43 20 37 24 33 43 27 22 [151] 28 18 38 23 38 21 25 30 25 17 26 39 27 33 47 37 34 24 25 20 34 22 39 33 35 [176] 26 32 22 39 35 21 27 31 20 28 26 36 16 34 30 > 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/1x2o21293467190.tab") + } + } > m Conditional inference tree with 4 terminal nodes Response: Intrinsieke_waarden Inputs: geslacht, leeftijd, opleiding, Neuroticisme, Extraversie, Openheid. Number of observations: 190 1) Extraversie <= 50; criterion = 1, statistic = 18.412 2) Openheid. <= 25; criterion = 0.999, statistic = 14.014 3)* weights = 36 2) Openheid. > 25 4) geslacht <= 1; criterion = 0.997, statistic = 12.05 5)* weights = 51 4) geslacht > 1 6)* weights = 79 1) Extraversie > 50 7)* weights = 24 > postscript(file="/var/www/rcomp/tmp/2qtn51293467190.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/3qtn51293467190.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 40 33.66667 6.3333333 2 45 33.66667 11.3333333 3 38 35.66667 2.3333333 4 28 33.66667 -5.6666667 5 38 35.66667 2.3333333 6 39 33.66667 5.3333333 7 37 33.66667 3.3333333 8 30 33.66667 -3.6666667 9 30 29.87342 0.1265823 10 30 29.87342 0.1265823 11 26 29.87342 -3.8734177 12 29 33.66667 -4.6666667 13 31 29.87342 1.1265823 14 27 29.87342 -2.8734177 15 25 26.86111 -1.8611111 16 39 26.86111 12.1388889 17 35 33.66667 1.3333333 18 27 29.87342 -2.8734177 19 40 29.87342 10.1265823 20 34 29.87342 4.1265823 21 32 29.87342 2.1265823 22 34 33.66667 0.3333333 23 38 26.86111 11.1388889 24 21 26.86111 -5.8611111 25 33 35.66667 -2.6666667 26 27 29.87342 -2.8734177 27 35 26.86111 8.1388889 28 33 26.86111 6.1388889 29 36 33.66667 2.3333333 30 37 35.66667 1.3333333 31 37 33.66667 3.3333333 32 37 33.66667 3.3333333 33 32 33.66667 -1.6666667 34 25 29.87342 -4.8734177 35 31 33.66667 -2.6666667 36 33 29.87342 3.1265823 37 18 29.87342 -11.8734177 38 42 35.66667 6.3333333 39 26 26.86111 -0.8611111 40 26 29.87342 -3.8734177 41 32 26.86111 5.1388889 42 31 33.66667 -2.6666667 43 29 29.87342 -0.8734177 44 35 26.86111 8.1388889 45 44 33.66667 10.3333333 46 35 33.66667 1.3333333 47 30 35.66667 -5.6666667 48 32 35.66667 -3.6666667 49 24 29.87342 -5.8734177 50 34 35.66667 -1.6666667 51 27 29.87342 -2.8734177 52 31 29.87342 1.1265823 53 38 35.66667 2.3333333 54 41 29.87342 11.1265823 55 40 35.66667 4.3333333 56 25 29.87342 -4.8734177 57 19 26.86111 -7.8611111 58 33 35.66667 -2.6666667 59 27 29.87342 -2.8734177 60 45 33.66667 11.3333333 61 27 29.87342 -2.8734177 62 30 29.87342 0.1265823 63 42 35.66667 6.3333333 64 21 29.87342 -8.8734177 65 32 29.87342 2.1265823 66 31 29.87342 1.1265823 67 36 29.87342 6.1265823 68 34 33.66667 0.3333333 69 11 26.86111 -15.8611111 70 35 26.86111 8.1388889 71 39 33.66667 5.3333333 72 32 33.66667 -1.6666667 73 28 29.87342 -1.8734177 74 45 35.66667 9.3333333 75 18 26.86111 -8.8611111 76 35 35.66667 -0.6666667 77 35 35.66667 -0.6666667 78 36 29.87342 6.1265823 79 34 33.66667 0.3333333 80 34 33.66667 0.3333333 81 38 29.87342 8.1265823 82 28 29.87342 -1.8734177 83 23 29.87342 -6.8734177 84 37 35.66667 1.3333333 85 29 29.87342 -0.8734177 86 28 33.66667 -5.6666667 87 30 33.66667 -3.6666667 88 24 29.87342 -5.8734177 89 36 33.66667 2.3333333 90 40 33.66667 6.3333333 91 37 29.87342 7.1265823 92 27 29.87342 -2.8734177 93 25 29.87342 -4.8734177 94 22 26.86111 -4.8611111 95 21 29.87342 -8.8734177 96 28 33.66667 -5.6666667 97 34 35.66667 -1.6666667 98 32 29.87342 2.1265823 99 23 26.86111 -3.8611111 100 29 33.66667 -4.6666667 101 35 26.86111 8.1388889 102 31 29.87342 1.1265823 103 36 26.86111 9.1388889 104 32 26.86111 5.1388889 105 35 26.86111 8.1388889 106 45 33.66667 11.3333333 107 29 29.87342 -0.8734177 108 41 35.66667 5.3333333 109 36 29.87342 6.1265823 110 37 33.66667 3.3333333 111 25 26.86111 -1.8611111 112 36 29.87342 6.1265823 113 34 29.87342 4.1265823 114 33 33.66667 -0.6666667 115 32 29.87342 2.1265823 116 40 33.66667 6.3333333 117 27 26.86111 0.1388889 118 24 29.87342 -5.8734177 119 26 29.87342 -3.8734177 120 13 26.86111 -13.8611111 121 22 29.87342 -7.8734177 122 29 29.87342 -0.8734177 123 30 29.87342 0.1265823 124 24 35.66667 -11.6666667 125 26 29.87342 -3.8734177 126 37 29.87342 7.1265823 127 36 29.87342 6.1265823 128 38 33.66667 4.3333333 129 34 29.87342 4.1265823 130 35 29.87342 5.1265823 131 32 33.66667 -1.6666667 132 44 35.66667 8.3333333 133 40 29.87342 10.1265823 134 24 33.66667 -9.6666667 135 36 29.87342 6.1265823 136 20 26.86111 -6.8611111 137 28 29.87342 -1.8734177 138 18 29.87342 -11.8734177 139 23 29.87342 -6.8734177 140 28 33.66667 -5.6666667 141 30 26.86111 3.1388889 142 30 33.66667 -3.6666667 143 43 33.66667 9.3333333 144 20 26.86111 -6.8611111 145 37 29.87342 7.1265823 146 24 26.86111 -2.8611111 147 33 29.87342 3.1265823 148 43 29.87342 13.1265823 149 27 33.66667 -6.6666667 150 22 29.87342 -7.8734177 151 28 29.87342 -1.8734177 152 18 26.86111 -8.8611111 153 38 33.66667 4.3333333 154 23 29.87342 -6.8734177 155 38 29.87342 8.1265823 156 21 26.86111 -5.8611111 157 25 29.87342 -4.8734177 158 30 33.66667 -3.6666667 159 25 26.86111 -1.8611111 160 17 33.66667 -16.6666667 161 26 26.86111 -0.8611111 162 39 35.66667 3.3333333 163 27 33.66667 -6.6666667 164 33 33.66667 -0.6666667 165 47 26.86111 20.1388889 166 37 35.66667 1.3333333 167 34 33.66667 0.3333333 168 24 26.86111 -2.8611111 169 25 29.87342 -4.8734177 170 20 26.86111 -6.8611111 171 34 29.87342 4.1265823 172 22 29.87342 -7.8734177 173 39 33.66667 5.3333333 174 33 33.66667 -0.6666667 175 35 26.86111 8.1388889 176 26 33.66667 -7.6666667 177 32 33.66667 -1.6666667 178 22 33.66667 -11.6666667 179 39 29.87342 9.1265823 180 35 29.87342 5.1265823 181 21 35.66667 -14.6666667 182 27 35.66667 -8.6666667 183 31 29.87342 1.1265823 184 20 29.87342 -9.8734177 185 28 29.87342 -1.8734177 186 26 26.86111 -0.8611111 187 36 29.87342 6.1265823 188 16 26.86111 -10.8611111 189 34 29.87342 4.1265823 190 30 29.87342 0.1265823 > 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/41k4q1293467190.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/5fukz1293467190.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/673jk1293467190.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/7b4iq1293467190.tab") + } > > try(system("convert tmp/2qtn51293467190.ps tmp/2qtn51293467190.png",intern=TRUE)) character(0) > try(system("convert tmp/3qtn51293467190.ps tmp/3qtn51293467190.png",intern=TRUE)) character(0) > try(system("convert tmp/41k4q1293467190.ps tmp/41k4q1293467190.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.180 0.780 3.956