R version 2.13.0 (2011-04-13) Copyright (C) 2011 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. > par9 = 'ATTLES connected' > par8 = 'ATTLES connected' > par7 = 'all' > par6 = 'all' > par5 = 'female' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'ATTLES connected' > par8 <- 'ATTLES connected' > par7 <- 'all' > par6 <- 'all' > par5 <- 'female' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '0' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., 2012, Recursive Partitioning (Regression Trees) in Information Management (v1.0.8) 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 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 <- as.data.frame(read.table(file='http://www.wessa.net/download/utaut.csv',sep=',',header=T)) > x$U25 <- 6-x$U25 > if(par5 == 'female') x <- x[x$Gender==0,] > if(par5 == 'male') x <- x[x$Gender==1,] > if(par6 == 'prep') x <- x[x$Pop==1,] > if(par6 == 'bachelor') x <- x[x$Pop==0,] > if(par7 != 'all') { + x <- x[x$Year==as.numeric(par7),] + } > cAc <- with(x,cbind( A1, A2, A3, A4, A5, A6, A7, A8, A9,A10)) > cAs <- with(x,cbind(A11,A12,A13,A14,A15,A16,A17,A18,A19,A20)) > cA <- cbind(cAc,cAs) > cCa <- with(x,cbind(C1,C3,C5,C7, C9,C11,C13,C15,C17,C19,C21,C23,C25,C27,C29,C31,C33,C35,C37,C39,C41,C43,C45,C47)) > cCp <- with(x,cbind(C2,C4,C6,C8,C10,C12,C14,C16,C18,C20,C22,C24,C26,C28,C30,C32,C34,C36,C38,C40,C42,C44,C46,C48)) > cC <- cbind(cCa,cCp) > cU <- with(x,cbind(U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33)) > cE <- with(x,cbind(BC,NNZFG,MRT,AFL,LPM,LPC,W,WPA)) > cX <- with(x,cbind(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14,X15,X16,X17,X18)) > if (par8=='ATTLES connected') x <- cAc > if (par8=='ATTLES separate') x <- cAs > if (par8=='ATTLES all') x <- cA > if (par8=='COLLES actuals') x <- cCa > if (par8=='COLLES preferred') x <- cCp > if (par8=='COLLES all') x <- cC > if (par8=='CSUQ') x <- cU > if (par8=='Learning Activities') x <- cE > if (par8=='Exam Items') x <- cX > if (par9=='ATTLES connected') y <- cAc > if (par9=='ATTLES separate') y <- cAs > if (par9=='ATTLES all') y <- cA > if (par9=='COLLES actuals') y <- cCa > if (par9=='COLLES preferred') y <- cCp > if (par9=='COLLES all') y <- cC > if (par9=='CSUQ') y <- cU > if (par9=='Learning Activities') y <- cE > if (par9=='Exam Items') y <- cX > if (par1==0) { + nr <- length(y[,1]) + nc <- length(y[1,]) + mysum <- array(0,dim=nr) + for(jjj in 1:nr) { + for(iii in 1:nc) { + mysum[jjj] = mysum[jjj] + y[jjj,iii] + } + } + y <- mysum + } else { + y <- y[,par1] + } > nx <- cbind(y,x) > colnames(nx) <- c('endo',colnames(x)) > x <- nx > par1=1 > ncol <- length(x[1,]) > for (jjj in 1:ncol) { + x <- x[!is.na(x[,jjj]),] + } > x <- as.data.frame(x) > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "endo" > x[,par1] [1] 34 38 30 27 31 34 28 40 34 38 32 36 30 32 38 31 32 36 32 36 38 38 27 35 32 [26] 33 32 37 37 37 39 33 37 36 32 38 32 37 39 34 30 35 38 37 28 41 39 37 38 35 [51] 29 32 31 32 37 36 37 35 32 28 35 37 32 24 21 36 30 38 39 32 35 36 27 34 34 [76] 37 38 30 24 30 36 36 30 26 36 34 37 37 35 35 38 36 28 41 33 32 34 35 29 36 [101] 32 29 40 34 38 34 32 37 34 28 31 32 35 35 37 34 35 21 21 33 41 30 31 27 34 [126] 38 22 33 32 30 35 31 33 27 28 33 38 31 35 40 31 33 29 39 34 32 35 40 35 35 [151] 40 32 36 39 37 39 36 36 36 43 40 36 33 36 37 37 32 33 41 40 32 35 34 37 32 [176] 43 35 33 26 39 40 36 35 37 32 33 35 32 38 35 38 29 38 40 39 35 40 34 36 37 [201] 33 38 37 38 32 38 28 37 31 42 38 38 40 30 36 34 39 44 40 37 39 38 34 36 34 [226] 33 33 35 37 31 36 39 37 32 32 31 35 30 32 34 49 38 35 35 35 34 34 41 38 37 [251] 38 36 27 36 38 39 39 36 33 41 45 43 35 23 43 36 41 41 34 39 40 28 39 36 36 [276] 35 37 35 34 39 39 41 44 42 31 39 39 35 38 37 39 43 39 40 31 28 40 33 38 39 [301] 47 35 42 38 37 37 38 41 38 43 35 37 32 37 30 35 38 32 36 36 37 35 40 34 39 [326] 36 35 36 26 35 36 34 35 32 38 37 36 40 45 42 39 32 38 41 36 35 39 42 33 38 [351] 32 34 44 34 40 37 39 34 24 42 38 26 29 36 34 40 35 36 37 43 32 44 39 39 37 [376] 34 29 22 33 37 40 37 30 36 36 37 31 48 39 42 36 39 36 38 47 36 36 38 39 37 [401] 38 39 36 36 38 35 40 38 38 37 37 38 33 33 36 35 31 33 36 41 38 37 33 30 43 [426] 41 38 40 35 35 37 35 35 42 37 41 41 34 32 40 35 32 46 39 41 34 36 38 38 32 [451] 41 29 21 34 36 > 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]) 21 22 23 24 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 4 2 1 3 4 6 9 8 14 15 38 23 34 48 50 47 48 34 23 17 8 8 4 2 1 2 48 49 1 1 > colnames(x) [1] "endo" "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" [11] "A10" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 34 38 30 27 31 34 28 40 34 38 32 36 30 32 38 31 32 36 32 36 38 38 27 35 32 [26] 33 32 37 37 37 39 33 37 36 32 38 32 37 39 34 30 35 38 37 28 41 39 37 38 35 [51] 29 32 31 32 37 36 37 35 32 28 35 37 32 24 21 36 30 38 39 32 35 36 27 34 34 [76] 37 38 30 24 30 36 36 30 26 36 34 37 37 35 35 38 36 28 41 33 32 34 35 29 36 [101] 32 29 40 34 38 34 32 37 34 28 31 32 35 35 37 34 35 21 21 33 41 30 31 27 34 [126] 38 22 33 32 30 35 31 33 27 28 33 38 31 35 40 31 33 29 39 34 32 35 40 35 35 [151] 40 32 36 39 37 39 36 36 36 43 40 36 33 36 37 37 32 33 41 40 32 35 34 37 32 [176] 43 35 33 26 39 40 36 35 37 32 33 35 32 38 35 38 29 38 40 39 35 40 34 36 37 [201] 33 38 37 38 32 38 28 37 31 42 38 38 40 30 36 34 39 44 40 37 39 38 34 36 34 [226] 33 33 35 37 31 36 39 37 32 32 31 35 30 32 34 49 38 35 35 35 34 34 41 38 37 [251] 38 36 27 36 38 39 39 36 33 41 45 43 35 23 43 36 41 41 34 39 40 28 39 36 36 [276] 35 37 35 34 39 39 41 44 42 31 39 39 35 38 37 39 43 39 40 31 28 40 33 38 39 [301] 47 35 42 38 37 37 38 41 38 43 35 37 32 37 30 35 38 32 36 36 37 35 40 34 39 [326] 36 35 36 26 35 36 34 35 32 38 37 36 40 45 42 39 32 38 41 36 35 39 42 33 38 [351] 32 34 44 34 40 37 39 34 24 42 38 26 29 36 34 40 35 36 37 43 32 44 39 39 37 [376] 34 29 22 33 37 40 37 30 36 36 37 31 48 39 42 36 39 36 38 47 36 36 38 39 37 [401] 38 39 36 36 38 35 40 38 38 37 37 38 33 33 36 35 31 33 36 41 38 37 33 30 43 [426] 41 38 40 35 35 37 35 35 42 37 41 41 34 32 40 35 32 46 39 41 34 36 38 38 32 [451] 41 29 21 34 36 > 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/1205b1336322366.tab") + } + } > m Conditional inference tree with 24 terminal nodes Response: endo Inputs: A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 Number of observations: 455 1) A8 <= 4; criterion = 1, statistic = 175.396 2) A4 <= 2; criterion = 1, statistic = 87.894 3) A8 <= 2; criterion = 1, statistic = 32.201 4)* weights = 16 3) A8 > 2 5) A2 <= 2; criterion = 1, statistic = 23.374 6) A9 <= 1; criterion = 0.963, statistic = 8.383 7)* weights = 12 6) A9 > 1 8)* weights = 20 5) A2 > 2 9) A5 <= 3; criterion = 0.977, statistic = 9.252 10)* weights = 13 9) A5 > 3 11)* weights = 20 2) A4 > 2 12) A10 <= 2; criterion = 1, statistic = 55.48 13)* weights = 16 12) A10 > 2 14) A2 <= 2; criterion = 1, statistic = 47.923 15) A5 <= 3; criterion = 1, statistic = 24.588 16)* weights = 23 15) A5 > 3 17) A10 <= 3; criterion = 0.998, statistic = 14.02 18)* weights = 18 17) A10 > 3 19) A3 <= 4; criterion = 0.996, statistic = 12.525 20)* weights = 31 19) A3 > 4 21)* weights = 13 14) A2 > 2 22) A6 <= 3; criterion = 1, statistic = 31.079 23) A9 <= 2; criterion = 0.995, statistic = 12.057 24)* weights = 19 23) A9 > 2 25)* weights = 24 22) A6 > 3 26) A7 <= 3; criterion = 1, statistic = 27.064 27) A8 <= 3; criterion = 0.987, statistic = 10.36 28)* weights = 9 27) A8 > 3 29)* weights = 29 26) A7 > 3 30) A3 <= 3; criterion = 0.999, statistic = 15.472 31)* weights = 19 30) A3 > 3 32) A4 <= 3; criterion = 1, statistic = 16.673 33)* weights = 22 32) A4 > 3 34)* weights = 28 1) A8 > 4 35) A9 <= 2; criterion = 1, statistic = 36.781 36) A2 <= 2; criterion = 0.999, statistic = 15.131 37)* weights = 16 36) A2 > 2 38) A10 <= 4; criterion = 0.99, statistic = 10.805 39)* weights = 26 38) A10 > 4 40)* weights = 10 35) A9 > 2 41) A5 <= 4; criterion = 1, statistic = 18.783 42) A1 <= 3; criterion = 1, statistic = 19.369 43)* weights = 14 42) A1 > 3 44) A7 <= 4; criterion = 0.972, statistic = 8.937 45)* weights = 23 44) A7 > 4 46)* weights = 17 41) A5 > 4 47)* weights = 17 > postscript(file="/var/wessaorg/rcomp/tmp/2o2fs1336322366.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/340171336322366.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 34 31.95652 2.04347826 2 38 40.00000 -2.00000000 3 30 34.77419 -4.77419355 4 27 31.95652 -4.95652174 5 31 31.95652 -0.95652174 6 34 31.95652 2.04347826 7 28 26.00000 2.00000000 8 40 37.15385 2.84615385 9 34 36.44828 -2.44827586 10 38 39.03571 -1.03571429 11 32 35.40000 -3.40000000 12 36 35.40000 0.60000000 13 30 33.11111 -3.11111111 14 32 32.23077 -0.23076923 15 38 34.77419 3.22580645 16 31 31.30000 -0.30000000 17 32 33.11111 -1.11111111 18 36 34.77419 1.22580645 19 32 33.11111 -1.11111111 20 36 33.47368 2.52631579 21 38 36.44828 1.55172414 22 38 39.03571 -1.03571429 23 27 31.30000 -4.30000000 24 35 32.23077 2.76923077 25 32 31.95652 0.04347826 26 33 31.95652 1.04347826 27 32 31.95652 0.04347826 28 37 37.40909 -0.40909091 29 37 37.38462 -0.38461538 30 37 37.40909 -0.40909091 31 39 39.65217 -0.65217391 32 33 37.15385 -4.15384615 33 37 37.40909 -0.40909091 34 36 34.77419 1.22580645 35 32 31.30000 0.70000000 36 38 35.40000 2.60000000 37 32 31.95652 0.04347826 38 37 34.77419 2.22580645 39 39 37.40909 1.59090909 40 34 33.11111 0.88888889 41 30 30.00000 0.00000000 42 35 31.95652 3.04347826 43 38 36.31579 1.68421053 44 37 36.44828 0.55172414 45 28 30.00000 -2.00000000 46 41 36.44828 4.55172414 47 39 40.00000 -1.00000000 48 37 34.77419 2.22580645 49 38 37.40909 0.59090909 50 35 37.40909 -2.40909091 51 29 31.95652 -2.95652174 52 32 34.77419 -2.77419355 53 31 31.30000 -0.30000000 54 32 26.00000 6.00000000 55 37 36.44828 0.55172414 56 36 37.40909 -1.40909091 57 37 39.65217 -2.65217391 58 35 31.30000 3.70000000 59 32 33.11111 -1.11111111 60 28 26.00000 2.00000000 61 35 33.47368 1.52631579 62 37 34.44444 2.55555556 63 32 33.11111 -1.11111111 64 24 29.08333 -5.08333333 65 21 30.00000 -9.00000000 66 36 36.44828 -0.44827586 67 30 26.00000 4.00000000 68 38 37.40909 0.59090909 69 39 37.40909 1.59090909 70 32 34.81250 -2.81250000 71 35 37.38462 -2.38461538 72 36 39.03571 -3.03571429 73 27 29.08333 -2.08333333 74 34 33.11111 0.88888889 75 34 34.44444 -0.44444444 76 37 39.03571 -2.03571429 77 38 37.40909 0.59090909 78 30 26.00000 4.00000000 79 24 26.00000 -2.00000000 80 30 31.95652 -1.95652174 81 36 34.77419 1.22580645 82 36 34.44444 1.55555556 83 30 31.30000 -1.30000000 84 26 30.00000 -4.00000000 85 36 34.81250 1.18750000 86 34 36.20833 -2.20833333 87 37 37.40909 -0.40909091 88 37 31.95652 5.04347826 89 35 35.40000 -0.40000000 90 35 37.15385 -2.15384615 91 38 37.15385 0.84615385 92 36 34.81250 1.18750000 93 28 31.30000 -3.30000000 94 41 39.65217 1.34782609 95 33 31.95652 1.04347826 96 32 30.00000 2.00000000 97 34 33.11111 0.88888889 98 35 35.40000 -0.40000000 99 29 33.11111 -4.11111111 100 36 35.40000 0.60000000 101 32 33.11111 -1.11111111 102 29 31.30000 -2.30000000 103 40 35.40000 4.60000000 104 34 31.30000 2.70000000 105 38 39.03571 -1.03571429 106 34 35.40000 -1.40000000 107 32 31.95652 0.04347826 108 37 33.11111 3.88888889 109 34 34.81250 -0.81250000 110 28 32.23077 -4.23076923 111 31 29.08333 1.91666667 112 32 31.95652 0.04347826 113 35 31.95652 3.04347826 114 35 34.77419 0.22580645 115 37 37.15385 -0.15384615 116 34 35.40000 -1.40000000 117 35 34.77419 0.22580645 118 21 26.00000 -5.00000000 119 21 26.00000 -5.00000000 120 33 34.81250 -1.81250000 121 41 41.23529 -0.23529412 122 30 31.95652 -1.95652174 123 31 29.08333 1.91666667 124 27 29.08333 -2.08333333 125 34 32.23077 1.76923077 126 38 35.40000 2.60000000 127 22 26.00000 -4.00000000 128 33 31.30000 1.70000000 129 32 33.11111 -1.11111111 130 30 34.81250 -4.81250000 131 35 34.77419 0.22580645 132 31 31.30000 -0.30000000 133 33 33.11111 -0.11111111 134 27 32.23077 -5.23076923 135 28 31.30000 -3.30000000 136 33 33.11111 -0.11111111 137 38 37.38462 0.61538462 138 31 31.30000 -0.30000000 139 35 35.40000 -0.40000000 140 40 39.03571 0.96428571 141 31 31.30000 -0.30000000 142 33 33.47368 -0.47368421 143 29 31.95652 -2.95652174 144 39 40.00000 -1.00000000 145 34 33.47368 0.52631579 146 32 34.81250 -2.81250000 147 35 37.15385 -2.15384615 148 40 37.15385 2.84615385 149 35 35.40000 -0.40000000 150 35 34.44444 0.55555556 151 40 39.03571 0.96428571 152 32 29.08333 2.91666667 153 36 33.11111 2.88888889 154 39 37.38462 1.61538462 155 37 34.81250 2.18750000 156 39 39.65217 -0.65217391 157 36 36.44828 -0.44827586 158 36 37.40909 -1.40909091 159 36 34.77419 1.22580645 160 43 37.38462 5.61538462 161 40 37.40909 2.59090909 162 36 37.38462 -1.38461538 163 33 32.23077 0.76923077 164 36 37.15385 -1.15384615 165 37 42.88235 -5.88235294 166 37 37.38462 -0.38461538 167 32 31.30000 0.70000000 168 33 34.77419 -1.77419355 169 41 40.00000 1.00000000 170 40 37.38462 2.61538462 171 32 31.30000 0.70000000 172 35 35.40000 -0.40000000 173 34 33.11111 0.88888889 174 37 35.40000 1.60000000 175 32 32.23077 -0.23076923 176 43 41.23529 1.76470588 177 35 33.47368 1.52631579 178 33 32.23077 0.76923077 179 26 29.08333 -3.08333333 180 39 40.00000 -1.00000000 181 40 39.65217 0.34782609 182 36 36.44828 -0.44827586 183 35 37.28571 -2.28571429 184 37 39.65217 -2.65217391 185 32 34.77419 -2.77419355 186 33 34.77419 -1.77419355 187 35 34.81250 0.18750000 188 32 34.77419 -2.77419355 189 38 37.15385 0.84615385 190 35 34.77419 0.22580645 191 38 34.81250 3.18750000 192 29 29.08333 -0.08333333 193 38 39.65217 -1.65217391 194 40 37.15385 2.84615385 195 39 36.44828 2.55172414 196 35 36.44828 -1.44827586 197 40 37.15385 2.84615385 198 34 33.47368 0.52631579 199 36 37.38462 -1.38461538 200 37 30.00000 7.00000000 201 33 29.08333 3.91666667 202 38 39.03571 -1.03571429 203 37 37.38462 -0.38461538 204 38 36.31579 1.68421053 205 32 31.30000 0.70000000 206 38 39.65217 -1.65217391 207 28 29.08333 -1.08333333 208 37 34.81250 2.18750000 209 31 29.08333 1.91666667 210 42 42.88235 -0.88235294 211 38 34.81250 3.18750000 212 38 37.40909 0.59090909 213 40 41.23529 -1.23529412 214 30 29.08333 0.91666667 215 36 34.81250 1.18750000 216 34 34.44444 -0.44444444 217 39 42.88235 -3.88235294 218 44 42.88235 1.11764706 219 40 39.03571 0.96428571 220 37 37.38462 -0.38461538 221 39 34.77419 4.22580645 222 38 34.77419 3.22580645 223 34 34.77419 -0.77419355 224 36 37.15385 -1.15384615 225 34 31.30000 2.70000000 226 33 37.38462 -4.38461538 227 33 34.77419 -1.77419355 228 35 37.15385 -2.15384615 229 37 34.77419 2.22580645 230 31 31.95652 -0.95652174 231 36 34.77419 1.22580645 232 39 36.44828 2.55172414 233 37 37.15385 -0.15384615 234 32 33.11111 -1.11111111 235 32 34.77419 -2.77419355 236 31 26.00000 5.00000000 237 35 37.15385 -2.15384615 238 30 26.00000 4.00000000 239 32 35.40000 -3.40000000 240 34 34.77419 -0.77419355 241 49 42.88235 6.11764706 242 38 39.03571 -1.03571429 243 35 34.81250 0.18750000 244 35 34.77419 0.22580645 245 35 37.15385 -2.15384615 246 34 35.40000 -1.40000000 247 34 32.23077 1.76923077 248 41 39.03571 1.96428571 249 38 37.40909 0.59090909 250 37 37.40909 -0.40909091 251 38 37.38462 0.61538462 252 36 37.28571 -1.28571429 253 27 26.00000 1.00000000 254 36 34.77419 1.22580645 255 38 36.44828 1.55172414 256 39 36.44828 2.55172414 257 39 40.00000 -1.00000000 258 36 34.77419 1.22580645 259 33 32.23077 0.76923077 260 41 41.23529 -0.23529412 261 45 41.23529 3.76470588 262 43 40.00000 3.00000000 263 35 36.44828 -1.44827586 264 23 26.00000 -3.00000000 265 43 42.88235 0.11764706 266 36 30.00000 6.00000000 267 41 42.88235 -1.88235294 268 41 37.15385 3.84615385 269 34 36.20833 -2.20833333 270 39 39.03571 -0.03571429 271 40 39.03571 0.96428571 272 28 33.47368 -5.47368421 273 39 39.65217 -0.65217391 274 36 33.47368 2.52631579 275 36 37.28571 -1.28571429 276 35 37.28571 -2.28571429 277 37 36.31579 0.68421053 278 35 36.44828 -1.44827586 279 34 36.31579 -2.31578947 280 39 39.65217 -0.65217391 281 39 39.65217 -0.65217391 282 41 36.20833 4.79166667 283 44 41.23529 2.76470588 284 42 39.03571 2.96428571 285 31 32.23077 -1.23076923 286 39 39.65217 -0.65217391 287 39 41.23529 -2.23529412 288 35 35.40000 -0.40000000 289 38 37.40909 0.59090909 290 37 36.31579 0.68421053 291 39 37.40909 1.59090909 292 43 42.88235 0.11764706 293 39 37.28571 1.71428571 294 40 37.28571 2.71428571 295 31 30.00000 1.00000000 296 28 31.95652 -3.95652174 297 40 39.65217 0.34782609 298 33 30.00000 3.00000000 299 38 41.23529 -3.23529412 300 39 39.03571 -0.03571429 301 47 42.88235 4.11764706 302 35 37.28571 -2.28571429 303 42 41.23529 0.76470588 304 38 37.28571 0.71428571 305 37 30.00000 7.00000000 306 37 39.03571 -2.03571429 307 38 34.77419 3.22580645 308 41 41.23529 -0.23529412 309 38 37.15385 0.84615385 310 43 40.00000 3.00000000 311 35 36.20833 -1.20833333 312 37 36.20833 0.79166667 313 32 34.44444 -2.44444444 314 37 36.44828 0.55172414 315 30 31.95652 -1.95652174 316 35 36.20833 -1.20833333 317 38 37.15385 0.84615385 318 32 34.44444 -2.44444444 319 36 36.20833 -0.20833333 320 36 36.20833 -0.20833333 321 37 36.20833 0.79166667 322 35 34.81250 0.18750000 323 40 39.03571 0.96428571 324 34 36.20833 -2.20833333 325 39 39.03571 -0.03571429 326 36 36.31579 -0.31578947 327 35 35.40000 -0.40000000 328 36 37.15385 -1.15384615 329 26 30.00000 -4.00000000 330 35 37.28571 -2.28571429 331 36 39.03571 -3.03571429 332 34 32.23077 1.76923077 333 35 36.44828 -1.44827586 334 32 34.77419 -2.77419355 335 38 39.03571 -1.03571429 336 37 36.31579 0.68421053 337 36 37.40909 -1.40909091 338 40 37.28571 2.71428571 339 45 42.88235 2.11764706 340 42 41.23529 0.76470588 341 39 42.88235 -3.88235294 342 32 33.47368 -1.47368421 343 38 37.15385 0.84615385 344 41 39.65217 1.34782609 345 36 36.31579 -0.31578947 346 35 36.20833 -1.20833333 347 39 39.65217 -0.65217391 348 42 39.65217 2.34782609 349 33 37.15385 -4.15384615 350 38 37.15385 0.84615385 351 32 33.47368 -1.47368421 352 34 36.31579 -2.31578947 353 44 42.88235 1.11764706 354 34 33.47368 0.52631579 355 40 37.15385 2.84615385 356 37 36.44828 0.55172414 357 39 36.20833 2.79166667 358 34 36.20833 -2.20833333 359 24 30.00000 -6.00000000 360 42 39.65217 2.34782609 361 38 37.40909 0.59090909 362 26 26.00000 0.00000000 363 29 30.00000 -1.00000000 364 36 31.95652 4.04347826 365 34 36.44828 -2.44827586 366 40 36.20833 3.79166667 367 35 35.40000 -0.40000000 368 36 36.20833 -0.20833333 369 37 36.44828 0.55172414 370 43 39.65217 3.34782609 371 32 30.00000 2.00000000 372 44 42.88235 1.11764706 373 39 39.03571 -0.03571429 374 39 39.03571 -0.03571429 375 37 35.40000 1.60000000 376 34 34.44444 -0.44444444 377 29 30.00000 -1.00000000 378 22 26.00000 -4.00000000 379 33 34.81250 -1.81250000 380 37 37.28571 -0.28571429 381 40 41.23529 -1.23529412 382 37 40.00000 -3.00000000 383 30 34.77419 -4.77419355 384 36 36.44828 -0.44827586 385 36 37.15385 -1.15384615 386 37 39.03571 -2.03571429 387 31 33.47368 -2.47368421 388 48 42.88235 5.11764706 389 39 36.20833 2.79166667 390 42 39.65217 2.34782609 391 36 36.31579 -0.31578947 392 39 36.44828 2.55172414 393 36 33.47368 2.52631579 394 38 42.88235 -4.88235294 395 47 42.88235 4.11764706 396 36 34.44444 1.55555556 397 36 36.31579 -0.31578947 398 38 36.20833 1.79166667 399 39 42.88235 -3.88235294 400 37 33.47368 3.52631579 401 38 36.31579 1.68421053 402 39 39.03571 -0.03571429 403 36 36.31579 -0.31578947 404 36 36.44828 -0.44827586 405 38 37.15385 0.84615385 406 35 36.44828 -1.44827586 407 40 41.23529 -1.23529412 408 38 36.20833 1.79166667 409 38 33.11111 4.88888889 410 37 36.20833 0.79166667 411 37 37.28571 -0.28571429 412 38 39.65217 -1.65217391 413 33 33.47368 -0.47368421 414 33 36.20833 -3.20833333 415 36 36.20833 -0.20833333 416 35 36.44828 -1.44827586 417 31 33.47368 -2.47368421 418 33 31.95652 1.04347826 419 36 36.20833 -0.20833333 420 41 41.23529 -0.23529412 421 38 37.28571 0.71428571 422 37 36.44828 0.55172414 423 33 32.23077 0.76923077 424 30 31.30000 -1.30000000 425 43 41.23529 1.76470588 426 41 39.65217 1.34782609 427 38 36.31579 1.68421053 428 40 39.65217 0.34782609 429 35 36.44828 -1.44827586 430 35 31.30000 3.70000000 431 37 36.20833 0.79166667 432 35 33.47368 1.52631579 433 35 36.31579 -1.31578947 434 42 40.00000 2.00000000 435 37 39.03571 -2.03571429 436 41 39.03571 1.96428571 437 41 37.28571 3.71428571 438 34 36.31579 -2.31578947 439 32 33.47368 -1.47368421 440 40 41.23529 -1.23529412 441 35 36.44828 -1.44827586 442 32 36.20833 -4.20833333 443 46 39.03571 6.96428571 444 39 39.65217 -0.65217391 445 41 39.03571 1.96428571 446 34 36.31579 -2.31578947 447 36 37.40909 -1.40909091 448 38 36.31579 1.68421053 449 38 36.31579 1.68421053 450 32 33.47368 -1.47368421 451 41 41.23529 -0.23529412 452 29 30.00000 -1.00000000 453 21 26.00000 -5.00000000 454 34 36.44828 -2.44827586 455 36 37.40909 -1.40909091 > 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/4fnwb1336322366.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/5sdqe1336322366.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/6zowq1336322366.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/7opmw1336322366.tab") + } > > try(system("convert tmp/2o2fs1336322366.ps tmp/2o2fs1336322366.png",intern=TRUE)) character(0) > try(system("convert tmp/340171336322366.ps tmp/340171336322366.png",intern=TRUE)) character(0) > try(system("convert tmp/4fnwb1336322366.ps tmp/4fnwb1336322366.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 8.919 0.373 9.293