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 = '1' > #'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] 97 136 88 36 134 43 99 39 84 62 164 59 71 123 5 110 128 70 [19] 72 115 123 150 88 97 118 121 126 67 100 164 74 129 89 93 80 173 [37] 86 21 94 45 115 76 34 106 64 97 32 62 129 96 152 99 102 94 [55] 145 126 90 85 77 123 94 177 133 41 116 92 54 23 154 22 126 110 [73] 135 75 101 112 24 61 126 134 95 148 47 77 140 124 138 96 48 147 [91] 95 78 105 33 90 132 71 90 127 67 50 104 161 95 51 107 157 178 [109] 108 162 35 40 113 80 54 85 121 102 43 70 108 73 126 125 81 27 [127] 5 77 84 76 40 61 46 43 48 55 35 50 64 37 58 74 76 58 [145] 61 78 61 47 5 118 47 71 49 19 53 97 63 46 43 25 69 35 [163] 58 0 20 54 55 31 47 56 46 96 56 53 63 76 74 53 30 67 [181] 21 62 43 30 36 70 44 14 108 52 109 58 19 129 28 25 44 42 [199] 40 58 26 49 24 19 86 66 39 90 32 45 66 61 36 84 89 54 [217] 85 55 48 42 45 58 57 55 56 80 137 94 74 71 122 157 2 139 [235] 103 132 75 37 64 128 153 77 0 130 134 65 134 116 128 69 71 57 [253] 139 88 97 42 187 15 60 94 95 36 109 94 180 65 132 61 115 78 [271] 162 103 172 147 114 54 74 117 145 120 95 68 25 157 17 147 6 108 [289] 262 153 135 137 55 138 86 95 31 114 56 53 174 144 27 84 112 122 [307] 232 38 112 169 77 155 72 107 158 84 61 107 81 90 56 42 144 43 [325] 116 110 94 124 55 115 21 94 72 73 22 48 50 102 7 68 20 2 [343] 41 32 52 20 40 0 44 23 157 57 43 17 23 44 158 74 37 1 [361] 30 100 75 24 29 42 97 4 29 93 19 43 30 55 1 20 33 79 [379] 25 101 94 1 22 30 23 83 40 28 2 26 58 52 41 32 17 14 [397] 136 22 119 80 33 34 59 13 49 57 22 46 > 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 4 5 6 7 13 14 15 17 19 20 21 22 23 24 25 26 27 3 3 3 1 3 1 1 1 2 1 3 4 4 3 5 4 3 4 2 2 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 2 2 5 2 4 3 2 3 4 3 1 2 5 3 5 8 4 3 4 4 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 4 3 3 1 3 4 5 7 5 4 7 2 1 7 3 2 3 2 2 3 68 69 70 71 72 73 74 75 76 77 78 79 80 81 83 84 85 86 88 89 2 2 3 5 3 2 6 3 4 5 3 1 4 2 1 5 3 3 3 2 90 92 93 94 95 96 97 99 100 101 102 103 104 105 106 107 108 109 110 112 5 1 2 9 6 3 6 2 2 2 3 2 1 1 1 3 4 2 3 3 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 132 133 1 2 4 3 1 2 1 1 2 2 3 2 1 5 1 3 3 1 3 1 134 135 136 137 138 139 140 144 145 147 148 150 152 153 154 155 157 158 161 162 4 2 2 2 2 2 1 2 2 3 1 1 1 2 1 1 4 2 1 2 164 169 172 173 174 177 178 180 187 232 262 2 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] 97 136 88 36 134 43 99 39 84 62 164 59 71 123 5 110 128 70 [19] 72 115 123 150 88 97 118 121 126 67 100 164 74 129 89 93 80 173 [37] 86 21 94 45 115 76 34 106 64 97 32 62 129 96 152 99 102 94 [55] 145 126 90 85 77 123 94 177 133 41 116 92 54 23 154 22 126 110 [73] 135 75 101 112 24 61 126 134 95 148 47 77 140 124 138 96 48 147 [91] 95 78 105 33 90 132 71 90 127 67 50 104 161 95 51 107 157 178 [109] 108 162 35 40 113 80 54 85 121 102 43 70 108 73 126 125 81 27 [127] 5 77 84 76 40 61 46 43 48 55 35 50 64 37 58 74 76 58 [145] 61 78 61 47 5 118 47 71 49 19 53 97 63 46 43 25 69 35 [163] 58 0 20 54 55 31 47 56 46 96 56 53 63 76 74 53 30 67 [181] 21 62 43 30 36 70 44 14 108 52 109 58 19 129 28 25 44 42 [199] 40 58 26 49 24 19 86 66 39 90 32 45 66 61 36 84 89 54 [217] 85 55 48 42 45 58 57 55 56 80 137 94 74 71 122 157 2 139 [235] 103 132 75 37 64 128 153 77 0 130 134 65 134 116 128 69 71 57 [253] 139 88 97 42 187 15 60 94 95 36 109 94 180 65 132 61 115 78 [271] 162 103 172 147 114 54 74 117 145 120 95 68 25 157 17 147 6 108 [289] 262 153 135 137 55 138 86 95 31 114 56 53 174 144 27 84 112 122 [307] 232 38 112 169 77 155 72 107 158 84 61 107 81 90 56 42 144 43 [325] 116 110 94 124 55 115 21 94 72 73 22 48 50 102 7 68 20 2 [343] 41 32 52 20 40 0 44 23 157 57 43 17 23 44 158 74 37 1 [361] 30 100 75 24 29 42 97 4 29 93 19 43 30 55 1 20 33 79 [379] 25 101 94 1 22 30 23 83 40 28 2 26 58 52 41 32 17 14 [397] 136 22 119 80 33 34 59 13 49 57 22 46 > 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/11fwi1334679285.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: 408 1) U7 <= 3; criterion = 1, statistic = 20.342 2)* weights = 155 1) U7 > 3 3)* weights = 253 > postscript(file="/var/wessaorg/rcomp/tmp/219341334679285.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/334521334679285.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 97 82.94466 14.05533597 2 136 82.94466 53.05533597 3 88 82.94466 5.05533597 4 36 82.94466 -46.94466403 5 134 82.94466 51.05533597 6 43 67.12903 -24.12903226 7 99 67.12903 31.87096774 8 39 82.94466 -43.94466403 9 84 82.94466 1.05533597 10 62 67.12903 -5.12903226 11 164 82.94466 81.05533597 12 59 67.12903 -8.12903226 13 71 82.94466 -11.94466403 14 123 82.94466 40.05533597 15 5 67.12903 -62.12903226 16 110 82.94466 27.05533597 17 128 82.94466 45.05533597 18 70 82.94466 -12.94466403 19 72 82.94466 -10.94466403 20 115 82.94466 32.05533597 21 123 82.94466 40.05533597 22 150 82.94466 67.05533597 23 88 82.94466 5.05533597 24 97 82.94466 14.05533597 25 118 82.94466 35.05533597 26 121 82.94466 38.05533597 27 126 67.12903 58.87096774 28 67 82.94466 -15.94466403 29 100 67.12903 32.87096774 30 164 82.94466 81.05533597 31 74 67.12903 6.87096774 32 129 82.94466 46.05533597 33 89 67.12903 21.87096774 34 93 67.12903 25.87096774 35 80 67.12903 12.87096774 36 173 82.94466 90.05533597 37 86 82.94466 3.05533597 38 21 67.12903 -46.12903226 39 94 82.94466 11.05533597 40 45 82.94466 -37.94466403 41 115 67.12903 47.87096774 42 76 82.94466 -6.94466403 43 34 67.12903 -33.12903226 44 106 67.12903 38.87096774 45 64 82.94466 -18.94466403 46 97 67.12903 29.87096774 47 32 82.94466 -50.94466403 48 62 82.94466 -20.94466403 49 129 67.12903 61.87096774 50 96 82.94466 13.05533597 51 152 82.94466 69.05533597 52 99 82.94466 16.05533597 53 102 82.94466 19.05533597 54 94 67.12903 26.87096774 55 145 67.12903 77.87096774 56 126 82.94466 43.05533597 57 90 82.94466 7.05533597 58 85 82.94466 2.05533597 59 77 67.12903 9.87096774 60 123 67.12903 55.87096774 61 94 67.12903 26.87096774 62 177 82.94466 94.05533597 63 133 82.94466 50.05533597 64 41 67.12903 -26.12903226 65 116 67.12903 48.87096774 66 92 82.94466 9.05533597 67 54 82.94466 -28.94466403 68 23 67.12903 -44.12903226 69 154 82.94466 71.05533597 70 22 82.94466 -60.94466403 71 126 82.94466 43.05533597 72 110 82.94466 27.05533597 73 135 67.12903 67.87096774 74 75 82.94466 -7.94466403 75 101 67.12903 33.87096774 76 112 67.12903 44.87096774 77 24 82.94466 -58.94466403 78 61 82.94466 -21.94466403 79 126 67.12903 58.87096774 80 134 67.12903 66.87096774 81 95 82.94466 12.05533597 82 148 67.12903 80.87096774 83 47 67.12903 -20.12903226 84 77 82.94466 -5.94466403 85 140 82.94466 57.05533597 86 124 82.94466 41.05533597 87 138 82.94466 55.05533597 88 96 67.12903 28.87096774 89 48 67.12903 -19.12903226 90 147 67.12903 79.87096774 91 95 67.12903 27.87096774 92 78 82.94466 -4.94466403 93 105 82.94466 22.05533597 94 33 67.12903 -34.12903226 95 90 82.94466 7.05533597 96 132 82.94466 49.05533597 97 71 82.94466 -11.94466403 98 90 82.94466 7.05533597 99 127 82.94466 44.05533597 100 67 82.94466 -15.94466403 101 50 82.94466 -32.94466403 102 104 82.94466 21.05533597 103 161 67.12903 93.87096774 104 95 67.12903 27.87096774 105 51 67.12903 -16.12903226 106 107 67.12903 39.87096774 107 157 82.94466 74.05533597 108 178 82.94466 95.05533597 109 108 82.94466 25.05533597 110 162 82.94466 79.05533597 111 35 67.12903 -32.12903226 112 40 67.12903 -27.12903226 113 113 82.94466 30.05533597 114 80 82.94466 -2.94466403 115 54 82.94466 -28.94466403 116 85 82.94466 2.05533597 117 121 67.12903 53.87096774 118 102 67.12903 34.87096774 119 43 82.94466 -39.94466403 120 70 67.12903 2.87096774 121 108 67.12903 40.87096774 122 73 82.94466 -9.94466403 123 126 82.94466 43.05533597 124 125 67.12903 57.87096774 125 81 82.94466 -1.94466403 126 27 82.94466 -55.94466403 127 5 82.94466 -77.94466403 128 77 67.12903 9.87096774 129 84 82.94466 1.05533597 130 76 67.12903 8.87096774 131 40 82.94466 -42.94466403 132 61 82.94466 -21.94466403 133 46 82.94466 -36.94466403 134 43 67.12903 -24.12903226 135 48 82.94466 -34.94466403 136 55 82.94466 -27.94466403 137 35 67.12903 -32.12903226 138 50 82.94466 -32.94466403 139 64 67.12903 -3.12903226 140 37 82.94466 -45.94466403 141 58 82.94466 -24.94466403 142 74 67.12903 6.87096774 143 76 67.12903 8.87096774 144 58 82.94466 -24.94466403 145 61 82.94466 -21.94466403 146 78 82.94466 -4.94466403 147 61 82.94466 -21.94466403 148 47 82.94466 -35.94466403 149 5 67.12903 -62.12903226 150 118 82.94466 35.05533597 151 47 82.94466 -35.94466403 152 71 82.94466 -11.94466403 153 49 82.94466 -33.94466403 154 19 67.12903 -48.12903226 155 53 82.94466 -29.94466403 156 97 82.94466 14.05533597 157 63 82.94466 -19.94466403 158 46 82.94466 -36.94466403 159 43 82.94466 -39.94466403 160 25 67.12903 -42.12903226 161 69 82.94466 -13.94466403 162 35 67.12903 -32.12903226 163 58 67.12903 -9.12903226 164 0 67.12903 -67.12903226 165 20 82.94466 -62.94466403 166 54 67.12903 -13.12903226 167 55 67.12903 -12.12903226 168 31 82.94466 -51.94466403 169 47 82.94466 -35.94466403 170 56 67.12903 -11.12903226 171 46 82.94466 -36.94466403 172 96 82.94466 13.05533597 173 56 67.12903 -11.12903226 174 53 82.94466 -29.94466403 175 63 82.94466 -19.94466403 176 76 67.12903 8.87096774 177 74 82.94466 -8.94466403 178 53 82.94466 -29.94466403 179 30 82.94466 -52.94466403 180 67 67.12903 -0.12903226 181 21 82.94466 -61.94466403 182 62 82.94466 -20.94466403 183 43 67.12903 -24.12903226 184 30 67.12903 -37.12903226 185 36 82.94466 -46.94466403 186 70 67.12903 2.87096774 187 44 82.94466 -38.94466403 188 14 67.12903 -53.12903226 189 108 67.12903 40.87096774 190 52 67.12903 -15.12903226 191 109 82.94466 26.05533597 192 58 82.94466 -24.94466403 193 19 67.12903 -48.12903226 194 129 82.94466 46.05533597 195 28 82.94466 -54.94466403 196 25 67.12903 -42.12903226 197 44 82.94466 -38.94466403 198 42 67.12903 -25.12903226 199 40 67.12903 -27.12903226 200 58 82.94466 -24.94466403 201 26 82.94466 -56.94466403 202 49 82.94466 -33.94466403 203 24 82.94466 -58.94466403 204 19 67.12903 -48.12903226 205 86 82.94466 3.05533597 206 66 67.12903 -1.12903226 207 39 67.12903 -28.12903226 208 90 67.12903 22.87096774 209 32 82.94466 -50.94466403 210 45 82.94466 -37.94466403 211 66 67.12903 -1.12903226 212 61 67.12903 -6.12903226 213 36 67.12903 -31.12903226 214 84 82.94466 1.05533597 215 89 82.94466 6.05533597 216 54 67.12903 -13.12903226 217 85 82.94466 2.05533597 218 55 67.12903 -12.12903226 219 48 67.12903 -19.12903226 220 42 82.94466 -40.94466403 221 45 82.94466 -37.94466403 222 58 67.12903 -9.12903226 223 57 82.94466 -25.94466403 224 55 67.12903 -12.12903226 225 56 82.94466 -26.94466403 226 80 82.94466 -2.94466403 227 137 82.94466 54.05533597 228 94 67.12903 26.87096774 229 74 82.94466 -8.94466403 230 71 82.94466 -11.94466403 231 122 82.94466 39.05533597 232 157 82.94466 74.05533597 233 2 82.94466 -80.94466403 234 139 82.94466 56.05533597 235 103 82.94466 20.05533597 236 132 82.94466 49.05533597 237 75 82.94466 -7.94466403 238 37 67.12903 -30.12903226 239 64 82.94466 -18.94466403 240 128 67.12903 60.87096774 241 153 82.94466 70.05533597 242 77 82.94466 -5.94466403 243 0 82.94466 -82.94466403 244 130 82.94466 47.05533597 245 134 82.94466 51.05533597 246 65 67.12903 -2.12903226 247 134 67.12903 66.87096774 248 116 82.94466 33.05533597 249 128 67.12903 60.87096774 250 69 67.12903 1.87096774 251 71 82.94466 -11.94466403 252 57 82.94466 -25.94466403 253 139 82.94466 56.05533597 254 88 67.12903 20.87096774 255 97 82.94466 14.05533597 256 42 67.12903 -25.12903226 257 187 82.94466 104.05533597 258 15 67.12903 -52.12903226 259 60 82.94466 -22.94466403 260 94 82.94466 11.05533597 261 95 82.94466 12.05533597 262 36 82.94466 -46.94466403 263 109 82.94466 26.05533597 264 94 67.12903 26.87096774 265 180 82.94466 97.05533597 266 65 67.12903 -2.12903226 267 132 67.12903 64.87096774 268 61 67.12903 -6.12903226 269 115 82.94466 32.05533597 270 78 82.94466 -4.94466403 271 162 82.94466 79.05533597 272 103 82.94466 20.05533597 273 172 82.94466 89.05533597 274 147 82.94466 64.05533597 275 114 67.12903 46.87096774 276 54 82.94466 -28.94466403 277 74 67.12903 6.87096774 278 117 67.12903 49.87096774 279 145 82.94466 62.05533597 280 120 82.94466 37.05533597 281 95 67.12903 27.87096774 282 68 82.94466 -14.94466403 283 25 67.12903 -42.12903226 284 157 82.94466 74.05533597 285 17 67.12903 -50.12903226 286 147 82.94466 64.05533597 287 6 67.12903 -61.12903226 288 108 82.94466 25.05533597 289 262 82.94466 179.05533597 290 153 82.94466 70.05533597 291 135 67.12903 67.87096774 292 137 67.12903 69.87096774 293 55 67.12903 -12.12903226 294 138 82.94466 55.05533597 295 86 67.12903 18.87096774 296 95 82.94466 12.05533597 297 31 67.12903 -36.12903226 298 114 82.94466 31.05533597 299 56 67.12903 -11.12903226 300 53 67.12903 -14.12903226 301 174 67.12903 106.87096774 302 144 82.94466 61.05533597 303 27 82.94466 -55.94466403 304 84 82.94466 1.05533597 305 112 82.94466 29.05533597 306 122 82.94466 39.05533597 307 232 82.94466 149.05533597 308 38 67.12903 -29.12903226 309 112 82.94466 29.05533597 310 169 82.94466 86.05533597 311 77 67.12903 9.87096774 312 155 82.94466 72.05533597 313 72 82.94466 -10.94466403 314 107 67.12903 39.87096774 315 158 82.94466 75.05533597 316 84 67.12903 16.87096774 317 61 82.94466 -21.94466403 318 107 82.94466 24.05533597 319 81 67.12903 13.87096774 320 90 82.94466 7.05533597 321 56 67.12903 -11.12903226 322 42 82.94466 -40.94466403 323 144 82.94466 61.05533597 324 43 82.94466 -39.94466403 325 116 82.94466 33.05533597 326 110 67.12903 42.87096774 327 94 67.12903 26.87096774 328 124 82.94466 41.05533597 329 55 82.94466 -27.94466403 330 115 82.94466 32.05533597 331 21 82.94466 -61.94466403 332 94 82.94466 11.05533597 333 72 82.94466 -10.94466403 334 73 82.94466 -9.94466403 335 22 67.12903 -45.12903226 336 48 67.12903 -19.12903226 337 50 82.94466 -32.94466403 338 102 67.12903 34.87096774 339 7 82.94466 -75.94466403 340 68 82.94466 -14.94466403 341 20 82.94466 -62.94466403 342 2 82.94466 -80.94466403 343 41 67.12903 -26.12903226 344 32 82.94466 -50.94466403 345 52 82.94466 -30.94466403 346 20 67.12903 -47.12903226 347 40 67.12903 -27.12903226 348 0 67.12903 -67.12903226 349 44 82.94466 -38.94466403 350 23 82.94466 -59.94466403 351 157 82.94466 74.05533597 352 57 67.12903 -10.12903226 353 43 67.12903 -24.12903226 354 17 82.94466 -65.94466403 355 23 82.94466 -59.94466403 356 44 67.12903 -23.12903226 357 158 82.94466 75.05533597 358 74 67.12903 6.87096774 359 37 67.12903 -30.12903226 360 1 82.94466 -81.94466403 361 30 67.12903 -37.12903226 362 100 82.94466 17.05533597 363 75 82.94466 -7.94466403 364 24 67.12903 -43.12903226 365 29 82.94466 -53.94466403 366 42 82.94466 -40.94466403 367 97 67.12903 29.87096774 368 4 82.94466 -78.94466403 369 29 82.94466 -53.94466403 370 93 82.94466 10.05533597 371 19 67.12903 -48.12903226 372 43 82.94466 -39.94466403 373 30 82.94466 -52.94466403 374 55 82.94466 -27.94466403 375 1 67.12903 -66.12903226 376 20 82.94466 -62.94466403 377 33 67.12903 -34.12903226 378 79 82.94466 -3.94466403 379 25 82.94466 -57.94466403 380 101 82.94466 18.05533597 381 94 82.94466 11.05533597 382 1 82.94466 -81.94466403 383 22 82.94466 -60.94466403 384 30 67.12903 -37.12903226 385 23 67.12903 -44.12903226 386 83 82.94466 0.05533597 387 40 67.12903 -27.12903226 388 28 67.12903 -39.12903226 389 2 82.94466 -80.94466403 390 26 67.12903 -41.12903226 391 58 67.12903 -9.12903226 392 52 67.12903 -15.12903226 393 41 82.94466 -41.94466403 394 32 82.94466 -50.94466403 395 17 67.12903 -50.12903226 396 14 82.94466 -68.94466403 397 136 82.94466 53.05533597 398 22 67.12903 -45.12903226 399 119 82.94466 36.05533597 400 80 82.94466 -2.94466403 401 33 82.94466 -49.94466403 402 34 67.12903 -33.12903226 403 59 82.94466 -23.94466403 404 13 82.94466 -69.94466403 405 49 82.94466 -33.94466403 406 57 82.94466 -25.94466403 407 22 82.94466 -60.94466403 408 46 67.12903 -21.12903226 > 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/45m731334679285.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/5u4d01334679285.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/6dl3a1334679285.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/7a8jh1334679285.tab") + } > > try(system("convert tmp/219341334679285.ps tmp/219341334679285.png",intern=TRUE)) character(0) > try(system("convert tmp/334521334679285.ps tmp/334521334679285.png",intern=TRUE)) character(0) > try(system("convert tmp/45m731334679285.ps tmp/45m731334679285.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.785 0.293 7.073