R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > par9 = 'CSUQ' > par8 = 'CSUQ' > par7 = 'all' > par6 = 'prep' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'CSUQ' > par8 <- 'CSUQ' > par7 <- 'all' > par6 <- 'prep' > 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] 119 143 141 137 141 109 105 111 153 99 134 122 124 119 91 122 136 131 [19] 129 135 120 119 119 125 118 138 123 114 134 97 130 112 126 107 106 110 [37] 137 130 105 106 144 129 140 112 108 113 116 116 135 95 101 122 123 126 [55] 121 106 100 126 132 87 117 100 128 140 117 132 107 133 80 133 119 132 [73] 142 69 141 125 95 119 136 108 112 115 100 82 122 142 147 132 98 67 [91] 130 91 124 122 96 127 124 127 144 134 108 130 151 113 81 101 109 126 [109] 134 128 128 125 88 117 112 97 99 96 105 121 95 131 122 97 106 119 [127] 124 126 99 126 151 118 95 138 101 121 134 130 121 130 131 117 86 126 [145] 122 110 129 87 150 109 137 111 138 123 82 120 118 99 69 126 119 116 [163] 101 132 85 128 82 128 143 125 147 111 108 122 84 117 120 77 100 134 [181] 123 123 123 128 108 118 107 105 111 112 121 92 97 99 111 93 121 86 [199] 125 96 126 108 99 137 105 69 82 115 96 91 128 91 92 78 116 125 [217] 113 130 131 111 126 122 130 114 102 121 122 81 129 124 89 139 99 127 [235] 123 87 129 97 119 126 104 109 127 52 125 114 > 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]) 52 67 69 77 78 80 81 82 84 85 86 87 88 89 91 92 93 95 96 97 1 1 3 1 1 1 2 4 1 1 2 3 1 1 4 2 1 4 4 5 98 99 100 101 102 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 1 7 4 4 1 1 5 4 3 6 4 2 6 5 3 3 2 4 5 4 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 9 3 7 10 7 5 7 11 4 7 5 8 4 5 2 6 2 2 4 3 139 140 141 142 143 144 147 150 151 153 1 2 3 2 2 2 2 1 2 1 > colnames(x) [1] "endo" "U1" "U2" "U3" "U4" "U5" "U6" "U7" "U8" "U9" [11] "U10" "U11" "U12" "U13" "U14" "U15" "U16" "U17" "U18" "U19" [21] "U20" "U21" "U22" "U23" "U24" "U25" "U26" "U27" "U28" "U29" [31] "U30" "U31" "U32" "U33" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 119 143 141 137 141 109 105 111 153 99 134 122 124 119 91 122 136 131 [19] 129 135 120 119 119 125 118 138 123 114 134 97 130 112 126 107 106 110 [37] 137 130 105 106 144 129 140 112 108 113 116 116 135 95 101 122 123 126 [55] 121 106 100 126 132 87 117 100 128 140 117 132 107 133 80 133 119 132 [73] 142 69 141 125 95 119 136 108 112 115 100 82 122 142 147 132 98 67 [91] 130 91 124 122 96 127 124 127 144 134 108 130 151 113 81 101 109 126 [109] 134 128 128 125 88 117 112 97 99 96 105 121 95 131 122 97 106 119 [127] 124 126 99 126 151 118 95 138 101 121 134 130 121 130 131 117 86 126 [145] 122 110 129 87 150 109 137 111 138 123 82 120 118 99 69 126 119 116 [163] 101 132 85 128 82 128 143 125 147 111 108 122 84 117 120 77 100 134 [181] 123 123 123 128 108 118 107 105 111 112 121 92 97 99 111 93 121 86 [199] 125 96 126 108 99 137 105 69 82 115 96 91 128 91 92 78 116 125 [217] 113 130 131 111 126 122 130 114 102 121 122 81 129 124 89 139 99 127 [235] 123 87 129 97 119 126 104 109 127 52 125 114 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/rcomp/createtable") > > if (par2 != 'none') { + m <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data = x) + if (par4=='yes') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'10-Fold Cross Validation',3+2*par3,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'',1,TRUE) + a<-table.element(a,'Prediction (training)',par3+1,TRUE) + a<-table.element(a,'Prediction (testing)',par3+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Actual',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) + a<-table.element(a,'CV',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) + a<-table.element(a,'CV',1,TRUE) + a<-table.row.end(a) + for (i in 1:10) { + ind <- sample(2, nrow(x), replace=T, prob=c(0.9,0.1)) + m.ct <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data =x[ind==1,]) + if (i==1) { + m.ct.i.pred <- predict(m.ct, newdata=x[ind==1,]) + m.ct.i.actu <- x[ind==1,par1] + m.ct.x.pred <- predict(m.ct, newdata=x[ind==2,]) + m.ct.x.actu <- x[ind==2,par1] + } else { + m.ct.i.pred <- c(m.ct.i.pred,predict(m.ct, newdata=x[ind==1,])) + m.ct.i.actu <- c(m.ct.i.actu,x[ind==1,par1]) + m.ct.x.pred <- c(m.ct.x.pred,predict(m.ct, newdata=x[ind==2,])) + m.ct.x.actu <- c(m.ct.x.actu,x[ind==2,par1]) + } + } + print(m.ct.i.tab <- table(m.ct.i.actu,m.ct.i.pred)) + numer <- 0 + for (i in 1:par3) { + print(m.ct.i.tab[i,i] / sum(m.ct.i.tab[i,])) + numer <- numer + m.ct.i.tab[i,i] + } + print(m.ct.i.cp <- numer / sum(m.ct.i.tab)) + print(m.ct.x.tab <- table(m.ct.x.actu,m.ct.x.pred)) + numer <- 0 + for (i in 1:par3) { + print(m.ct.x.tab[i,i] / sum(m.ct.x.tab[i,])) + numer <- numer + m.ct.x.tab[i,i] + } + print(m.ct.x.cp <- numer / sum(m.ct.x.tab)) + for (i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + for (jjj in 1:par3) a<-table.element(a,m.ct.i.tab[i,jjj]) + a<-table.element(a,round(m.ct.i.tab[i,i]/sum(m.ct.i.tab[i,]),4)) + for (jjj in 1:par3) a<-table.element(a,m.ct.x.tab[i,jjj]) + a<-table.element(a,round(m.ct.x.tab[i,i]/sum(m.ct.x.tab[i,]),4)) + a<-table.row.end(a) + } + a<-table.row.start(a) + a<-table.element(a,'Overall',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,'-') + a<-table.element(a,round(m.ct.i.cp,4)) + for (jjj in 1:par3) a<-table.element(a,'-') + a<-table.element(a,round(m.ct.x.cp,4)) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/rcomp/tmp/1vntb1337256839.tab") + } + } > m Conditional inference tree with 16 terminal nodes Response: endo Inputs: 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 Number of observations: 246 1) U20 <= 3; criterion = 1, statistic = 169.661 2) U1 <= 2; criterion = 1, statistic = 37.181 3) U13 <= 2; criterion = 0.99, statistic = 13.013 4)* weights = 16 3) U13 > 2 5)* weights = 10 2) U1 > 2 6) U29 <= 3; criterion = 1, statistic = 22.408 7) U22 <= 3; criterion = 0.971, statistic = 11.059 8)* weights = 16 7) U22 > 3 9)* weights = 7 6) U29 > 3 10) U30 <= 3; criterion = 0.994, statistic = 13.886 11)* weights = 15 10) U30 > 3 12)* weights = 10 1) U20 > 3 13) U5 <= 4; criterion = 1, statistic = 66.86 14) U22 <= 3; criterion = 1, statistic = 48.785 15)* weights = 26 14) U22 > 3 16) U19 <= 3; criterion = 1, statistic = 36.764 17) U17 <= 3; criterion = 0.963, statistic = 10.598 18)* weights = 13 17) U17 > 3 19)* weights = 17 16) U19 > 3 20) U7 <= 4; criterion = 1, statistic = 30.161 21) U13 <= 3; criterion = 1, statistic = 21.812 22)* weights = 25 21) U13 > 3 23) U3 <= 3; criterion = 0.995, statistic = 14.349 24)* weights = 7 23) U3 > 3 25) U21 <= 4; criterion = 0.975, statistic = 11.324 26)* weights = 20 25) U21 > 4 27)* weights = 26 20) U7 > 4 28)* weights = 11 13) U5 > 4 29) U1 <= 4; criterion = 0.997, statistic = 15.557 30)* weights = 7 29) U1 > 4 31)* weights = 20 > postscript(file="/var/www/rcomp/tmp/29r7r1337256839.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(m) > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/37wby1337256839.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 119 120.0000 -1.0000000 2 143 140.5000 2.5000000 3 141 140.5000 0.5000000 4 137 129.6538 7.3461538 5 141 140.5000 0.5000000 6 109 119.4400 -10.4400000 7 105 119.4400 -14.4400000 8 111 102.4000 8.6000000 9 153 140.5000 12.5000000 10 99 92.5625 6.4375000 11 134 126.1000 7.9000000 12 122 119.4400 2.5600000 13 124 126.1000 -2.1000000 14 119 121.1429 -2.1428571 15 91 92.8000 -1.8000000 16 122 126.1000 -4.1000000 17 136 129.6538 6.3461538 18 131 129.6538 1.3461538 19 129 129.6538 -0.6538462 20 135 140.5000 -5.5000000 21 120 113.6154 6.3846154 22 119 126.1000 -7.1000000 23 119 119.4400 -0.4400000 24 125 129.6538 -4.6538462 25 118 119.4400 -1.4400000 26 138 126.1000 11.9000000 27 123 120.0000 3.0000000 28 114 119.4400 -5.4400000 29 134 129.6538 4.3461538 30 97 92.5625 4.4375000 31 130 126.1000 3.9000000 32 112 111.7308 0.2692308 33 126 120.0000 6.0000000 34 107 102.1429 4.8571429 35 106 111.7308 -5.7307692 36 110 119.4400 -9.4400000 37 137 140.5000 -3.5000000 38 130 126.1000 3.9000000 39 105 102.4000 2.6000000 40 106 102.4000 3.6000000 41 144 128.7143 15.2857143 42 129 129.6538 -0.6538462 43 140 128.7143 11.2857143 44 112 111.7308 0.2692308 45 108 113.6154 -5.6153846 46 113 116.4000 -3.4000000 47 116 121.1429 -5.1428571 48 116 113.6154 2.3846154 49 135 129.6538 5.3461538 50 95 92.8000 2.2000000 51 101 102.4000 -1.4000000 52 122 126.1000 -4.1000000 53 123 120.0000 3.0000000 54 126 121.1429 4.8571429 55 121 121.1429 -0.1428571 56 106 102.4000 3.6000000 57 100 111.7308 -11.7307692 58 126 129.6538 -3.6538462 59 132 129.6538 2.3461538 60 87 78.3750 8.6250000 61 117 120.0000 -3.0000000 62 100 92.5625 7.4375000 63 128 129.6538 -1.6538462 64 140 140.5000 -0.5000000 65 117 120.0000 -3.0000000 66 132 129.6538 2.3461538 67 107 113.6154 -6.6153846 68 133 140.5000 -7.5000000 69 80 78.3750 1.6250000 70 133 129.6538 3.3461538 71 119 119.4400 -0.4400000 72 132 129.6538 2.3461538 73 142 140.5000 1.5000000 74 69 78.3750 -9.3750000 75 141 140.5000 0.5000000 76 125 120.0000 5.0000000 77 95 92.5625 2.4375000 78 119 111.7308 7.2692308 79 136 140.5000 -4.5000000 80 108 113.6154 -5.6153846 81 112 120.0000 -8.0000000 82 115 120.0000 -5.0000000 83 100 102.1429 -2.1428571 84 82 78.3750 3.6250000 85 122 121.1429 0.8571429 86 142 140.5000 1.5000000 87 147 140.5000 6.5000000 88 132 136.4545 -4.4545455 89 98 102.4000 -4.4000000 90 67 92.5625 -25.5625000 91 130 119.4400 10.5600000 92 91 92.5625 -1.5625000 93 124 116.4000 7.6000000 94 122 126.1000 -4.1000000 95 96 111.7308 -15.7307692 96 127 129.6538 -2.6538462 97 124 129.6538 -5.6538462 98 127 128.7143 -1.7142857 99 144 136.4545 7.5454545 100 134 129.6538 4.3461538 101 108 113.6154 -5.6153846 102 130 120.0000 10.0000000 103 151 140.5000 10.5000000 104 113 119.4400 -6.4400000 105 81 78.3750 2.6250000 106 101 102.4000 -1.4000000 107 109 102.4000 6.6000000 108 126 126.1000 -0.1000000 109 134 140.5000 -6.5000000 110 128 129.6538 -1.6538462 111 128 119.4400 8.5600000 112 125 119.4400 5.5600000 113 88 78.3750 9.6250000 114 117 113.6154 3.3846154 115 112 113.6154 -1.6153846 116 97 111.7308 -14.7307692 117 99 113.6154 -14.6153846 118 96 102.1429 -6.1428571 119 105 102.4000 2.6000000 120 121 120.0000 1.0000000 121 95 128.7143 -33.7142857 122 131 128.7143 2.2857143 123 122 126.1000 -4.1000000 124 97 102.1429 -5.1428571 125 106 92.8000 13.2000000 126 119 119.4400 -0.4400000 127 124 120.0000 4.0000000 128 126 129.6538 -3.6538462 129 99 92.5625 6.4375000 130 126 116.4000 9.6000000 131 151 140.5000 10.5000000 132 118 119.4400 -1.4400000 133 95 92.8000 2.2000000 134 138 140.5000 -2.5000000 135 101 102.1429 -1.1428571 136 121 121.1429 -0.1428571 137 134 129.6538 4.3461538 138 130 128.7143 1.2857143 139 121 119.4400 1.5600000 140 130 111.7308 18.2692308 141 131 140.5000 -9.5000000 142 117 111.7308 5.2692308 143 86 92.5625 -6.5625000 144 126 126.1000 -0.1000000 145 122 126.1000 -4.1000000 146 110 111.7308 -1.7307692 147 129 129.6538 -0.6538462 148 87 92.5625 -5.5625000 149 150 136.4545 13.5454545 150 109 111.7308 -2.7307692 151 137 140.5000 -3.5000000 152 111 111.7308 -0.7307692 153 138 136.4545 1.5454545 154 123 121.1429 1.8571429 155 82 92.8000 -10.8000000 156 120 119.4400 0.5600000 157 118 119.4400 -1.4400000 158 99 92.5625 6.4375000 159 69 78.3750 -9.3750000 160 126 119.4400 6.5600000 161 119 126.1000 -7.1000000 162 116 116.4000 -0.4000000 163 101 111.7308 -10.7307692 164 132 111.7308 20.2692308 165 85 92.5625 -7.5625000 166 128 126.1000 1.9000000 167 82 78.3750 3.6250000 168 128 111.7308 16.2692308 169 143 136.4545 6.5454545 170 125 126.1000 -1.1000000 171 147 136.4545 10.5454545 172 111 111.7308 -0.7307692 173 108 113.6154 -5.6153846 174 122 129.6538 -7.6538462 175 84 92.5625 -8.5625000 176 117 119.4400 -2.4400000 177 120 116.4000 3.6000000 178 77 78.3750 -1.3750000 179 100 102.4000 -2.4000000 180 134 128.7143 5.2857143 181 123 136.4545 -13.4545455 182 123 111.7308 11.2692308 183 123 120.0000 3.0000000 184 128 126.1000 1.9000000 185 108 111.7308 -3.7307692 186 118 120.0000 -2.0000000 187 107 111.7308 -4.7307692 188 105 102.4000 2.6000000 189 111 111.7308 -0.7307692 190 112 102.1429 9.8571429 191 121 119.4400 1.5600000 192 92 92.5625 -0.5625000 193 97 102.4000 -5.4000000 194 99 92.5625 6.4375000 195 111 116.4000 -5.4000000 196 93 92.8000 0.2000000 197 121 119.4400 1.5600000 198 86 78.3750 7.6250000 199 125 129.6538 -4.6538462 200 96 92.5625 3.4375000 201 126 113.6154 12.3846154 202 108 111.7308 -3.7307692 203 99 92.8000 6.2000000 204 137 140.5000 -3.5000000 205 105 92.5625 12.4375000 206 69 78.3750 -9.3750000 207 82 78.3750 3.6250000 208 115 116.4000 -1.4000000 209 96 102.4000 -6.4000000 210 91 78.3750 12.6250000 211 128 126.1000 1.9000000 212 91 92.8000 -1.8000000 213 92 111.7308 -19.7307692 214 78 78.3750 -0.3750000 215 116 120.0000 -4.0000000 216 125 129.6538 -4.6538462 217 113 111.7308 1.2692308 218 130 126.1000 3.9000000 219 131 129.6538 1.3461538 220 111 116.4000 -5.4000000 221 126 119.4400 6.5600000 222 122 120.0000 2.0000000 223 130 136.4545 -6.4545455 224 114 116.4000 -2.4000000 225 102 102.1429 -0.1428571 226 121 119.4400 1.5600000 227 122 119.4400 2.5600000 228 81 78.3750 2.6250000 229 129 136.4545 -7.4545455 230 124 119.4400 4.5600000 231 89 92.8000 -3.8000000 232 139 136.4545 2.5454545 233 99 102.4000 -3.4000000 234 127 129.6538 -2.6538462 235 123 111.7308 11.2692308 236 87 92.8000 -5.8000000 237 129 113.6154 15.3846154 238 97 102.4000 -5.4000000 239 119 113.6154 5.3846154 240 126 136.4545 -10.4545455 241 104 111.7308 -7.7307692 242 109 120.0000 -11.0000000 243 127 126.1000 0.9000000 244 52 78.3750 -26.3750000 245 125 111.7308 13.2692308 246 114 116.4000 -2.4000000 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/www/rcomp/tmp/42zbw1337256839.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > if(par2=='none') { + op <- par(mfrow=c(2,2)) + plot(density(result$Actuals),main='Kernel Density Plot of Actuals') + plot(density(result$Residuals),main='Kernel Density Plot of Residuals') + plot(result$Forecasts,result$Actuals,main='Actuals versus Predictions',xlab='Predictions',ylab='Actuals') + plot(density(result$Forecasts),main='Kernel Density Plot of Predictions') + par(op) + } > if(par2!='none') { + plot(myt,main='Confusion Matrix',xlab='Actual',ylab='Predicted') + } > dev.off() null device 1 > if (par2 == 'none') { + detcoef <- cor(result$Forecasts,result$Actuals) + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goodness of Fit',2,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Correlation',1,TRUE) + a<-table.element(a,round(detcoef,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'R-squared',1,TRUE) + a<-table.element(a,round(detcoef*detcoef,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'RMSE',1,TRUE) + a<-table.element(a,round(sqrt(mean((result$Residuals)^2)),4)) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/rcomp/tmp/5zwhi1337256839.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Actuals, Predictions, and Residuals',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'#',header=TRUE) + a<-table.element(a,'Actuals',header=TRUE) + a<-table.element(a,'Forecasts',header=TRUE) + a<-table.element(a,'Residuals',header=TRUE) + a<-table.row.end(a) + for (i in 1:length(result$Actuals)) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,result$Actuals[i]) + a<-table.element(a,result$Forecasts[i]) + a<-table.element(a,result$Residuals[i]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/rcomp/tmp/67mes1337256839.tab") + } > if (par2 != 'none') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Confusion Matrix (predicted in columns / actuals in rows)',par3+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'',1,TRUE) + for (i in 1:par3) { + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + } + a<-table.row.end(a) + for (i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + for (j in 1:par3) { + a<-table.element(a,myt[i,j]) + } + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/rcomp/tmp/7oies1337256839.tab") + } > > try(system("convert tmp/29r7r1337256839.ps tmp/29r7r1337256839.png",intern=TRUE)) character(0) > try(system("convert tmp/37wby1337256839.ps tmp/37wby1337256839.png",intern=TRUE)) character(0) > try(system("convert tmp/42zbw1337256839.ps tmp/42zbw1337256839.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.690 0.820 6.882