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 = '3' > par6 = 'all' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'ATTLES connected' > par8 <- 'ATTLES connected' > par7 <- '3' > par6 <- 'all' > 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] 34 38 38 30 27 37 31 34 38 34 28 38 36 36 40 34 38 36 32 36 37 30 34 32 35 [26] 38 31 32 37 36 32 36 38 38 39 27 39 36 34 35 29 33 35 32 33 32 37 37 37 39 [51] 31 31 33 37 36 32 41 34 38 32 32 32 39 33 34 39 39 37 40 39 32 34 30 33 41 [76] 31 35 33 44 29 34 38 39 37 28 34 41 32 29 39 33 37 38 35 34 37 35 31 32 33 [101] 37 30 29 43 32 31 37 31 33 38 39 32 32 34 30 30 33 35 37 33 40 36 32 31 29 [126] 37 39 37 37 34 35 37 38 33 30 32 33 42 38 35 35 28 32 36 36 34 31 38 35 36 [151] 35 32 33 38 38 35 32 31 28 36 36 37 30 36 32 24 33 21 16 31 39 36 32 30 30 [176] 38 34 34 26 21 35 39 35 32 35 36 34 19 36 27 34 34 32 37 38 33 37 30 24 22 [201] 30 36 36 30 26 33 36 31 34 37 33 37 35 31 35 26 27 38 36 28 41 33 32 34 35 [226] 29 36 32 29 38 40 34 34 38 32 38 33 34 37 34 32 37 34 33 34 35 32 28 32 31 [251] 32 35 33 35 37 35 38 34 35 21 36 24 34 21 33 41 41 30 34 31 27 34 38 39 22 [276] 32 29 33 30 39 39 33 32 32 30 35 31 33 27 28 33 35 36 34 29 34 31 38 38 31 [301] 35 36 40 31 33 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 19 21 22 24 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1 1 4 2 3 3 6 7 9 16 20 35 28 34 27 26 27 27 16 5 6 1 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 38 30 27 37 31 34 38 34 28 38 36 36 40 34 38 36 32 36 37 30 34 32 35 [26] 38 31 32 37 36 32 36 38 38 39 27 39 36 34 35 29 33 35 32 33 32 37 37 37 39 [51] 31 31 33 37 36 32 41 34 38 32 32 32 39 33 34 39 39 37 40 39 32 34 30 33 41 [76] 31 35 33 44 29 34 38 39 37 28 34 41 32 29 39 33 37 38 35 34 37 35 31 32 33 [101] 37 30 29 43 32 31 37 31 33 38 39 32 32 34 30 30 33 35 37 33 40 36 32 31 29 [126] 37 39 37 37 34 35 37 38 33 30 32 33 42 38 35 35 28 32 36 36 34 31 38 35 36 [151] 35 32 33 38 38 35 32 31 28 36 36 37 30 36 32 24 33 21 16 31 39 36 32 30 30 [176] 38 34 34 26 21 35 39 35 32 35 36 34 19 36 27 34 34 32 37 38 33 37 30 24 22 [201] 30 36 36 30 26 33 36 31 34 37 33 37 35 31 35 26 27 38 36 28 41 33 32 34 35 [226] 29 36 32 29 38 40 34 34 38 32 38 33 34 37 34 32 37 34 33 34 35 32 28 32 31 [251] 32 35 33 35 37 35 38 34 35 21 36 24 34 21 33 41 41 30 34 31 27 34 38 39 22 [276] 32 29 33 30 39 39 33 32 32 30 35 31 33 27 28 33 35 36 34 29 34 31 38 38 31 [301] 35 36 40 31 33 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/1lpf21337792135.tab") + } + } > m Conditional inference tree with 20 terminal nodes Response: endo Inputs: A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 Number of observations: 306 1) A3 <= 3; criterion = 1, statistic = 98.265 2) A6 <= 2; criterion = 1, statistic = 33.159 3)* weights = 19 2) A6 > 2 4) A10 <= 2; criterion = 1, statistic = 21.494 5)* weights = 7 4) A10 > 2 6) A9 <= 2; criterion = 1, statistic = 20.378 7) A4 <= 3; criterion = 0.998, statistic = 13.848 8) A8 <= 3; criterion = 0.999, statistic = 15.988 9)* weights = 15 8) A8 > 3 10)* weights = 25 7) A4 > 3 11)* weights = 8 6) A9 > 2 12)* weights = 16 1) A3 > 3 13) A2 <= 2; criterion = 1, statistic = 47.027 14) A6 <= 3; criterion = 1, statistic = 22.944 15)* weights = 13 14) A6 > 3 16) A7 <= 3; criterion = 1, statistic = 17.356 17) A8 <= 3; criterion = 0.991, statistic = 11.052 18)* weights = 13 17) A8 > 3 19)* weights = 24 16) A7 > 3 20) A1 <= 2; criterion = 0.989, statistic = 10.677 21)* weights = 7 20) A1 > 2 22) A5 <= 3; criterion = 0.972, statistic = 8.911 23)* weights = 14 22) A5 > 3 24)* weights = 24 13) A2 > 2 25) A6 <= 3; criterion = 1, statistic = 29.246 26) A10 <= 3; criterion = 0.998, statistic = 13.681 27)* weights = 8 26) A10 > 3 28)* weights = 18 25) A6 > 3 29) A7 <= 3; criterion = 1, statistic = 18.33 30) A10 <= 3; criterion = 0.996, statistic = 12.655 31)* weights = 8 30) A10 > 3 32)* weights = 19 29) A7 > 3 33) A8 <= 4; criterion = 1, statistic = 20.431 34) A5 <= 3; criterion = 0.999, statistic = 14.545 35)* weights = 13 34) A5 > 3 36) A8 <= 3; criterion = 0.981, statistic = 9.627 37)* weights = 14 36) A8 > 3 38)* weights = 26 33) A8 > 4 39)* weights = 15 > postscript(file="/var/wessaorg/rcomp/tmp/2l9ht1337792135.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/3kpb11337792135.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 34.64286 -0.64285714 2 38 39.40000 -1.40000000 3 38 38.19231 -0.19230769 4 30 31.15385 -1.15384615 5 27 31.15385 -4.15384615 6 37 36.71429 0.28571429 7 31 30.46154 0.53846154 8 34 34.64286 -0.64285714 9 38 35.95833 2.04166667 10 34 34.75000 -0.75000000 11 28 26.85714 1.14285714 12 38 35.95833 2.04166667 13 36 34.75000 1.25000000 14 36 35.30769 0.69230769 15 40 39.40000 0.60000000 16 34 36.26316 -2.26315789 17 38 38.19231 -0.19230769 18 36 36.26316 -0.26315789 19 32 31.25000 0.75000000 20 36 36.26316 -0.26315789 21 37 34.81250 2.18750000 22 30 32.12000 -2.12000000 23 34 32.57143 1.42857143 24 32 32.12000 -0.12000000 25 35 33.20833 1.79166667 26 38 35.95833 2.04166667 27 31 34.64286 -3.64285714 28 32 32.12000 -0.12000000 29 37 38.19231 -1.19230769 30 36 35.95833 0.04166667 31 32 31.15385 0.84615385 32 36 35.16667 0.83333333 33 38 36.26316 1.73684211 34 38 38.19231 -0.19230769 35 39 38.19231 0.80769231 36 27 30.46154 -3.46153846 37 39 38.19231 0.80769231 38 36 35.16667 0.83333333 39 34 35.16667 -1.16666667 40 35 34.81250 0.18750000 41 29 30.06667 -1.06666667 42 33 31.25000 1.75000000 43 35 32.12000 2.88000000 44 32 31.15385 0.84615385 45 33 34.64286 -1.64285714 46 32 31.15385 0.84615385 47 37 38.19231 -1.19230769 48 37 35.95833 1.04166667 49 37 38.19231 -1.19230769 50 39 34.64286 4.35714286 51 31 33.20833 -2.20833333 52 31 32.12000 -1.12000000 53 33 32.12000 0.88000000 54 37 35.30769 1.69230769 55 36 35.95833 0.04166667 56 32 33.20833 -1.20833333 57 41 38.19231 2.80769231 58 34 32.12000 1.88000000 59 38 38.19231 -0.19230769 60 32 32.57143 -0.57142857 61 32 32.12000 -0.12000000 62 32 31.25000 0.75000000 63 39 33.62500 5.37500000 64 33 33.20833 -0.20833333 65 34 34.64286 -0.64285714 66 39 36.71429 2.28571429 67 39 38.19231 0.80769231 68 37 35.95833 1.04166667 69 40 39.40000 0.60000000 70 39 36.71429 2.28571429 71 32 25.68421 6.31578947 72 34 33.20833 0.79166667 73 30 33.20833 -3.20833333 74 33 31.15385 1.84615385 75 41 38.19231 2.80769231 76 31 30.46154 0.53846154 77 35 34.64286 0.35714286 78 33 32.12000 0.88000000 79 44 39.40000 4.60000000 80 29 31.25000 -2.25000000 81 34 35.30769 -1.30769231 82 38 34.81250 3.18750000 83 39 35.95833 3.04166667 84 37 36.26316 0.73684211 85 28 31.15385 -3.15384615 86 34 25.68421 8.31578947 87 41 36.26316 4.73684211 88 32 32.12000 -0.12000000 89 29 30.06667 -1.06666667 90 39 35.16667 3.83333333 91 33 36.71429 -3.71428571 92 37 33.20833 3.79166667 93 38 36.71429 1.28571429 94 35 38.19231 -3.19230769 95 34 33.20833 0.79166667 96 37 35.95833 1.04166667 97 35 35.95833 -0.95833333 98 31 35.16667 -4.16666667 99 32 32.12000 -0.12000000 100 33 32.12000 0.88000000 101 37 36.71429 0.28571429 102 30 30.06667 -0.06666667 103 29 33.20833 -4.20833333 104 43 39.40000 3.60000000 105 32 32.12000 -0.12000000 106 31 32.12000 -1.12000000 107 37 39.40000 -2.40000000 108 31 33.20833 -2.20833333 109 33 32.12000 0.88000000 110 38 33.20833 4.79166667 111 39 35.16667 3.83333333 112 32 35.30769 -3.30769231 113 32 30.06667 1.93333333 114 34 34.75000 -0.75000000 115 30 30.06667 -0.06666667 116 30 31.15385 -1.15384615 117 33 34.81250 -1.81250000 118 35 35.30769 -0.30769231 119 37 36.26316 0.73684211 120 33 35.16667 -2.16666667 121 40 39.40000 0.60000000 122 36 38.19231 -2.19230769 123 32 35.95833 -3.95833333 124 31 25.68421 5.31578947 125 29 32.57143 -3.57142857 126 37 34.81250 2.18750000 127 39 38.19231 0.80769231 128 37 36.26316 0.73684211 129 37 35.16667 1.83333333 130 34 34.81250 -0.81250000 131 35 35.95833 -0.95833333 132 37 35.95833 1.04166667 133 38 36.26316 1.73684211 134 33 36.26316 -3.26315789 135 30 31.25000 -1.25000000 136 32 31.15385 0.84615385 137 33 33.62500 -0.62500000 138 42 39.40000 2.60000000 139 38 35.16667 2.83333333 140 35 36.71429 -1.71428571 141 35 36.71429 -1.71428571 142 28 30.06667 -2.06666667 143 32 30.06667 1.93333333 144 36 35.16667 0.83333333 145 36 39.40000 -3.40000000 146 34 33.20833 0.79166667 147 31 31.25000 -0.25000000 148 38 35.95833 2.04166667 149 35 34.75000 0.25000000 150 36 36.26316 -0.26315789 151 35 25.68421 9.31578947 152 32 35.30769 -3.30769231 153 33 35.16667 -2.16666667 154 38 35.30769 2.69230769 155 38 38.19231 -0.19230769 156 35 33.20833 1.79166667 157 32 30.06667 1.93333333 158 31 30.06667 0.93333333 159 28 32.12000 -4.12000000 160 36 36.26316 -0.26315789 161 36 36.71429 -0.71428571 162 37 36.26316 0.73684211 163 30 31.15385 -1.15384615 164 36 39.40000 -3.40000000 165 32 33.20833 -1.20833333 166 24 25.68421 -1.68421053 167 33 35.16667 -2.16666667 168 21 25.68421 -4.68421053 169 16 25.68421 -9.68421053 170 31 34.81250 -3.81250000 171 39 34.81250 4.18750000 172 36 33.62500 2.37500000 173 32 35.30769 -3.30769231 174 30 26.85714 3.14285714 175 30 30.06667 -0.06666667 176 38 38.19231 -0.19230769 177 34 35.95833 -1.95833333 178 34 35.95833 -1.95833333 179 26 25.68421 0.31578947 180 21 25.68421 -4.68421053 181 35 35.30769 -0.30769231 182 39 36.71429 2.28571429 183 35 34.64286 0.35714286 184 32 33.20833 -1.20833333 185 35 32.57143 2.42857143 186 36 36.71429 -0.71428571 187 34 32.12000 1.88000000 188 19 25.68421 -6.68421053 189 36 35.16667 0.83333333 190 27 25.68421 1.31578947 191 34 33.20833 0.79166667 192 34 36.26316 -2.26315789 193 32 32.12000 -0.12000000 194 37 35.30769 1.69230769 195 38 36.71429 1.28571429 196 33 34.81250 -1.81250000 197 37 35.95833 1.04166667 198 30 30.06667 -0.06666667 199 24 25.68421 -1.68421053 200 22 25.68421 -3.68421053 201 30 30.46154 -0.46153846 202 36 33.20833 2.79166667 203 36 36.26316 -0.26315789 204 30 30.06667 -0.06666667 205 26 26.85714 -0.85714286 206 33 30.46154 2.53846154 207 36 33.20833 2.79166667 208 31 33.62500 -2.62500000 209 34 35.16667 -1.16666667 210 37 35.30769 1.69230769 211 33 31.15385 1.84615385 212 37 34.64286 2.35714286 213 35 33.62500 1.37500000 214 31 32.12000 -1.12000000 215 35 36.26316 -1.26315789 216 26 30.46154 -4.46153846 217 27 26.85714 0.14285714 218 38 39.40000 -1.40000000 219 36 35.95833 0.04166667 220 28 26.85714 1.14285714 221 41 39.40000 1.60000000 222 33 34.81250 -1.81250000 223 32 33.62500 -1.62500000 224 34 34.81250 -0.81250000 225 35 34.81250 0.18750000 226 29 32.12000 -3.12000000 227 36 36.71429 -0.71428571 228 32 33.20833 -1.20833333 229 29 33.20833 -4.20833333 230 38 38.19231 -0.19230769 231 40 38.19231 1.80769231 232 34 34.64286 -0.64285714 233 34 35.95833 -1.95833333 234 38 38.19231 -0.19230769 235 32 32.12000 -0.12000000 236 38 39.40000 -1.40000000 237 33 32.57143 0.42857143 238 34 35.16667 -1.16666667 239 37 36.26316 0.73684211 240 34 35.16667 -1.16666667 241 32 33.20833 -1.20833333 242 37 35.95833 1.04166667 243 34 32.12000 1.88000000 244 33 31.25000 1.75000000 245 34 34.81250 -0.81250000 246 35 34.64286 0.35714286 247 32 35.16667 -3.16666667 248 28 26.85714 1.14285714 249 32 30.46154 1.53846154 250 31 35.95833 -4.95833333 251 32 32.57143 -0.57142857 252 35 34.64286 0.35714286 253 33 32.12000 0.88000000 254 35 34.75000 0.25000000 255 37 39.40000 -2.40000000 256 35 34.75000 0.25000000 257 38 38.19231 -0.19230769 258 34 32.12000 1.88000000 259 35 33.20833 1.79166667 260 21 26.85714 -5.85714286 261 36 35.95833 0.04166667 262 24 25.68421 -1.68421053 263 34 33.20833 0.79166667 264 21 25.68421 -4.68421053 265 33 32.57143 0.42857143 266 41 39.40000 1.60000000 267 41 34.81250 6.18750000 268 30 25.68421 4.31578947 269 34 34.75000 -0.75000000 270 31 32.12000 -1.12000000 271 27 30.46154 -3.46153846 272 34 36.26316 -2.26315789 273 38 35.16667 2.83333333 274 39 38.19231 0.80769231 275 22 25.68421 -3.68421053 276 32 25.68421 6.31578947 277 29 30.06667 -1.06666667 278 33 35.95833 -2.95833333 279 30 31.25000 -1.25000000 280 39 38.19231 0.80769231 281 39 35.30769 3.69230769 282 33 34.64286 -1.64285714 283 32 34.81250 -2.81250000 284 32 33.20833 -1.20833333 285 30 30.46154 -0.46153846 286 35 34.75000 0.25000000 287 31 30.06667 0.93333333 288 33 31.15385 1.84615385 289 27 25.68421 1.31578947 290 28 30.06667 -2.06666667 291 33 31.15385 1.84615385 292 35 35.30769 -0.30769231 293 36 34.64286 1.35714286 294 34 33.62500 0.37500000 295 29 33.62500 -4.62500000 296 34 30.46154 3.53846154 297 31 34.81250 -3.81250000 298 38 38.19231 -0.19230769 299 38 35.95833 2.04166667 300 31 30.46154 0.53846154 301 35 38.19231 -3.19230769 302 36 36.71429 -0.71428571 303 40 38.19231 1.80769231 304 31 30.46154 0.53846154 305 33 30.46154 2.53846154 306 37 36.26316 0.73684211 > 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/42y711337792135.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/5ytzt1337792135.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/63k8j1337792136.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/7s2e11337792136.tab") + } > > try(system("convert tmp/2l9ht1337792135.ps tmp/2l9ht1337792135.png",intern=TRUE)) character(0) > try(system("convert tmp/3kpb11337792135.ps tmp/3kpb11337792135.png",intern=TRUE)) character(0) > try(system("convert tmp/42y711337792135.ps tmp/42y711337792135.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.056 0.390 6.439