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 = 'male' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'ATTLES connected' > par8 <- 'ATTLES connected' > par7 <- 'all' > par6 <- 'all' > par5 <- 'male' > 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] 38 37 38 34 38 36 36 36 37 34 35 37 39 39 36 34 35 29 33 31 31 41 34 32 32 [26] 39 33 34 39 39 40 32 33 41 31 33 44 29 34 39 34 32 29 33 34 37 35 31 32 33 [51] 37 30 43 31 37 33 38 39 32 34 30 30 33 35 33 40 32 31 29 37 39 37 34 37 38 [76] 33 30 33 42 38 35 35 32 36 36 34 31 38 36 35 32 33 38 38 35 32 31 28 36 36 [101] 30 36 33 16 31 39 32 30 34 34 26 21 35 35 34 19 36 32 33 37 22 33 31 33 31 [126] 26 27 38 34 32 38 33 34 37 33 34 35 32 32 33 35 38 36 24 34 41 34 39 32 29 [151] 33 30 39 39 32 35 36 34 29 34 31 38 36 33 37 36 34 30 38 40 37 43 30 36 43 [176] 36 47 37 40 27 36 33 35 44 37 43 42 39 26 36 42 43 35 32 31 47 34 28 39 36 [201] 25 32 36 34 44 30 39 41 41 36 30 44 40 24 40 35 31 37 37 46 43 32 34 34 36 [226] 40 26 34 47 40 41 37 36 32 33 29 39 33 29 37 40 45 44 41 39 29 37 39 42 42 [251] 37 35 33 39 29 30 35 33 34 35 37 42 39 40 42 41 30 34 36 35 42 39 38 37 43 [276] 44 38 38 33 37 42 30 42 31 40 30 32 39 34 37 37 38 37 36 35 40 37 30 33 28 [301] 41 33 33 31 37 39 33 27 30 33 38 36 40 39 36 37 33 40 34 35 48 38 30 32 34 [326] 28 40 36 36 38 34 41 27 40 40 38 26 35 40 37 35 34 38 37 33 39 40 36 36 38 [351] 40 38 37 39 35 38 37 35 27 41 45 29 35 38 37 35 31 40 38 42 40 26 27 43 40 [376] 36 35 34 31 33 40 36 36 33 40 30 35 32 25 38 37 33 30 38 38 34 36 28 40 36 [401] 29 40 36 41 40 36 22 35 40 38 35 33 39 49 36 41 35 35 42 37 36 39 32 37 35 [426] 39 39 25 35 38 42 34 26 34 26 41 32 26 42 38 34 37 32 37 35 29 35 34 38 34 [451] 37 39 36 39 33 32 33 36 36 27 36 38 34 31 28 38 39 38 42 40 39 43 33 45 36 [476] 41 40 40 32 24 43 34 42 46 38 36 29 32 43 34 37 37 36 34 35 33 38 41 41 38 [501] 34 29 34 34 45 33 39 32 42 34 38 41 36 36 34 34 30 35 32 42 38 30 33 40 33 [526] 38 26 42 34 36 36 29 44 33 34 33 38 41 32 31 30 37 30 18 31 48 33 37 37 48 > 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]) 16 18 19 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1 1 1 1 2 3 3 10 7 6 16 24 21 33 48 53 40 52 46 45 35 33 19 19 11 7 45 46 47 48 49 4 2 3 3 1 > colnames(x) [1] "endo" "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" [11] "A10" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 38 37 38 34 38 36 36 36 37 34 35 37 39 39 36 34 35 29 33 31 31 41 34 32 32 [26] 39 33 34 39 39 40 32 33 41 31 33 44 29 34 39 34 32 29 33 34 37 35 31 32 33 [51] 37 30 43 31 37 33 38 39 32 34 30 30 33 35 33 40 32 31 29 37 39 37 34 37 38 [76] 33 30 33 42 38 35 35 32 36 36 34 31 38 36 35 32 33 38 38 35 32 31 28 36 36 [101] 30 36 33 16 31 39 32 30 34 34 26 21 35 35 34 19 36 32 33 37 22 33 31 33 31 [126] 26 27 38 34 32 38 33 34 37 33 34 35 32 32 33 35 38 36 24 34 41 34 39 32 29 [151] 33 30 39 39 32 35 36 34 29 34 31 38 36 33 37 36 34 30 38 40 37 43 30 36 43 [176] 36 47 37 40 27 36 33 35 44 37 43 42 39 26 36 42 43 35 32 31 47 34 28 39 36 [201] 25 32 36 34 44 30 39 41 41 36 30 44 40 24 40 35 31 37 37 46 43 32 34 34 36 [226] 40 26 34 47 40 41 37 36 32 33 29 39 33 29 37 40 45 44 41 39 29 37 39 42 42 [251] 37 35 33 39 29 30 35 33 34 35 37 42 39 40 42 41 30 34 36 35 42 39 38 37 43 [276] 44 38 38 33 37 42 30 42 31 40 30 32 39 34 37 37 38 37 36 35 40 37 30 33 28 [301] 41 33 33 31 37 39 33 27 30 33 38 36 40 39 36 37 33 40 34 35 48 38 30 32 34 [326] 28 40 36 36 38 34 41 27 40 40 38 26 35 40 37 35 34 38 37 33 39 40 36 36 38 [351] 40 38 37 39 35 38 37 35 27 41 45 29 35 38 37 35 31 40 38 42 40 26 27 43 40 [376] 36 35 34 31 33 40 36 36 33 40 30 35 32 25 38 37 33 30 38 38 34 36 28 40 36 [401] 29 40 36 41 40 36 22 35 40 38 35 33 39 49 36 41 35 35 42 37 36 39 32 37 35 [426] 39 39 25 35 38 42 34 26 34 26 41 32 26 42 38 34 37 32 37 35 29 35 34 38 34 [451] 37 39 36 39 33 32 33 36 36 27 36 38 34 31 28 38 39 38 42 40 39 43 33 45 36 [476] 41 40 40 32 24 43 34 42 46 38 36 29 32 43 34 37 37 36 34 35 33 38 41 41 38 [501] 34 29 34 34 45 33 39 32 42 34 38 41 36 36 34 34 30 35 32 42 38 30 33 40 33 [526] 38 26 42 34 36 36 29 44 33 34 33 38 41 32 31 30 37 30 18 31 48 33 37 37 48 > 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/1l2zj1336322235.tab") + } + } > m Conditional inference tree with 35 terminal nodes Response: endo Inputs: A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 Number of observations: 550 1) A8 <= 3; criterion = 1, statistic = 187.18 2) A6 <= 2; criterion = 1, statistic = 42.474 3) A10 <= 2; criterion = 0.974, statistic = 9.012 4)* weights = 11 3) A10 > 2 5)* weights = 14 2) A6 > 2 6) A5 <= 3; criterion = 1, statistic = 31.016 7) A9 <= 2; criterion = 0.992, statistic = 11.197 8)* weights = 28 7) A9 > 2 9)* weights = 17 6) A5 > 3 10) A9 <= 1; criterion = 1, statistic = 17.646 11)* weights = 8 10) A9 > 1 12) A5 <= 4; criterion = 0.991, statistic = 11.086 13) A2 <= 2; criterion = 0.992, statistic = 11.134 14)* weights = 10 13) A2 > 2 15) A6 <= 3; criterion = 0.981, statistic = 9.626 16)* weights = 9 15) A6 > 3 17) A1 <= 3; criterion = 0.973, statistic = 8.953 18)* weights = 9 17) A1 > 3 19)* weights = 13 12) A5 > 4 20)* weights = 10 1) A8 > 3 21) A3 <= 4; criterion = 1, statistic = 122.749 22) A6 <= 3; criterion = 1, statistic = 85.718 23) A10 <= 2; criterion = 1, statistic = 31.52 24)* weights = 14 23) A10 > 2 25) A7 <= 3; criterion = 0.994, statistic = 11.696 26)* weights = 33 25) A7 > 3 27) A9 <= 2; criterion = 0.992, statistic = 11.354 28)* weights = 18 27) A9 > 2 29)* weights = 16 22) A6 > 3 30) A7 <= 3; criterion = 1, statistic = 76.07 31) A5 <= 2; criterion = 1, statistic = 18.341 32)* weights = 8 31) A5 > 2 33) A7 <= 2; criterion = 1, statistic = 16.782 34)* weights = 17 33) A7 > 2 35) A2 <= 2; criterion = 0.981, statistic = 9.586 36)* weights = 20 35) A2 > 2 37)* weights = 25 30) A7 > 3 38) A9 <= 2; criterion = 1, statistic = 40.474 39) A5 <= 4; criterion = 0.991, statistic = 11.047 40) A2 <= 3; criterion = 0.996, statistic = 12.494 41)* weights = 24 40) A2 > 3 42)* weights = 20 39) A5 > 4 43)* weights = 13 38) A9 > 2 44) A1 <= 3; criterion = 1, statistic = 21.072 45) A5 <= 4; criterion = 1, statistic = 17.457 46) A3 <= 3; criterion = 0.953, statistic = 7.971 47)* weights = 12 46) A3 > 3 48)* weights = 17 45) A5 > 4 49)* weights = 9 44) A1 > 3 50) A4 <= 3; criterion = 1, statistic = 20.298 51) A7 <= 4; criterion = 0.997, statistic = 13.156 52) A9 <= 3; criterion = 0.968, statistic = 8.685 53)* weights = 19 52) A9 > 3 54)* weights = 10 51) A7 > 4 55)* weights = 10 50) A4 > 3 56) A8 <= 4; criterion = 0.993, statistic = 11.611 57)* weights = 28 56) A8 > 4 58)* weights = 11 21) A3 > 4 59) A9 <= 2; criterion = 1, statistic = 38.764 60) A7 <= 2; criterion = 0.979, statistic = 9.476 61)* weights = 7 60) A7 > 2 62)* weights = 25 59) A9 > 2 63) A7 <= 4; criterion = 1, statistic = 26.017 64) A5 <= 4; criterion = 0.993, statistic = 11.357 65)* weights = 29 64) A5 > 4 66)* weights = 12 63) A7 > 4 67) A4 <= 4; criterion = 0.985, statistic = 10.054 68)* weights = 14 67) A4 > 4 69)* weights = 10 > postscript(file="/var/wessaorg/rcomp/tmp/232t91336322235.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/3cqn71336322235.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 38 36.40000 1.60000000 2 37 36.30769 0.69230769 3 38 37.53846 0.46153846 4 34 32.35294 1.64705882 5 38 37.53846 0.46153846 6 36 29.53571 6.46428571 7 36 36.78947 -0.78947368 8 36 36.00000 0.00000000 9 37 38.20000 -1.20000000 10 34 34.29167 -0.29166667 11 35 34.25000 0.75000000 12 37 36.82353 0.17647059 13 39 39.42857 -0.42857143 14 39 36.78947 2.21052632 15 36 32.90909 3.09090909 16 34 32.90909 1.09090909 17 35 32.47059 2.52941176 18 29 29.53571 -0.53571429 19 33 33.22222 -0.22222222 20 31 34.25000 -3.25000000 21 31 33.22222 -2.22222222 22 41 39.65517 1.34482759 23 34 34.25000 -0.25000000 24 32 36.82353 -4.82352941 25 32 28.85714 3.14285714 26 39 39.65517 -0.65517241 27 33 30.62500 2.37500000 28 34 34.29167 -0.29166667 29 39 36.30769 2.69230769 30 39 36.40000 2.60000000 31 40 41.81818 -1.81818182 32 32 33.22222 -1.22222222 33 33 31.90000 1.10000000 34 41 36.82353 4.17647059 35 31 32.90909 -1.90909091 36 33 33.22222 -0.22222222 37 44 41.91667 2.08333333 38 29 33.22222 -4.22222222 39 34 32.47059 1.52941176 40 39 39.65517 -0.65517241 41 34 33.22222 0.77777778 42 32 34.29167 -2.29166667 43 29 29.53571 -0.53571429 44 33 34.11111 -1.11111111 45 34 34.25000 -0.25000000 46 37 34.29167 2.70833333 47 35 34.29167 0.70833333 48 31 29.53571 1.46428571 49 32 34.25000 -2.25000000 50 33 34.29167 -1.29166667 51 37 36.30769 0.69230769 52 30 30.50000 -0.50000000 53 43 43.07143 -0.07142857 54 31 32.90909 -1.90909091 55 37 37.53846 -0.53846154 56 33 34.29167 -1.29166667 57 38 34.25000 3.75000000 58 39 36.37500 2.62500000 59 32 34.11111 -2.11111111 60 34 34.29167 -0.29166667 61 30 31.90000 -1.90000000 62 30 29.53571 0.46428571 63 33 36.37500 -3.37500000 64 35 38.04000 -3.04000000 65 33 29.53571 3.46428571 66 40 41.81818 -1.81818182 67 32 31.90000 0.10000000 68 31 29.28571 1.71428571 69 29 30.50000 -1.50000000 70 37 36.30769 0.69230769 71 39 38.04000 0.96000000 72 37 32.90909 4.09090909 73 34 36.37500 -2.37500000 74 37 37.10000 -0.10000000 75 38 37.10000 0.90000000 76 33 32.35294 0.64705882 77 30 28.85714 1.14285714 78 33 36.00000 -3.00000000 79 42 43.07143 -1.07142857 80 38 36.37500 1.62500000 81 35 34.11111 0.88888889 82 35 36.30769 -1.30769231 83 32 29.53571 2.46428571 84 36 39.65517 -3.65517241 85 36 36.78947 -0.78947368 86 34 34.25000 -0.25000000 87 31 29.53571 1.46428571 88 38 38.04000 -0.04000000 89 36 34.28571 1.71428571 90 35 29.28571 5.71428571 91 32 29.53571 2.46428571 92 33 33.22222 -0.22222222 93 38 36.40000 1.60000000 94 38 38.04000 -0.04000000 95 35 34.25000 0.75000000 96 32 29.53571 2.46428571 97 31 29.53571 1.46428571 98 28 30.62500 -2.62500000 99 36 36.00000 0.00000000 100 36 37.10000 -1.10000000 101 30 30.50000 -0.50000000 102 36 38.04000 -2.04000000 103 33 33.22222 -0.22222222 104 16 23.63636 -7.63636364 105 31 32.47059 -1.47058824 106 39 36.37500 2.62500000 107 32 36.40000 -4.40000000 108 30 28.85714 1.14285714 109 34 34.29167 -0.29166667 110 34 38.04000 -4.04000000 111 26 29.28571 -3.28571429 112 21 23.63636 -2.63636364 113 35 36.40000 -1.40000000 114 35 34.29167 0.70833333 115 34 33.22222 0.77777778 116 19 23.63636 -4.63636364 117 36 33.22222 2.77777778 118 32 33.22222 -1.22222222 119 33 36.00000 -3.00000000 120 37 36.78947 0.21052632 121 22 29.28571 -7.28571429 122 33 32.90909 0.09090909 123 31 29.53571 1.46428571 124 33 32.47059 0.52941176 125 31 30.62500 0.37500000 126 26 28.85714 -2.85714286 127 27 29.53571 -2.53571429 128 38 36.78947 1.21052632 129 34 31.90000 2.10000000 130 32 34.29167 -2.29166667 131 38 39.65517 -1.65517241 132 33 34.29167 -1.29166667 133 34 30.50000 3.50000000 134 37 37.10000 -0.10000000 135 33 32.90909 0.09090909 136 34 36.00000 -2.00000000 137 35 32.47059 2.52941176 138 32 32.90909 -0.90909091 139 32 32.90909 -0.90909091 140 33 34.25000 -1.25000000 141 35 34.29167 0.70833333 142 38 38.20000 -0.20000000 143 36 36.82353 -0.82352941 144 24 28.85714 -4.85714286 145 34 34.28571 -0.28571429 146 41 39.88889 1.11111111 147 34 34.29167 -0.29166667 148 39 37.53846 1.46153846 149 32 32.90909 -0.90909091 150 29 29.53571 -0.53571429 151 33 31.90000 1.10000000 152 30 32.44444 -2.44444444 153 39 36.78947 2.21052632 154 39 39.42857 -0.42857143 155 32 34.41667 -2.41666667 156 35 36.78947 -1.78947368 157 36 36.78947 -0.78947368 158 34 32.35294 1.64705882 159 29 32.35294 -3.35294118 160 34 31.90000 2.10000000 161 31 32.47059 -1.47058824 162 38 38.04000 -0.04000000 163 36 36.30769 -0.30769231 164 33 32.90909 0.09090909 165 37 36.00000 1.00000000 166 36 36.78947 -0.78947368 167 34 33.22222 0.77777778 168 30 34.28571 -4.28571429 169 38 39.90000 -1.90000000 170 40 41.91667 -1.91666667 171 37 39.42857 -2.42857143 172 43 38.20000 4.80000000 173 30 29.28571 0.71428571 174 36 34.25000 1.75000000 175 43 41.91667 1.08333333 176 36 36.78947 -0.78947368 177 47 46.00000 1.00000000 178 37 36.30769 0.69230769 179 40 37.53846 2.46153846 180 27 29.53571 -2.53571429 181 36 36.78947 -0.78947368 182 33 29.53571 3.46428571 183 35 36.78947 -1.78947368 184 44 43.07143 0.92857143 185 37 36.37500 0.62500000 186 43 41.81818 1.18181818 187 42 41.81818 0.18181818 188 39 39.42857 -0.42857143 189 26 28.85714 -2.85714286 190 36 34.25000 1.75000000 191 42 41.91667 0.08333333 192 43 43.07143 -0.07142857 193 35 36.37500 -1.37500000 194 32 32.44444 -0.44444444 195 31 28.85714 2.14285714 196 47 41.91667 5.08333333 197 34 31.90000 2.10000000 198 28 29.28571 -1.28571429 199 39 39.65517 -0.65517241 200 36 36.40000 -0.40000000 201 25 29.28571 -4.28571429 202 32 30.62500 1.37500000 203 36 36.00000 0.00000000 204 34 34.25000 -0.25000000 205 44 43.07143 0.92857143 206 30 31.90000 -1.90000000 207 39 41.91667 -2.91666667 208 41 39.42857 1.57142857 209 41 39.42857 1.57142857 210 36 32.90909 3.09090909 211 30 32.90909 -2.90909091 212 44 38.04000 5.96000000 213 40 39.42857 0.57142857 214 24 29.53571 -5.53571429 215 40 39.65517 0.34482759 216 35 34.29167 0.70833333 217 31 29.28571 1.71428571 218 37 38.04000 -1.04000000 219 37 38.20000 -1.20000000 220 46 46.00000 0.00000000 221 43 39.65517 3.34482759 222 32 34.28571 -2.28571429 223 34 34.25000 -0.25000000 224 34 38.04000 -4.04000000 225 36 37.53846 -1.53846154 226 40 39.65517 0.34482759 227 26 29.53571 -3.53571429 228 34 32.35294 1.64705882 229 47 46.00000 1.00000000 230 40 38.04000 1.96000000 231 41 39.90000 1.10000000 232 37 38.04000 -1.04000000 233 36 37.10000 -1.10000000 234 32 34.25000 -2.25000000 235 33 34.29167 -1.29166667 236 29 30.50000 -1.50000000 237 39 34.29167 4.70833333 238 33 32.47059 0.52941176 239 29 29.53571 -0.53571429 240 37 37.10000 -0.10000000 241 40 39.90000 0.10000000 242 45 46.00000 -1.00000000 243 44 43.07143 0.92857143 244 41 39.42857 1.57142857 245 39 41.91667 -2.91666667 246 29 23.63636 5.36363636 247 37 36.37500 0.62500000 248 39 36.00000 3.00000000 249 42 39.65517 2.34482759 250 42 41.81818 0.18181818 251 37 36.40000 0.60000000 252 35 36.40000 -1.40000000 253 33 30.62500 2.37500000 254 39 37.53846 1.46153846 255 29 29.53571 -0.53571429 256 30 31.90000 -1.90000000 257 35 34.29167 0.70833333 258 33 29.28571 3.71428571 259 34 32.90909 1.09090909 260 35 34.29167 0.70833333 261 37 36.40000 0.60000000 262 42 39.65517 2.34482759 263 39 37.10000 1.90000000 264 40 38.04000 1.96000000 265 42 39.42857 2.57142857 266 41 39.65517 1.34482759 267 30 32.90909 -2.90909091 268 34 34.11111 -0.11111111 269 36 36.30769 -0.30769231 270 35 36.00000 -1.00000000 271 42 41.81818 0.18181818 272 39 43.07143 -4.07142857 273 38 39.65517 -1.65517241 274 37 38.04000 -1.04000000 275 43 43.07143 -0.07142857 276 44 43.07143 0.92857143 277 38 38.04000 -0.04000000 278 38 34.25000 3.75000000 279 33 33.22222 -0.22222222 280 37 36.78947 0.21052632 281 42 43.07143 -1.07142857 282 30 32.47059 -2.47058824 283 42 43.07143 -1.07142857 284 31 32.35294 -1.35294118 285 40 43.07143 -3.07142857 286 30 28.85714 1.14285714 287 32 32.47059 -0.47058824 288 39 38.04000 0.96000000 289 34 34.28571 -0.28571429 290 37 38.04000 -1.04000000 291 37 37.53846 -0.53846154 292 38 36.78947 1.21052632 293 37 37.10000 -0.10000000 294 36 37.53846 -1.53846154 295 35 32.47059 2.52941176 296 40 39.42857 0.57142857 297 37 34.25000 2.75000000 298 30 32.47059 -2.47058824 299 33 32.90909 0.09090909 300 28 33.22222 -5.22222222 301 41 38.04000 2.96000000 302 33 34.41667 -1.41666667 303 33 34.29167 -1.29166667 304 31 30.50000 0.50000000 305 37 36.82353 0.17647059 306 39 33.22222 5.77777778 307 33 34.25000 -1.25000000 308 27 32.47059 -5.47058824 309 30 32.90909 -2.90909091 310 33 32.90909 0.09090909 311 38 36.00000 2.00000000 312 36 36.82353 -0.82352941 313 40 39.90000 0.10000000 314 39 38.20000 0.80000000 315 36 32.44444 3.55555556 316 37 36.37500 0.62500000 317 33 32.44444 0.55555556 318 40 39.88889 0.11111111 319 34 34.11111 -0.11111111 320 35 33.22222 1.77777778 321 48 46.00000 2.00000000 322 38 39.65517 -1.65517241 323 30 29.28571 0.71428571 324 32 29.53571 2.46428571 325 34 36.00000 -2.00000000 326 28 29.28571 -1.28571429 327 40 39.65517 0.34482759 328 36 32.90909 3.09090909 329 36 39.65517 -3.65517241 330 38 38.04000 -0.04000000 331 34 34.41667 -0.41666667 332 41 39.65517 1.34482759 333 27 28.85714 -1.85714286 334 40 39.90000 0.10000000 335 40 36.82353 3.17647059 336 38 39.42857 -1.42857143 337 26 28.85714 -2.85714286 338 35 28.85714 6.14285714 339 40 41.91667 -1.91666667 340 37 36.40000 0.60000000 341 35 34.11111 0.88888889 342 34 36.82353 -2.82352941 343 38 34.41667 3.58333333 344 37 39.42857 -2.42857143 345 33 34.25000 -1.25000000 346 39 39.42857 -0.42857143 347 40 39.88889 0.11111111 348 36 33.22222 2.77777778 349 36 36.00000 0.00000000 350 38 36.82353 1.17647059 351 40 41.91667 -1.91666667 352 38 36.37500 1.62500000 353 37 36.40000 0.60000000 354 39 41.91667 -2.91666667 355 35 36.00000 -1.00000000 356 38 36.82353 1.17647059 357 37 36.00000 1.00000000 358 35 32.90909 2.09090909 359 27 29.53571 -2.53571429 360 41 39.88889 1.11111111 361 45 41.91667 3.08333333 362 29 29.53571 -0.53571429 363 35 36.82353 -1.82352941 364 38 39.42857 -1.42857143 365 37 38.20000 -1.20000000 366 35 32.90909 2.09090909 367 31 29.28571 1.71428571 368 40 39.88889 0.11111111 369 38 36.00000 2.00000000 370 42 39.65517 2.34482759 371 40 38.04000 1.96000000 372 26 30.62500 -4.62500000 373 27 30.50000 -3.50000000 374 43 46.00000 -3.00000000 375 40 41.81818 -1.81818182 376 36 36.40000 -0.40000000 377 35 32.90909 2.09090909 378 34 37.53846 -3.53846154 379 31 36.37500 -5.37500000 380 33 34.29167 -1.29166667 381 40 36.00000 4.00000000 382 36 36.82353 -0.82352941 383 36 39.42857 -3.42857143 384 33 34.25000 -1.25000000 385 40 39.42857 0.57142857 386 30 32.90909 -2.90909091 387 35 32.90909 2.09090909 388 32 32.44444 -0.44444444 389 25 23.63636 1.36363636 390 38 36.82353 1.17647059 391 37 36.40000 0.60000000 392 33 32.44444 0.55555556 393 30 32.35294 -2.35294118 394 38 36.82353 1.17647059 395 38 39.65517 -1.65517241 396 34 32.35294 1.64705882 397 36 38.04000 -2.04000000 398 28 29.28571 -1.28571429 399 40 39.65517 0.34482759 400 36 39.65517 -3.65517241 401 29 31.90000 -2.90000000 402 40 39.42857 0.57142857 403 36 36.78947 -0.78947368 404 41 36.40000 4.60000000 405 40 39.90000 0.10000000 406 36 36.82353 -0.82352941 407 22 29.53571 -7.53571429 408 35 36.78947 -1.78947368 409 40 38.20000 1.80000000 410 38 36.37500 1.62500000 411 35 36.37500 -1.37500000 412 33 34.25000 -1.25000000 413 39 38.04000 0.96000000 414 49 46.00000 3.00000000 415 36 36.30769 -0.30769231 416 41 39.65517 1.34482759 417 35 34.41667 0.58333333 418 35 32.90909 2.09090909 419 42 39.42857 2.57142857 420 37 39.88889 -2.88888889 421 36 37.53846 -1.53846154 422 39 39.42857 -0.42857143 423 32 32.44444 -0.44444444 424 37 38.20000 -1.20000000 425 35 34.41667 0.58333333 426 39 39.42857 -0.42857143 427 39 39.65517 -0.65517241 428 25 28.85714 -3.85714286 429 35 32.35294 2.64705882 430 38 34.28571 3.71428571 431 42 39.65517 2.34482759 432 34 36.40000 -2.40000000 433 26 23.63636 2.36363636 434 34 36.40000 -2.40000000 435 26 23.63636 2.36363636 436 41 39.42857 1.57142857 437 32 32.47059 -0.47058824 438 26 29.53571 -3.53571429 439 42 37.10000 4.90000000 440 38 36.78947 1.21052632 441 34 34.11111 -0.11111111 442 37 36.37500 0.62500000 443 32 32.47059 -0.47058824 444 37 38.20000 -1.20000000 445 35 32.47059 2.52941176 446 29 32.90909 -3.90909091 447 35 34.41667 0.58333333 448 34 32.90909 1.09090909 449 38 39.42857 -1.42857143 450 34 32.35294 1.64705882 451 37 36.78947 0.21052632 452 39 39.90000 -0.90000000 453 36 39.65517 -3.65517241 454 39 36.78947 2.21052632 455 33 34.41667 -1.41666667 456 32 32.35294 -0.35294118 457 33 32.35294 0.64705882 458 36 36.30769 -0.30769231 459 36 36.00000 0.00000000 460 27 29.53571 -2.53571429 461 36 36.00000 0.00000000 462 38 39.42857 -1.42857143 463 34 32.44444 1.55555556 464 31 32.90909 -1.90909091 465 28 32.35294 -4.35294118 466 38 34.29167 3.70833333 467 39 38.04000 0.96000000 468 38 36.40000 1.60000000 469 42 39.88889 2.11111111 470 40 39.42857 0.57142857 471 39 39.42857 -0.42857143 472 43 46.00000 -3.00000000 473 33 30.62500 2.37500000 474 45 41.91667 3.08333333 475 36 36.30769 -0.30769231 476 41 38.04000 2.96000000 477 40 41.81818 -1.81818182 478 40 39.88889 0.11111111 479 32 36.40000 -4.40000000 480 24 23.63636 0.36363636 481 43 39.65517 3.34482759 482 34 32.35294 1.64705882 483 42 39.65517 2.34482759 484 46 41.81818 4.18181818 485 38 36.00000 2.00000000 486 36 38.04000 -2.04000000 487 29 28.85714 0.14285714 488 32 29.53571 2.46428571 489 43 41.81818 1.18181818 490 34 36.00000 -2.00000000 491 37 32.47059 4.52941176 492 37 38.20000 -1.20000000 493 36 34.28571 1.71428571 494 34 32.35294 1.64705882 495 35 36.00000 -1.00000000 496 33 34.29167 -1.29166667 497 38 36.82353 1.17647059 498 41 39.65517 1.34482759 499 41 39.42857 1.57142857 500 38 37.53846 0.46153846 501 34 32.90909 1.09090909 502 29 32.35294 -3.35294118 503 34 36.00000 -2.00000000 504 34 34.41667 -0.41666667 505 45 43.07143 1.92857143 506 33 28.85714 4.14285714 507 39 36.00000 3.00000000 508 32 32.35294 -0.35294118 509 42 39.90000 2.10000000 510 34 34.29167 -0.29166667 511 38 39.88889 -1.88888889 512 41 39.90000 1.10000000 513 36 36.00000 0.00000000 514 36 36.82353 -0.82352941 515 34 30.50000 3.50000000 516 34 34.41667 -0.41666667 517 30 32.47059 -2.47058824 518 35 36.00000 -1.00000000 519 32 37.10000 -5.10000000 520 42 39.42857 2.57142857 521 38 39.90000 -1.90000000 522 30 32.90909 -2.90909091 523 33 33.22222 -0.22222222 524 40 37.53846 2.46153846 525 33 36.30769 -3.30769231 526 38 36.40000 1.60000000 527 26 23.63636 2.36363636 528 42 41.81818 0.18181818 529 34 34.11111 -0.11111111 530 36 34.41667 1.58333333 531 36 34.11111 1.88888889 532 29 30.62500 -1.62500000 533 44 46.00000 -2.00000000 534 33 36.37500 -3.37500000 535 34 34.41667 -0.41666667 536 33 32.90909 0.09090909 537 38 39.42857 -1.42857143 538 41 36.37500 4.62500000 539 32 29.28571 2.71428571 540 31 29.53571 1.46428571 541 30 32.44444 -2.44444444 542 37 39.65517 -2.65517241 543 30 23.63636 6.36363636 544 18 23.63636 -5.63636364 545 31 32.90909 -1.90909091 546 48 46.00000 2.00000000 547 33 32.90909 0.09090909 548 37 36.30769 0.69230769 549 37 36.40000 0.60000000 550 48 43.07143 4.92857143 > 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/47l7h1336322235.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/5i5xs1336322235.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/629ea1336322235.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/7n1kl1336322235.tab") + } > > try(system("convert tmp/232t91336322235.ps tmp/232t91336322235.png",intern=TRUE)) character(0) > try(system("convert tmp/3cqn71336322235.ps tmp/3cqn71336322235.png",intern=TRUE)) character(0) > try(system("convert tmp/47l7h1336322235.ps tmp/47l7h1336322235.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 10.525 0.349 10.886