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 = 'Learning Activities' > par8 = 'CSUQ' > par7 = 'all' > par6 = 'all' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '2' > #'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] 111 144 143 69 153 85 106 86 173 136 137 123 169 103 75 127 143 102 [19] 124 133 159 163 153 116 133 99 94 154 137 110 138 156 84 129 115 113 [37] 85 130 73 163 127 52 157 66 167 128 104 169 118 103 154 112 132 145 [55] 158 135 108 127 114 150 127 123 131 163 94 51 112 54 117 132 151 148 [73] 103 98 60 43 95 141 84 147 131 121 118 149 142 142 128 131 141 120 [91] 133 166 136 166 149 99 152 143 138 43 99 115 129 147 113 159 86 97 [109] 145 105 111 128 139 128 109 124 168 84 167 172 114 101 3 103 89 99 [127] 76 96 45 81 59 112 83 97 62 77 110 97 59 101 89 48 97 83 [145] 122 48 63 61 30 100 102 111 85 112 41 95 55 84 10 71 59 75 [163] 86 84 95 88 68 83 90 106 95 74 98 66 80 99 86 85 52 46 [181] 143 85 3 111 105 75 102 61 86 60 25 26 99 58 63 94 80 61 [199] 43 97 111 97 74 115 91 97 93 24 54 103 106 84 63 87 54 32 [217] 71 56 79 97 131 125 122 14 39 164 258 169 57 71 115 51 7 157 [235] 44 13 13 19 22 0 64 180 188 43 165 102 61 89 142 107 92 1 [253] 80 212 13 24 6 9 57 69 103 0 65 168 70 260 6 73 47 49 [271] 96 7 39 34 6 196 46 73 264 78 19 110 6 198 0 52 141 10 [289] 79 19 483 52 0 80 18 99 16 230 0 116 122 35 212 16 46 134 [307] 34 167 77 153 290 43 156 74 41 208 29 173 159 79 163 177 95 1 [325] 155 9 134 33 3 4 2 154 102 125 55 203 244 100 65 0 0 72 [343] 134 20 54 31 99 131 0 8 98 0 37 208 78 0 23 60 0 0 [361] 241 46 406 108 144 123 0 77 106 205 127 84 93 15 75 111 31 6 [379] 106 71 93 0 0 17 0 134 65 0 22 118 0 99 0 90 104 120 [397] 92 30 188 109 156 76 78 0 1 44 0 0 118 51 0 141 69 0 [415] 359 24 180 71 131 76 58 69 97 89 5 2 54 136 115 0 133 73 [433] 91 221 141 95 133 123 171 97 38 > 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]) 0 1 2 3 4 5 6 7 8 9 10 13 14 15 16 17 18 19 20 22 25 3 2 3 1 1 5 2 1 2 2 3 1 1 2 1 1 3 1 2 23 24 25 26 29 30 31 32 33 34 35 37 38 39 41 43 44 45 46 47 1 3 1 1 1 2 2 1 1 2 1 1 1 2 2 5 2 1 4 1 48 49 51 52 54 55 56 57 58 59 60 61 62 63 64 65 66 68 69 70 2 1 3 4 5 2 1 2 2 3 3 4 1 3 1 3 2 1 4 1 71 72 73 74 75 76 77 78 79 80 81 83 84 85 86 87 88 89 90 91 5 1 4 3 4 3 3 3 3 4 1 3 7 5 5 1 1 4 2 2 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 2 3 3 6 2 10 3 9 2 2 5 6 2 2 5 1 2 2 3 6 112 113 114 115 116 117 118 120 121 122 123 124 125 127 128 129 130 131 132 133 4 2 2 5 2 1 4 2 1 3 4 2 2 5 4 2 1 6 2 5 134 135 136 137 138 139 141 142 143 144 145 147 148 149 150 151 152 153 154 155 4 1 3 2 2 1 5 3 4 2 2 2 1 2 1 1 1 3 3 1 156 157 158 159 163 164 165 166 167 168 169 171 172 173 177 180 188 196 198 203 3 2 1 3 4 1 1 2 3 2 3 1 1 2 1 2 2 1 1 1 205 208 212 221 230 241 244 258 260 264 290 359 406 483 1 2 2 1 1 1 1 1 1 1 1 1 1 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] 111 144 143 69 153 85 106 86 173 136 137 123 169 103 75 127 143 102 [19] 124 133 159 163 153 116 133 99 94 154 137 110 138 156 84 129 115 113 [37] 85 130 73 163 127 52 157 66 167 128 104 169 118 103 154 112 132 145 [55] 158 135 108 127 114 150 127 123 131 163 94 51 112 54 117 132 151 148 [73] 103 98 60 43 95 141 84 147 131 121 118 149 142 142 128 131 141 120 [91] 133 166 136 166 149 99 152 143 138 43 99 115 129 147 113 159 86 97 [109] 145 105 111 128 139 128 109 124 168 84 167 172 114 101 3 103 89 99 [127] 76 96 45 81 59 112 83 97 62 77 110 97 59 101 89 48 97 83 [145] 122 48 63 61 30 100 102 111 85 112 41 95 55 84 10 71 59 75 [163] 86 84 95 88 68 83 90 106 95 74 98 66 80 99 86 85 52 46 [181] 143 85 3 111 105 75 102 61 86 60 25 26 99 58 63 94 80 61 [199] 43 97 111 97 74 115 91 97 93 24 54 103 106 84 63 87 54 32 [217] 71 56 79 97 131 125 122 14 39 164 258 169 57 71 115 51 7 157 [235] 44 13 13 19 22 0 64 180 188 43 165 102 61 89 142 107 92 1 [253] 80 212 13 24 6 9 57 69 103 0 65 168 70 260 6 73 47 49 [271] 96 7 39 34 6 196 46 73 264 78 19 110 6 198 0 52 141 10 [289] 79 19 483 52 0 80 18 99 16 230 0 116 122 35 212 16 46 134 [307] 34 167 77 153 290 43 156 74 41 208 29 173 159 79 163 177 95 1 [325] 155 9 134 33 3 4 2 154 102 125 55 203 244 100 65 0 0 72 [343] 134 20 54 31 99 131 0 8 98 0 37 208 78 0 23 60 0 0 [361] 241 46 406 108 144 123 0 77 106 205 127 84 93 15 75 111 31 6 [379] 106 71 93 0 0 17 0 134 65 0 22 118 0 99 0 90 104 120 [397] 92 30 188 109 156 76 78 0 1 44 0 0 118 51 0 141 69 0 [415] 359 24 180 71 131 76 58 69 97 89 5 2 54 136 115 0 133 73 [433] 91 221 141 95 133 123 171 97 38 > 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/127b91334679113.tab") + } + } > m Conditional inference tree with 2 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: 441 1) U21 <= 2; criterion = 1, statistic = 29.612 2)* weights = 94 1) U21 > 2 3)* weights = 347 > postscript(file="/var/wessaorg/rcomp/tmp/2j8o51334679113.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/3r3g71334679113.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 111 101.37464 9.6253602 2 144 101.37464 42.6253602 3 143 101.37464 41.6253602 4 69 101.37464 -32.3746398 5 153 101.37464 51.6253602 6 85 101.37464 -16.3746398 7 106 66.94681 39.0531915 8 86 101.37464 -15.3746398 9 173 101.37464 71.6253602 10 136 101.37464 34.6253602 11 137 101.37464 35.6253602 12 123 101.37464 21.6253602 13 169 101.37464 67.6253602 14 103 101.37464 1.6253602 15 75 101.37464 -26.3746398 16 127 101.37464 25.6253602 17 143 101.37464 41.6253602 18 102 101.37464 0.6253602 19 124 101.37464 22.6253602 20 133 101.37464 31.6253602 21 159 101.37464 57.6253602 22 163 101.37464 61.6253602 23 153 101.37464 51.6253602 24 116 101.37464 14.6253602 25 133 101.37464 31.6253602 26 99 101.37464 -2.3746398 27 94 101.37464 -7.3746398 28 154 101.37464 52.6253602 29 137 101.37464 35.6253602 30 110 66.94681 43.0531915 31 138 101.37464 36.6253602 32 156 101.37464 54.6253602 33 84 101.37464 -17.3746398 34 129 101.37464 27.6253602 35 115 101.37464 13.6253602 36 113 101.37464 11.6253602 37 85 66.94681 18.0531915 38 130 101.37464 28.6253602 39 73 101.37464 -28.3746398 40 163 101.37464 61.6253602 41 127 101.37464 25.6253602 42 52 101.37464 -49.3746398 43 157 101.37464 55.6253602 44 66 101.37464 -35.3746398 45 167 101.37464 65.6253602 46 128 101.37464 26.6253602 47 104 101.37464 2.6253602 48 169 101.37464 67.6253602 49 118 101.37464 16.6253602 50 103 101.37464 1.6253602 51 154 101.37464 52.6253602 52 112 101.37464 10.6253602 53 132 101.37464 30.6253602 54 145 101.37464 43.6253602 55 158 101.37464 56.6253602 56 135 101.37464 33.6253602 57 108 101.37464 6.6253602 58 127 101.37464 25.6253602 59 114 101.37464 12.6253602 60 150 101.37464 48.6253602 61 127 101.37464 25.6253602 62 123 101.37464 21.6253602 63 131 101.37464 29.6253602 64 163 101.37464 61.6253602 65 94 101.37464 -7.3746398 66 51 101.37464 -50.3746398 67 112 101.37464 10.6253602 68 54 101.37464 -47.3746398 69 117 101.37464 15.6253602 70 132 101.37464 30.6253602 71 151 66.94681 84.0531915 72 148 101.37464 46.6253602 73 103 101.37464 1.6253602 74 98 101.37464 -3.3746398 75 60 101.37464 -41.3746398 76 43 101.37464 -58.3746398 77 95 101.37464 -6.3746398 78 141 101.37464 39.6253602 79 84 101.37464 -17.3746398 80 147 101.37464 45.6253602 81 131 101.37464 29.6253602 82 121 101.37464 19.6253602 83 118 101.37464 16.6253602 84 149 101.37464 47.6253602 85 142 101.37464 40.6253602 86 142 101.37464 40.6253602 87 128 101.37464 26.6253602 88 131 101.37464 29.6253602 89 141 101.37464 39.6253602 90 120 101.37464 18.6253602 91 133 101.37464 31.6253602 92 166 101.37464 64.6253602 93 136 101.37464 34.6253602 94 166 101.37464 64.6253602 95 149 101.37464 47.6253602 96 99 101.37464 -2.3746398 97 152 101.37464 50.6253602 98 143 101.37464 41.6253602 99 138 101.37464 36.6253602 100 43 101.37464 -58.3746398 101 99 101.37464 -2.3746398 102 115 101.37464 13.6253602 103 129 101.37464 27.6253602 104 147 101.37464 45.6253602 105 113 101.37464 11.6253602 106 159 101.37464 57.6253602 107 86 101.37464 -15.3746398 108 97 101.37464 -4.3746398 109 145 101.37464 43.6253602 110 105 66.94681 38.0531915 111 111 66.94681 44.0531915 112 128 101.37464 26.6253602 113 139 101.37464 37.6253602 114 128 101.37464 26.6253602 115 109 101.37464 7.6253602 116 124 101.37464 22.6253602 117 168 101.37464 66.6253602 118 84 101.37464 -17.3746398 119 167 101.37464 65.6253602 120 172 101.37464 70.6253602 121 114 101.37464 12.6253602 122 101 101.37464 -0.3746398 123 3 101.37464 -98.3746398 124 103 101.37464 1.6253602 125 89 101.37464 -12.3746398 126 99 66.94681 32.0531915 127 76 101.37464 -25.3746398 128 96 101.37464 -5.3746398 129 45 101.37464 -56.3746398 130 81 66.94681 14.0531915 131 59 101.37464 -42.3746398 132 112 101.37464 10.6253602 133 83 101.37464 -18.3746398 134 97 66.94681 30.0531915 135 62 101.37464 -39.3746398 136 77 101.37464 -24.3746398 137 110 101.37464 8.6253602 138 97 101.37464 -4.3746398 139 59 66.94681 -7.9468085 140 101 101.37464 -0.3746398 141 89 101.37464 -12.3746398 142 48 101.37464 -53.3746398 143 97 101.37464 -4.3746398 144 83 101.37464 -18.3746398 145 122 101.37464 20.6253602 146 48 101.37464 -53.3746398 147 63 66.94681 -3.9468085 148 61 101.37464 -40.3746398 149 30 66.94681 -36.9468085 150 100 101.37464 -1.3746398 151 102 101.37464 0.6253602 152 111 101.37464 9.6253602 153 85 101.37464 -16.3746398 154 112 101.37464 10.6253602 155 41 101.37464 -60.3746398 156 95 101.37464 -6.3746398 157 55 101.37464 -46.3746398 158 84 101.37464 -17.3746398 159 10 66.94681 -56.9468085 160 71 101.37464 -30.3746398 161 59 101.37464 -42.3746398 162 75 101.37464 -26.3746398 163 86 101.37464 -15.3746398 164 84 101.37464 -17.3746398 165 95 101.37464 -6.3746398 166 88 101.37464 -13.3746398 167 68 101.37464 -33.3746398 168 83 101.37464 -18.3746398 169 90 101.37464 -11.3746398 170 106 101.37464 4.6253602 171 95 66.94681 28.0531915 172 74 101.37464 -27.3746398 173 98 101.37464 -3.3746398 174 66 66.94681 -0.9468085 175 80 66.94681 13.0531915 176 99 101.37464 -2.3746398 177 86 66.94681 19.0531915 178 85 66.94681 18.0531915 179 52 66.94681 -14.9468085 180 46 66.94681 -20.9468085 181 143 66.94681 76.0531915 182 85 66.94681 18.0531915 183 3 66.94681 -63.9468085 184 111 101.37464 9.6253602 185 105 101.37464 3.6253602 186 75 101.37464 -26.3746398 187 102 101.37464 0.6253602 188 61 101.37464 -40.3746398 189 86 101.37464 -15.3746398 190 60 66.94681 -6.9468085 191 25 101.37464 -76.3746398 192 26 66.94681 -40.9468085 193 99 66.94681 32.0531915 194 58 66.94681 -8.9468085 195 63 101.37464 -38.3746398 196 94 101.37464 -7.3746398 197 80 66.94681 13.0531915 198 61 101.37464 -40.3746398 199 43 66.94681 -23.9468085 200 97 101.37464 -4.3746398 201 111 66.94681 44.0531915 202 97 66.94681 30.0531915 203 74 101.37464 -27.3746398 204 115 101.37464 13.6253602 205 91 101.37464 -10.3746398 206 97 66.94681 30.0531915 207 93 66.94681 26.0531915 208 24 101.37464 -77.3746398 209 54 101.37464 -47.3746398 210 103 101.37464 1.6253602 211 106 66.94681 39.0531915 212 84 101.37464 -17.3746398 213 63 66.94681 -3.9468085 214 87 66.94681 20.0531915 215 54 101.37464 -47.3746398 216 32 66.94681 -34.9468085 217 71 101.37464 -30.3746398 218 56 66.94681 -10.9468085 219 79 66.94681 12.0531915 220 97 101.37464 -4.3746398 221 131 101.37464 29.6253602 222 125 101.37464 23.6253602 223 122 66.94681 55.0531915 224 14 101.37464 -87.3746398 225 39 101.37464 -62.3746398 226 164 101.37464 62.6253602 227 258 101.37464 156.6253602 228 169 101.37464 67.6253602 229 57 101.37464 -44.3746398 230 71 101.37464 -30.3746398 231 115 101.37464 13.6253602 232 51 66.94681 -15.9468085 233 7 66.94681 -59.9468085 234 157 101.37464 55.6253602 235 44 101.37464 -57.3746398 236 13 101.37464 -88.3746398 237 13 101.37464 -88.3746398 238 19 66.94681 -47.9468085 239 22 101.37464 -79.3746398 240 0 101.37464 -101.3746398 241 64 101.37464 -37.3746398 242 180 66.94681 113.0531915 243 188 101.37464 86.6253602 244 43 101.37464 -58.3746398 245 165 66.94681 98.0531915 246 102 101.37464 0.6253602 247 61 101.37464 -40.3746398 248 89 101.37464 -12.3746398 249 142 66.94681 75.0531915 250 107 101.37464 5.6253602 251 92 101.37464 -9.3746398 252 1 101.37464 -100.3746398 253 80 66.94681 13.0531915 254 212 101.37464 110.6253602 255 13 66.94681 -53.9468085 256 24 101.37464 -77.3746398 257 6 101.37464 -95.3746398 258 9 101.37464 -92.3746398 259 57 101.37464 -44.3746398 260 69 101.37464 -32.3746398 261 103 101.37464 1.6253602 262 0 66.94681 -66.9468085 263 65 101.37464 -36.3746398 264 168 101.37464 66.6253602 265 70 66.94681 3.0531915 266 260 101.37464 158.6253602 267 6 101.37464 -95.3746398 268 73 66.94681 6.0531915 269 47 101.37464 -54.3746398 270 49 101.37464 -52.3746398 271 96 66.94681 29.0531915 272 7 101.37464 -94.3746398 273 39 101.37464 -62.3746398 274 34 101.37464 -67.3746398 275 6 101.37464 -95.3746398 276 196 101.37464 94.6253602 277 46 66.94681 -20.9468085 278 73 101.37464 -28.3746398 279 264 66.94681 197.0531915 280 78 101.37464 -23.3746398 281 19 101.37464 -82.3746398 282 110 66.94681 43.0531915 283 6 66.94681 -60.9468085 284 198 101.37464 96.6253602 285 0 101.37464 -101.3746398 286 52 66.94681 -14.9468085 287 141 101.37464 39.6253602 288 10 66.94681 -56.9468085 289 79 101.37464 -22.3746398 290 19 66.94681 -47.9468085 291 483 101.37464 381.6253602 292 52 66.94681 -14.9468085 293 0 66.94681 -66.9468085 294 80 101.37464 -21.3746398 295 18 66.94681 -48.9468085 296 99 66.94681 32.0531915 297 16 66.94681 -50.9468085 298 230 101.37464 128.6253602 299 0 66.94681 -66.9468085 300 116 66.94681 49.0531915 301 122 101.37464 20.6253602 302 35 66.94681 -31.9468085 303 212 66.94681 145.0531915 304 16 66.94681 -50.9468085 305 46 101.37464 -55.3746398 306 134 101.37464 32.6253602 307 34 101.37464 -67.3746398 308 167 101.37464 65.6253602 309 77 101.37464 -24.3746398 310 153 101.37464 51.6253602 311 290 101.37464 188.6253602 312 43 101.37464 -58.3746398 313 156 101.37464 54.6253602 314 74 101.37464 -27.3746398 315 41 66.94681 -25.9468085 316 208 101.37464 106.6253602 317 29 101.37464 -72.3746398 318 173 66.94681 106.0531915 319 159 101.37464 57.6253602 320 79 101.37464 -22.3746398 321 163 101.37464 61.6253602 322 177 101.37464 75.6253602 323 95 101.37464 -6.3746398 324 1 101.37464 -100.3746398 325 155 66.94681 88.0531915 326 9 101.37464 -92.3746398 327 134 101.37464 32.6253602 328 33 101.37464 -68.3746398 329 3 66.94681 -63.9468085 330 4 101.37464 -97.3746398 331 2 66.94681 -64.9468085 332 154 101.37464 52.6253602 333 102 101.37464 0.6253602 334 125 66.94681 58.0531915 335 55 66.94681 -11.9468085 336 203 101.37464 101.6253602 337 244 101.37464 142.6253602 338 100 101.37464 -1.3746398 339 65 101.37464 -36.3746398 340 0 101.37464 -101.3746398 341 0 101.37464 -101.3746398 342 72 66.94681 5.0531915 343 134 101.37464 32.6253602 344 20 101.37464 -81.3746398 345 54 101.37464 -47.3746398 346 31 101.37464 -70.3746398 347 99 101.37464 -2.3746398 348 131 101.37464 29.6253602 349 0 101.37464 -101.3746398 350 8 101.37464 -93.3746398 351 98 101.37464 -3.3746398 352 0 101.37464 -101.3746398 353 37 66.94681 -29.9468085 354 208 66.94681 141.0531915 355 78 101.37464 -23.3746398 356 0 66.94681 -66.9468085 357 23 66.94681 -43.9468085 358 60 66.94681 -6.9468085 359 0 101.37464 -101.3746398 360 0 66.94681 -66.9468085 361 241 101.37464 139.6253602 362 46 101.37464 -55.3746398 363 406 101.37464 304.6253602 364 108 101.37464 6.6253602 365 144 101.37464 42.6253602 366 123 101.37464 21.6253602 367 0 101.37464 -101.3746398 368 77 101.37464 -24.3746398 369 106 101.37464 4.6253602 370 205 101.37464 103.6253602 371 127 101.37464 25.6253602 372 84 101.37464 -17.3746398 373 93 101.37464 -8.3746398 374 15 101.37464 -86.3746398 375 75 101.37464 -26.3746398 376 111 101.37464 9.6253602 377 31 101.37464 -70.3746398 378 6 101.37464 -95.3746398 379 106 101.37464 4.6253602 380 71 101.37464 -30.3746398 381 93 101.37464 -8.3746398 382 0 101.37464 -101.3746398 383 0 66.94681 -66.9468085 384 17 66.94681 -49.9468085 385 0 66.94681 -66.9468085 386 134 101.37464 32.6253602 387 65 101.37464 -36.3746398 388 0 101.37464 -101.3746398 389 22 66.94681 -44.9468085 390 118 101.37464 16.6253602 391 0 101.37464 -101.3746398 392 99 101.37464 -2.3746398 393 0 101.37464 -101.3746398 394 90 101.37464 -11.3746398 395 104 101.37464 2.6253602 396 120 101.37464 18.6253602 397 92 101.37464 -9.3746398 398 30 66.94681 -36.9468085 399 188 101.37464 86.6253602 400 109 101.37464 7.6253602 401 156 101.37464 54.6253602 402 76 101.37464 -25.3746398 403 78 101.37464 -23.3746398 404 0 101.37464 -101.3746398 405 1 101.37464 -100.3746398 406 44 101.37464 -57.3746398 407 0 101.37464 -101.3746398 408 0 101.37464 -101.3746398 409 118 101.37464 16.6253602 410 51 66.94681 -15.9468085 411 0 66.94681 -66.9468085 412 141 101.37464 39.6253602 413 69 101.37464 -32.3746398 414 0 66.94681 -66.9468085 415 359 101.37464 257.6253602 416 24 66.94681 -42.9468085 417 180 101.37464 78.6253602 418 71 66.94681 4.0531915 419 131 101.37464 29.6253602 420 76 101.37464 -25.3746398 421 58 101.37464 -43.3746398 422 69 101.37464 -32.3746398 423 97 101.37464 -4.3746398 424 89 101.37464 -12.3746398 425 5 101.37464 -96.3746398 426 2 101.37464 -99.3746398 427 54 101.37464 -47.3746398 428 136 101.37464 34.6253602 429 115 101.37464 13.6253602 430 0 66.94681 -66.9468085 431 133 101.37464 31.6253602 432 73 101.37464 -28.3746398 433 91 101.37464 -10.3746398 434 221 101.37464 119.6253602 435 141 101.37464 39.6253602 436 95 101.37464 -6.3746398 437 133 101.37464 31.6253602 438 123 101.37464 21.6253602 439 171 101.37464 69.6253602 440 97 101.37464 -4.3746398 441 38 101.37464 -63.3746398 > 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/4sfkl1334679113.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/59jwv1334679113.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/6qch01334679113.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/7oe9w1334679113.tab") + } > > try(system("convert tmp/2j8o51334679113.ps tmp/2j8o51334679113.png",intern=TRUE)) character(0) > try(system("convert tmp/3r3g71334679113.ps tmp/3r3g71334679113.png",intern=TRUE)) character(0) > try(system("convert tmp/4sfkl1334679113.ps tmp/4sfkl1334679113.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.150 0.344 7.487