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 = 'bachelor' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'ATTLES connected' > par8 <- 'ATTLES connected' > par7 <- 'all' > par6 <- 'bachelor' > par5 <- 'all' > 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] 28 36 36 37 30 36 32 24 33 21 16 31 39 36 32 30 30 38 34 34 26 21 35 39 35 [26] 32 35 36 34 19 36 27 34 34 32 37 38 33 37 30 24 22 30 36 36 30 26 33 36 31 [51] 34 37 33 37 35 31 35 26 27 38 36 28 41 33 32 34 35 29 36 32 29 38 40 34 34 [76] 38 32 38 33 34 37 34 32 37 34 33 34 35 32 28 32 31 32 35 33 35 37 35 38 34 [101] 35 21 36 24 34 21 33 41 41 30 34 31 27 34 38 39 22 32 29 33 30 39 39 33 32 [126] 32 30 35 31 33 27 28 33 35 36 34 29 34 31 38 38 31 35 36 40 31 33 37 42 41 [151] 38 39 29 37 39 38 42 40 30 42 37 35 36 34 39 33 44 39 29 30 40 37 35 33 34 [176] 35 39 37 38 42 34 39 40 36 34 42 41 33 30 34 36 33 35 37 31 35 42 36 39 39 [201] 38 37 37 32 32 43 31 44 35 30 38 32 34 38 33 37 42 49 38 30 35 42 31 40 30 [226] 32 35 35 39 34 34 37 37 34 41 38 37 36 35 40 38 37 38 37 30 33 36 27 36 38 [251] 28 39 42 31 38 33 40 37 36 37 36 38 41 33 40 30 35 32 38 43 25 35 38 37 37 [276] 33 30 32 37 38 30 38 35 38 32 34 36 28 40 36 36 36 37 29 40 35 36 41 40 40 [301] 36 34 22 39 35 40 38 35 36 35 36 26 35 36 34 33 35 32 39 49 36 41 38 37 35 [326] 35 36 40 42 37 45 42 39 36 32 39 32 38 41 36 37 35 35 39 39 39 42 25 35 38 [351] 42 34 26 34 26 33 36 36 38 35 33 39 32 40 42 38 34 38 37 38 41 37 38 36 33 [376] 33 36 35 31 36 33 34 34 30 35 36 32 41 42 38 38 37 33 30 43 41 30 38 40 35 [401] 35 37 33 35 35 42 40 33 37 38 26 41 42 41 34 32 34 40 36 35 36 32 46 29 44 [426] 39 33 34 41 34 36 38 33 38 32 41 38 41 32 29 31 21 34 30 37 30 18 31 48 33 [451] 36 37 > 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 5 3 3 2 7 5 6 9 24 16 30 35 41 46 46 38 44 24 19 18 17 3 3 45 46 48 49 1 1 1 2 > colnames(x) [1] "endo" "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" [11] "A10" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 28 36 36 37 30 36 32 24 33 21 16 31 39 36 32 30 30 38 34 34 26 21 35 39 35 [26] 32 35 36 34 19 36 27 34 34 32 37 38 33 37 30 24 22 30 36 36 30 26 33 36 31 [51] 34 37 33 37 35 31 35 26 27 38 36 28 41 33 32 34 35 29 36 32 29 38 40 34 34 [76] 38 32 38 33 34 37 34 32 37 34 33 34 35 32 28 32 31 32 35 33 35 37 35 38 34 [101] 35 21 36 24 34 21 33 41 41 30 34 31 27 34 38 39 22 32 29 33 30 39 39 33 32 [126] 32 30 35 31 33 27 28 33 35 36 34 29 34 31 38 38 31 35 36 40 31 33 37 42 41 [151] 38 39 29 37 39 38 42 40 30 42 37 35 36 34 39 33 44 39 29 30 40 37 35 33 34 [176] 35 39 37 38 42 34 39 40 36 34 42 41 33 30 34 36 33 35 37 31 35 42 36 39 39 [201] 38 37 37 32 32 43 31 44 35 30 38 32 34 38 33 37 42 49 38 30 35 42 31 40 30 [226] 32 35 35 39 34 34 37 37 34 41 38 37 36 35 40 38 37 38 37 30 33 36 27 36 38 [251] 28 39 42 31 38 33 40 37 36 37 36 38 41 33 40 30 35 32 38 43 25 35 38 37 37 [276] 33 30 32 37 38 30 38 35 38 32 34 36 28 40 36 36 36 37 29 40 35 36 41 40 40 [301] 36 34 22 39 35 40 38 35 36 35 36 26 35 36 34 33 35 32 39 49 36 41 38 37 35 [326] 35 36 40 42 37 45 42 39 36 32 39 32 38 41 36 37 35 35 39 39 39 42 25 35 38 [351] 42 34 26 34 26 33 36 36 38 35 33 39 32 40 42 38 34 38 37 38 41 37 38 36 33 [376] 33 36 35 31 36 33 34 34 30 35 36 32 41 42 38 38 37 33 30 43 41 30 38 40 35 [401] 35 37 33 35 35 42 40 33 37 38 26 41 42 41 34 32 34 40 36 35 36 32 46 29 44 [426] 39 33 34 41 34 36 38 33 38 32 41 38 41 32 29 31 21 34 30 37 30 18 31 48 33 [451] 36 37 > 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/1nkav1335897098.tab") + } + } > m Conditional inference tree with 26 terminal nodes Response: endo Inputs: A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 Number of observations: 452 1) A8 <= 3; criterion = 1, statistic = 171.672 2) A6 <= 2; criterion = 1, statistic = 50.634 3) A1 <= 2; criterion = 0.989, statistic = 10.586 4)* weights = 10 3) A1 > 2 5)* weights = 17 2) A6 > 2 6) A3 <= 3; criterion = 1, statistic = 24.218 7) A10 <= 3; criterion = 0.979, statistic = 9.438 8)* weights = 14 7) A10 > 3 9)* weights = 12 6) A3 > 3 10) A2 <= 2; criterion = 0.999, statistic = 14.685 11)* weights = 15 10) A2 > 2 12) A5 <= 3; criterion = 0.994, statistic = 11.757 13)* weights = 7 12) A5 > 3 14)* weights = 28 1) A8 > 3 15) A6 <= 3; criterion = 1, statistic = 79.294 16) A10 <= 3; criterion = 1, statistic = 19.331 17)* weights = 18 16) A10 > 3 18) A7 <= 4; criterion = 1, statistic = 18.813 19) A9 <= 2; criterion = 0.999, statistic = 15.299 20)* weights = 25 19) A9 > 2 21) A2 <= 3; criterion = 0.989, statistic = 10.659 22)* weights = 19 21) A2 > 3 23)* weights = 11 18) A7 > 4 24)* weights = 8 15) A6 > 3 25) A9 <= 2; criterion = 1, statistic = 62.917 26) A2 <= 2; criterion = 1, statistic = 26.591 27) A3 <= 3; criterion = 1, statistic = 16.91 28)* weights = 14 27) A3 > 3 29) A5 <= 4; criterion = 0.992, statistic = 11.146 30)* weights = 29 29) A5 > 4 31)* weights = 11 26) A2 > 2 32) A1 <= 3; criterion = 1, statistic = 19.32 33)* weights = 22 32) A1 > 3 34)* weights = 40 25) A9 > 2 35) A7 <= 4; criterion = 1, statistic = 41.655 36) A4 <= 3; criterion = 1, statistic = 28.762 37) A8 <= 4; criterion = 1, statistic = 20.139 38) A3 <= 3; criterion = 0.997, statistic = 12.813 39)* weights = 13 38) A3 > 3 40) A7 <= 3; criterion = 0.992, statistic = 11.173 41)* weights = 14 40) A7 > 3 42)* weights = 22 37) A8 > 4 43)* weights = 10 36) A4 > 3 44) A1 <= 3; criterion = 1, statistic = 20.746 45)* weights = 25 44) A1 > 3 46) A2 <= 3; criterion = 0.997, statistic = 13.083 47)* weights = 14 46) A2 > 3 48)* weights = 20 35) A7 > 4 49) A4 <= 3; criterion = 0.994, statistic = 11.792 50)* weights = 14 49) A4 > 3 51)* weights = 20 > postscript(file="/var/wessaorg/rcomp/tmp/2em511335897098.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/387rw1335897098.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 28 31.57143 -3.57142857 2 36 34.50000 1.50000000 3 36 35.42857 0.57142857 4 37 35.42857 1.57142857 5 30 31.86667 -1.86666667 6 36 37.57500 -1.57500000 7 32 33.93103 -1.93103448 8 24 22.30000 1.70000000 9 33 32.44000 0.56000000 10 21 22.30000 -1.30000000 11 16 22.30000 -6.30000000 12 31 31.91667 -0.91666667 13 39 39.00000 0.00000000 14 36 38.35714 -2.35714286 15 32 34.86364 -2.86363636 16 30 30.38889 -0.38888889 17 30 31.91667 -1.91666667 18 38 36.63636 1.36363636 19 34 33.93103 0.06896552 20 34 33.93103 0.06896552 21 26 22.30000 3.70000000 22 21 27.23529 -6.23529412 23 35 37.57500 -2.57500000 24 39 35.42857 3.57142857 25 35 33.93103 1.06896552 26 32 36.45455 -4.45454545 27 35 33.93103 1.06896552 28 36 35.42857 0.57142857 29 34 32.44000 1.56000000 30 19 22.30000 -3.30000000 31 36 32.44000 3.56000000 32 27 32.44000 -5.44000000 33 34 33.93103 0.06896552 34 34 35.42857 -1.42857143 35 32 32.44000 -0.44000000 36 37 32.85714 4.14285714 37 38 35.42857 2.57142857 38 33 33.61538 -0.61538462 39 37 36.63636 0.36363636 40 30 31.91667 -1.91666667 41 24 27.23529 -3.23529412 42 22 27.23529 -5.23529412 43 30 32.44000 -2.44000000 44 36 33.93103 2.06896552 45 36 35.42857 0.57142857 46 30 31.91667 -1.91666667 47 26 31.57143 -5.57142857 48 33 34.00000 -1.00000000 49 36 33.93103 2.06896552 50 31 32.85714 -1.85714286 51 34 35.42857 -1.42857143 52 37 36.63636 0.36363636 53 33 31.86667 1.13333333 54 37 36.63636 0.36363636 55 35 37.57500 -2.57500000 56 31 37.57500 -6.57500000 57 35 34.86364 0.13636364 58 26 30.38889 -4.38888889 59 27 29.35714 -2.35714286 60 38 37.57500 0.42500000 61 36 36.45455 -0.45454545 62 28 31.57143 -3.57142857 63 41 39.60000 1.40000000 64 33 33.61538 -0.61538462 65 32 34.50000 -2.50000000 66 34 33.61538 0.38461538 67 35 33.61538 1.38461538 68 29 31.57143 -2.57142857 69 36 35.42857 0.57142857 70 32 33.93103 -1.93103448 71 29 33.93103 -4.93103448 72 38 36.63636 1.36363636 73 40 37.57500 2.42500000 74 34 33.93103 0.06896552 75 34 31.86667 2.13333333 76 38 37.57500 0.42500000 77 32 31.57143 0.42857143 78 38 39.60000 -1.60000000 79 33 33.93103 -0.93103448 80 34 35.42857 -1.42857143 81 37 35.42857 1.57142857 82 34 32.44000 1.56000000 83 32 34.50000 -2.50000000 84 37 33.93103 3.06896552 85 34 31.57143 2.42857143 86 33 30.38889 2.61111111 87 34 33.61538 0.38461538 88 35 31.86667 3.13333333 89 32 32.44000 -0.44000000 90 28 30.38889 -2.38888889 91 32 34.00000 -2.00000000 92 31 33.93103 -2.93103448 93 32 33.93103 -1.93103448 94 35 36.63636 -1.63636364 95 33 31.57143 1.42857143 96 35 31.91667 3.08333333 97 37 37.57500 -0.57500000 98 35 37.57500 -2.57500000 99 38 36.63636 1.36363636 100 34 37.57500 -3.57500000 101 35 33.93103 1.06896552 102 21 29.35714 -8.35714286 103 36 36.63636 -0.63636364 104 24 30.38889 -6.38888889 105 34 36.45455 -2.45454545 106 21 22.30000 -1.30000000 107 33 33.93103 -0.93103448 108 41 39.85714 1.14285714 109 41 39.85714 1.14285714 110 30 30.38889 -0.38888889 111 34 31.57143 2.42857143 112 31 31.57143 -0.57142857 113 27 30.38889 -3.38888889 114 34 32.85714 1.14285714 115 38 39.00000 -1.00000000 116 39 34.86364 4.13636364 117 22 27.23529 -5.23529412 118 32 32.44000 -0.44000000 119 29 29.35714 -0.35714286 120 33 31.86667 1.13333333 121 30 35.42857 -5.42857143 122 39 36.63636 2.36363636 123 39 40.85000 -1.85000000 124 33 33.93103 -0.93103448 125 32 33.61538 -1.61538462 126 32 33.93103 -1.93103448 127 30 30.38889 -0.38888889 128 35 31.57143 3.42857143 129 31 31.91667 -0.91666667 130 33 31.86667 1.13333333 131 27 27.23529 -0.23529412 132 28 29.35714 -1.35714286 133 33 31.86667 1.13333333 134 35 36.63636 -1.63636364 135 36 36.63636 -0.63636364 136 34 39.60000 -5.60000000 137 29 34.86364 -5.86363636 138 34 31.86667 2.13333333 139 31 31.91667 -0.91666667 140 38 37.57500 0.42500000 141 38 36.63636 1.36363636 142 31 34.00000 -3.00000000 143 35 34.86364 0.13636364 144 36 35.42857 0.57142857 145 40 37.57500 2.42500000 146 31 31.86667 -0.86666667 147 33 34.00000 -1.00000000 148 37 34.50000 2.50000000 149 42 38.35714 3.64285714 150 41 42.35000 -1.35000000 151 38 36.45455 1.54545455 152 39 34.00000 5.00000000 153 29 27.23529 1.76470588 154 37 39.00000 -2.00000000 155 39 37.57500 1.42500000 156 38 35.42857 2.57142857 157 42 40.85000 1.15000000 158 40 42.35000 -2.35000000 159 30 31.57143 -1.57142857 160 42 42.35000 -0.35000000 161 37 37.57500 -0.57500000 162 35 34.86364 0.13636364 163 36 33.93103 2.06896552 164 34 35.42857 -1.42857143 165 39 39.60000 -0.60000000 166 33 34.50000 -1.50000000 167 44 42.35000 1.65000000 168 39 36.45455 2.54545455 169 29 32.85714 -3.85714286 170 30 29.35714 0.64285714 171 40 40.85000 -0.85000000 172 37 38.35714 -1.35714286 173 35 33.93103 1.06896552 174 33 27.23529 5.76470588 175 34 32.44000 1.56000000 176 35 33.93103 1.06896552 177 39 42.35000 -3.35000000 178 37 37.57500 -0.57500000 179 38 36.45455 1.54545455 180 42 40.85000 1.15000000 181 34 33.93103 0.06896552 182 39 35.42857 3.57142857 183 40 37.57500 2.42500000 184 36 37.57500 -1.57500000 185 34 36.63636 -2.63636364 186 42 38.35714 3.64285714 187 41 39.60000 1.40000000 188 33 31.86667 1.13333333 189 30 32.44000 -2.44000000 190 34 35.42857 -1.42857143 191 36 31.91667 4.08333333 192 33 32.44000 0.56000000 193 35 37.57500 -2.57500000 194 37 31.57143 5.42857143 195 31 31.91667 -0.91666667 196 35 36.92000 -1.92000000 197 42 42.35000 -0.35000000 198 36 38.35714 -2.35714286 199 39 37.57500 1.42500000 200 39 39.00000 0.00000000 201 38 34.50000 3.50000000 202 37 37.57500 -0.57500000 203 37 33.93103 3.06896552 204 32 31.57143 0.42857143 205 32 32.44000 -0.44000000 206 43 42.35000 0.65000000 207 31 29.35714 1.64285714 208 44 39.85714 4.14285714 209 35 37.57500 -2.57500000 210 30 27.23529 2.76470588 211 38 37.57500 0.42500000 212 32 32.44000 -0.44000000 213 34 34.00000 0.00000000 214 38 34.50000 3.50000000 215 33 32.44000 0.56000000 216 37 36.63636 0.36363636 217 42 42.35000 -0.35000000 218 49 40.85000 8.15000000 219 38 37.57500 0.42500000 220 30 31.91667 -1.91666667 221 35 36.45455 -1.45454545 222 42 39.00000 3.00000000 223 31 33.61538 -2.61538462 224 40 39.85714 0.14285714 225 30 30.38889 -0.38888889 226 32 31.86667 0.13333333 227 35 33.93103 1.06896552 228 35 34.86364 0.13636364 229 39 37.57500 1.42500000 230 34 33.93103 0.06896552 231 34 32.44000 1.56000000 232 37 36.45455 0.54545455 233 37 36.45455 0.54545455 234 34 33.61538 0.38461538 235 41 40.85000 0.15000000 236 38 36.63636 1.36363636 237 37 35.42857 1.57142857 238 36 37.57500 -1.57500000 239 35 32.85714 2.14285714 240 40 38.35714 1.64285714 241 38 35.42857 2.57142857 242 37 37.57500 -0.57500000 243 38 36.63636 1.36363636 244 37 36.45455 0.54545455 245 30 29.35714 0.64285714 246 33 32.44000 0.56000000 247 36 36.92000 -0.92000000 248 27 31.86667 -4.86666667 249 36 33.61538 2.38461538 250 38 38.35714 -0.35714286 251 28 30.38889 -2.38888889 252 39 37.57500 1.42500000 253 42 39.00000 3.00000000 254 31 34.00000 -3.00000000 255 38 37.27273 0.72727273 256 33 33.93103 -0.93103448 257 40 34.86364 5.13636364 258 37 35.42857 1.57142857 259 36 36.92000 -0.92000000 260 37 36.92000 0.08000000 261 36 38.35714 -2.35714286 262 38 38.35714 -0.35714286 263 41 39.85714 1.14285714 264 33 33.93103 -0.93103448 265 40 40.85000 -0.85000000 266 30 34.00000 -4.00000000 267 35 34.00000 1.00000000 268 32 35.42857 -3.42857143 269 38 37.57500 0.42500000 270 43 37.57500 5.42500000 271 25 27.23529 -2.23529412 272 35 34.00000 1.00000000 273 38 36.92000 1.08000000 274 37 37.27273 -0.27272727 275 37 37.57500 -0.57500000 276 33 35.42857 -2.42857143 277 30 34.86364 -4.86363636 278 32 32.85714 -0.85714286 279 37 36.92000 0.08000000 280 38 39.85714 -1.85714286 281 30 31.86667 -1.86666667 282 38 36.92000 1.08000000 283 35 34.00000 1.00000000 284 38 34.86364 3.13636364 285 32 32.85714 -0.85714286 286 34 36.92000 -2.92000000 287 36 30.38889 5.61111111 288 28 27.23529 0.76470588 289 40 36.92000 3.08000000 290 36 37.27273 -1.27272727 291 36 36.63636 -0.63636364 292 36 37.27273 -1.27272727 293 37 34.00000 3.00000000 294 29 31.86667 -2.86666667 295 40 40.85000 -0.85000000 296 35 33.93103 1.06896552 297 36 36.63636 -0.63636364 298 41 37.57500 3.42500000 299 40 39.85714 0.14285714 300 40 36.92000 3.08000000 301 36 36.63636 -0.63636364 302 34 34.00000 0.00000000 303 22 29.35714 -7.35714286 304 39 36.92000 2.08000000 305 35 36.63636 -1.63636364 306 40 39.60000 0.40000000 307 38 37.27273 0.72727273 308 35 39.00000 -4.00000000 309 36 36.92000 -0.92000000 310 35 35.42857 -0.42857143 311 36 32.44000 3.56000000 312 26 22.30000 3.70000000 313 35 36.92000 -1.92000000 314 36 37.57500 -1.57500000 315 34 34.50000 -0.50000000 316 33 31.57143 1.42857143 317 35 34.86364 0.13636364 318 32 34.00000 -2.00000000 319 39 37.57500 1.42500000 320 49 42.35000 6.65000000 321 36 35.42857 0.57142857 322 41 39.60000 1.40000000 323 38 40.85000 -2.85000000 324 37 37.57500 -0.57500000 325 35 36.92000 -1.92000000 326 35 34.00000 1.00000000 327 36 36.63636 -0.63636364 328 40 39.85714 0.14285714 329 42 42.35000 -0.35000000 330 37 39.85714 -2.85714286 331 45 40.85000 4.15000000 332 42 42.35000 -0.35000000 333 39 39.60000 -0.60000000 334 36 34.86364 1.13636364 335 32 32.44000 -0.44000000 336 39 38.35714 0.64285714 337 32 35.42857 -3.42857143 338 38 34.86364 3.13636364 339 41 40.85000 0.15000000 340 36 34.86364 1.13636364 341 37 33.61538 3.38461538 342 35 36.92000 -1.92000000 343 35 34.00000 1.00000000 344 39 38.35714 0.64285714 345 39 36.92000 2.08000000 346 39 40.85000 -1.85000000 347 42 40.85000 1.15000000 348 25 30.38889 -5.38888889 349 35 34.50000 0.50000000 350 38 37.57500 0.42500000 351 42 39.60000 2.40000000 352 34 34.86364 -0.86363636 353 26 27.23529 -1.23529412 354 34 34.86364 -0.86363636 355 26 22.30000 3.70000000 356 33 30.38889 2.61111111 357 36 31.91667 4.08333333 358 36 34.50000 1.50000000 359 38 37.57500 0.42500000 360 35 34.50000 0.50000000 361 33 30.38889 2.61111111 362 39 40.85000 -1.85000000 363 32 34.50000 -2.50000000 364 40 39.00000 1.00000000 365 42 39.85714 2.14285714 366 38 37.27273 0.72727273 367 34 34.86364 -0.86363636 368 38 36.45455 1.54545455 369 37 37.27273 -0.27272727 370 38 39.85714 -1.85714286 371 41 39.85714 1.14285714 372 37 39.85714 -2.85714286 373 38 38.35714 -0.35714286 374 36 38.35714 -2.35714286 375 33 32.44000 0.56000000 376 33 30.38889 2.61111111 377 36 37.27273 -1.27272727 378 35 34.86364 0.13636364 379 31 29.35714 1.64285714 380 36 36.92000 -0.92000000 381 33 29.35714 3.64285714 382 34 35.42857 -1.42857143 383 34 33.61538 0.38461538 384 30 29.35714 0.64285714 385 35 34.50000 0.50000000 386 36 37.27273 -1.27272727 387 32 31.91667 0.08333333 388 41 42.35000 -1.35000000 389 42 40.85000 1.15000000 390 38 39.85714 -1.85714286 391 38 36.92000 1.08000000 392 37 36.92000 0.08000000 393 33 34.00000 -1.00000000 394 30 34.50000 -4.50000000 395 43 42.35000 0.65000000 396 41 39.60000 1.40000000 397 30 32.44000 -2.44000000 398 38 40.85000 -2.85000000 399 40 38.35714 1.64285714 400 35 36.92000 -1.92000000 401 35 34.00000 1.00000000 402 37 34.00000 3.00000000 403 33 32.44000 0.56000000 404 35 30.38889 4.61111111 405 35 34.86364 0.13636364 406 42 37.57500 4.42500000 407 40 37.57500 2.42500000 408 33 29.35714 3.64285714 409 37 42.35000 -5.35000000 410 38 37.57500 0.42500000 411 26 22.30000 3.70000000 412 41 40.85000 0.15000000 413 42 40.85000 1.15000000 414 41 36.92000 4.08000000 415 34 34.86364 -0.86363636 416 32 27.23529 4.76470588 417 34 35.42857 -1.42857143 418 40 42.35000 -2.35000000 419 36 36.92000 -0.92000000 420 35 33.61538 1.38461538 421 36 29.35714 6.64285714 422 32 27.23529 4.76470588 423 46 42.35000 3.65000000 424 29 33.61538 -4.61538462 425 44 42.35000 1.65000000 426 39 40.85000 -1.85000000 427 33 30.38889 2.61111111 428 34 36.92000 -2.92000000 429 41 42.35000 -1.35000000 430 34 34.86364 -0.86363636 431 36 36.63636 -0.63636364 432 38 36.92000 1.08000000 433 33 32.44000 0.56000000 434 38 36.92000 1.08000000 435 32 32.44000 -0.44000000 436 41 42.35000 -1.35000000 437 38 40.85000 -2.85000000 438 41 37.27273 3.72727273 439 32 27.23529 4.76470588 440 29 27.23529 1.76470588 441 31 31.86667 -0.86666667 442 21 27.23529 -6.23529412 443 34 34.86364 -0.86363636 444 30 29.35714 0.64285714 445 37 37.27273 -0.27272727 446 30 27.23529 2.76470588 447 18 22.30000 -4.30000000 448 31 32.44000 -1.44000000 449 48 42.35000 5.65000000 450 33 30.38889 2.61111111 451 36 35.42857 0.57142857 452 37 37.57500 -0.57500000 > 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/4racn1335897098.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/58keq1335897098.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/69wg11335897098.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/79lr81335897098.tab") + } > > try(system("convert tmp/2em511335897098.ps tmp/2em511335897098.png",intern=TRUE)) character(0) > try(system("convert tmp/387rw1335897098.ps tmp/387rw1335897098.png",intern=TRUE)) character(0) > try(system("convert tmp/4racn1335897098.ps tmp/4racn1335897098.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 9.086 0.428 9.512