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 = 'CSUQ' > par8 = 'CSUQ' > par7 = 'all' > 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] 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 100 110 107 107 93 106 121 112 98 93 107 96 110 84 [145] 119 134 139 149 118 95 120 120 107 121 61 118 118 109 113 124 93 143 [163] 112 100 87 130 106 121 120 111 110 115 133 100 126 102 115 126 123 114 [181] 76 115 112 81 77 92 114 99 38 107 92 141 120 124 129 103 118 111 [199] 84 84 123 124 112 114 97 132 104 110 127 131 136 87 87 94 135 124 [217] 102 138 90 71 112 105 108 118 80 112 151 118 95 138 101 121 134 130 [235] 121 130 131 117 86 126 122 110 129 87 150 109 137 111 138 123 82 120 [253] 118 99 69 126 119 116 101 132 85 128 82 128 143 125 147 111 108 122 [271] 84 117 120 77 100 134 123 123 123 128 108 118 107 105 111 112 121 92 [289] 97 99 111 93 121 86 125 96 126 108 99 137 105 69 82 115 96 91 [307] 128 91 92 78 116 125 113 130 131 111 126 122 130 114 102 121 122 81 [325] 129 124 89 139 99 127 123 87 129 97 119 126 104 109 127 52 125 114 [343] 105 122 128 126 107 110 126 131 123 125 117 144 128 127 136 120 102 97 [361] 115 119 118 87 107 95 125 118 136 105 116 115 123 97 104 129 104 91 [379] 121 113 120 106 104 94 133 124 107 80 112 115 66 126 128 133 122 140 [397] 133 130 92 141 118 119 129 94 138 114 125 116 132 116 110 117 122 130 [415] 98 86 128 142 121 109 133 89 115 66 117 89 124 144 123 103 112 136 [433] 94 122 140 112 126 133 141 119 114 142 149 91 130 132 99 > 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]) 38 52 61 66 67 69 71 76 77 78 80 81 82 84 85 86 87 88 89 90 1 1 1 2 1 3 1 1 2 1 3 3 4 4 1 3 7 1 3 1 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 6 5 4 4 6 5 8 3 9 7 4 4 2 5 8 7 11 7 6 8 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 8 14 5 8 9 7 8 12 13 9 12 14 12 11 10 17 6 11 8 12 131 132 133 134 135 136 137 138 139 140 141 142 143 144 147 149 150 151 153 6 8 8 7 3 6 4 5 2 4 6 4 3 4 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 100 110 107 107 93 106 121 112 98 93 107 96 110 84 [145] 119 134 139 149 118 95 120 120 107 121 61 118 118 109 113 124 93 143 [163] 112 100 87 130 106 121 120 111 110 115 133 100 126 102 115 126 123 114 [181] 76 115 112 81 77 92 114 99 38 107 92 141 120 124 129 103 118 111 [199] 84 84 123 124 112 114 97 132 104 110 127 131 136 87 87 94 135 124 [217] 102 138 90 71 112 105 108 118 80 112 151 118 95 138 101 121 134 130 [235] 121 130 131 117 86 126 122 110 129 87 150 109 137 111 138 123 82 120 [253] 118 99 69 126 119 116 101 132 85 128 82 128 143 125 147 111 108 122 [271] 84 117 120 77 100 134 123 123 123 128 108 118 107 105 111 112 121 92 [289] 97 99 111 93 121 86 125 96 126 108 99 137 105 69 82 115 96 91 [307] 128 91 92 78 116 125 113 130 131 111 126 122 130 114 102 121 122 81 [325] 129 124 89 139 99 127 123 87 129 97 119 126 104 109 127 52 125 114 [343] 105 122 128 126 107 110 126 131 123 125 117 144 128 127 136 120 102 97 [361] 115 119 118 87 107 95 125 118 136 105 116 115 123 97 104 129 104 91 [379] 121 113 120 106 104 94 133 124 107 80 112 115 66 126 128 133 122 140 [397] 133 130 92 141 118 119 129 94 138 114 125 116 132 116 110 117 122 130 [415] 98 86 128 142 121 109 133 89 115 66 117 89 124 144 123 103 112 136 [433] 94 122 140 112 126 133 141 119 114 142 149 91 130 132 99 > 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/1xx6v1334678825.tab") + } + } > m Conditional inference tree with 27 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: 447 1) U20 <= 3; criterion = 1, statistic = 302.335 2) U1 <= 2; criterion = 1, statistic = 64.335 3) U31 <= 2; criterion = 1, statistic = 24.846 4)* weights = 16 3) U31 > 2 5) U16 <= 3; criterion = 0.98, statistic = 11.779 6)* weights = 21 5) U16 > 3 7)* weights = 12 2) U1 > 2 8) U21 <= 2; criterion = 1, statistic = 34.538 9) U22 <= 2; criterion = 0.978, statistic = 11.598 10)* weights = 12 9) U22 > 2 11)* weights = 14 8) U21 > 2 12) U1 <= 3; criterion = 1, statistic = 19.065 13) U14 <= 2; criterion = 0.969, statistic = 10.94 14)* weights = 16 13) U14 > 2 15)* weights = 24 12) U1 > 3 16) U6 <= 3; criterion = 0.979, statistic = 11.647 17)* weights = 14 16) U6 > 3 18)* weights = 9 1) U20 > 3 19) U22 <= 4; criterion = 1, statistic = 106.451 20) U5 <= 4; criterion = 1, statistic = 60.046 21) U29 <= 3; criterion = 1, statistic = 53.134 22) U30 <= 3; criterion = 1, statistic = 19.615 23)* weights = 27 22) U30 > 3 24)* weights = 23 21) U29 > 3 25) U21 <= 3; criterion = 1, statistic = 34.484 26) U7 <= 3; criterion = 0.999, statistic = 18.125 27)* weights = 15 26) U7 > 3 28) U10 <= 2; criterion = 0.954, statistic = 10.178 29)* weights = 17 28) U10 > 2 30)* weights = 23 25) U21 > 3 31) U3 <= 3; criterion = 1, statistic = 31.327 32)* weights = 19 31) U3 > 3 33) U13 <= 3; criterion = 1, statistic = 25.769 34) U19 <= 3; criterion = 0.983, statistic = 13.502 35)* weights = 10 34) U19 > 3 36)* weights = 21 33) U13 > 3 37) U12 <= 3; criterion = 0.999, statistic = 16.924 38)* weights = 12 37) U12 > 3 39) U17 <= 3; criterion = 0.989, statistic = 12.787 40)* weights = 8 39) U17 > 3 41)* weights = 24 20) U5 > 4 42)* weights = 19 19) U22 > 4 43) U1 <= 4; criterion = 1, statistic = 45.176 44) U30 <= 3; criterion = 1, statistic = 26.261 45)* weights = 11 44) U30 > 3 46) U32 <= 3; criterion = 0.998, statistic = 16.567 47) U17 <= 3; criterion = 0.964, statistic = 10.643 48)* weights = 11 47) U17 > 3 49)* weights = 9 46) U32 > 3 50)* weights = 30 43) U1 > 4 51) U18 <= 4; criterion = 0.976, statistic = 11.362 52)* weights = 22 51) U18 > 4 53)* weights = 8 > postscript(file="/var/wessaorg/rcomp/tmp/2aiyy1334678825.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/35jts1334678825.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.78261 -1.78260870 2 143 146.75000 -3.75000000 3 141 138.72727 2.27272727 4 137 132.73333 4.26666667 5 141 138.72727 2.27272727 6 109 117.52632 -8.52631579 7 105 110.80000 -5.80000000 8 111 104.25000 6.75000000 9 153 146.75000 6.25000000 10 99 104.25000 -5.25000000 11 134 130.66667 3.33333333 12 122 116.36364 5.63636364 13 124 123.00000 1.00000000 14 119 117.52632 1.47368421 15 91 95.75000 -4.75000000 16 122 120.78261 1.21739130 17 136 132.73333 3.26666667 18 131 132.73333 -1.73333333 19 129 130.66667 -1.66666667 20 135 138.72727 -3.72727273 21 120 123.00000 -3.00000000 22 119 120.78261 -1.78260870 23 119 123.57143 -4.57142857 24 125 120.72727 4.27272727 25 118 116.65217 1.34782609 26 138 130.66667 7.33333333 27 123 130.66667 -7.66666667 28 114 123.57143 -9.57142857 29 134 132.73333 1.26666667 30 97 104.25000 -7.25000000 31 130 130.66667 -0.66666667 32 112 110.80000 1.20000000 33 126 120.78261 5.21739130 34 107 107.92857 -0.92857143 35 106 110.80000 -4.80000000 36 110 110.80000 -0.80000000 37 137 138.72727 -1.72727273 38 130 130.66667 -0.66666667 39 105 98.28571 6.71428571 40 106 98.81250 7.18750000 41 144 132.73333 11.26666667 42 129 130.66667 -1.66666667 43 140 128.44444 11.55555556 44 112 110.80000 1.20000000 45 108 117.52632 -9.52631579 46 113 104.25000 8.75000000 47 116 120.72727 -4.72727273 48 116 120.78261 -4.78260870 49 135 130.66667 4.33333333 50 95 95.75000 -0.75000000 51 101 107.92857 -6.92857143 52 122 120.78261 1.21739130 53 123 123.00000 0.00000000 54 126 128.44444 -2.44444444 55 121 116.65217 4.34782609 56 106 104.25000 1.75000000 57 100 105.33333 -5.33333333 58 126 130.66667 -4.66666667 59 132 132.73333 -0.73333333 60 87 86.04762 0.95238095 61 117 117.70000 -0.70000000 62 100 104.25000 -4.25000000 63 128 132.73333 -4.73333333 64 140 138.72727 1.27272727 65 117 117.52632 -0.52631579 66 132 116.36364 15.63636364 67 107 105.33333 1.66666667 68 133 132.05263 0.94736842 69 80 71.87500 8.12500000 70 133 132.73333 0.26666667 71 119 120.78261 -1.78260870 72 132 123.00000 9.00000000 73 142 146.75000 -4.75000000 74 69 71.87500 -2.87500000 75 141 138.72727 2.27272727 76 125 117.70000 7.30000000 77 95 107.92857 -12.92857143 78 119 120.78261 -1.78260870 79 136 132.05263 3.94736842 80 108 105.33333 2.66666667 81 112 105.33333 6.66666667 82 115 105.33333 9.66666667 83 100 107.92857 -7.92857143 84 82 86.04762 -4.04761905 85 122 117.52632 4.47368421 86 142 132.05263 9.94736842 87 147 132.05263 14.94736842 88 132 138.72727 -6.72727273 89 98 98.81250 -0.81250000 90 67 84.83333 -17.83333333 91 130 123.57143 6.42857143 92 91 98.81250 -7.81250000 93 124 117.55556 6.44444444 94 122 124.75000 -2.75000000 95 96 105.33333 -9.33333333 96 127 128.44444 -1.44444444 97 124 124.75000 -0.75000000 98 127 132.05263 -5.05263158 99 144 132.73333 11.26666667 100 134 130.66667 3.33333333 101 108 120.78261 -12.78260870 102 130 130.66667 -0.66666667 103 151 146.75000 4.25000000 104 113 116.36364 -3.36363636 105 81 71.87500 9.12500000 106 101 107.92857 -6.92857143 107 109 117.55556 -8.55555556 108 126 124.75000 1.25000000 109 134 138.72727 -4.72727273 110 128 132.73333 -4.73333333 111 128 117.52632 10.47368421 112 125 123.57143 1.42857143 113 88 86.04762 1.95238095 114 117 120.72727 -3.72727273 115 112 116.88235 -4.88235294 116 97 105.33333 -8.33333333 117 99 117.52632 -18.52631579 118 96 98.81250 -2.81250000 119 105 107.92857 -2.92857143 120 121 116.88235 4.11764706 121 95 116.36364 -21.36363636 122 131 132.73333 -1.73333333 123 122 116.65217 5.34782609 124 97 98.81250 -1.81250000 125 106 95.75000 10.25000000 126 119 120.72727 -1.72727273 127 124 117.70000 6.30000000 128 126 130.66667 -4.66666667 129 99 104.25000 -5.25000000 130 126 117.55556 8.44444444 131 100 98.28571 1.71428571 132 110 117.70000 -7.70000000 133 107 104.25000 2.75000000 134 107 105.33333 1.66666667 135 93 95.75000 -2.75000000 136 106 95.75000 10.25000000 137 121 138.72727 -17.72727273 138 112 104.25000 7.75000000 139 98 98.28571 -0.28571429 140 93 86.04762 6.95238095 141 107 105.33333 1.66666667 142 96 105.33333 -9.33333333 143 110 116.65217 -6.65217391 144 84 86.04762 -2.04761905 145 119 120.78261 -1.78260870 146 134 130.66667 3.33333333 147 139 138.72727 0.27272727 148 149 146.75000 2.25000000 149 118 116.88235 1.11764706 150 95 105.33333 -10.33333333 151 120 105.33333 14.66666667 152 120 120.78261 -0.78260870 153 107 132.05263 -25.05263158 154 121 116.88235 4.11764706 155 61 71.87500 -10.87500000 156 118 123.57143 -5.57142857 157 118 117.52632 0.47368421 158 109 116.65217 -7.65217391 159 113 116.36364 -3.36363636 160 124 128.44444 -4.44444444 161 93 95.75000 -2.75000000 162 143 132.05263 10.94736842 163 112 117.52632 -5.52631579 164 100 116.65217 -16.65217391 165 87 84.83333 2.16666667 166 130 132.05263 -2.05263158 167 106 110.80000 -4.80000000 168 121 123.57143 -2.57142857 169 120 120.78261 -0.78260870 170 111 105.33333 5.66666667 171 110 104.25000 5.75000000 172 115 123.00000 -8.00000000 173 133 132.05263 0.94736842 174 100 98.81250 1.18750000 175 126 130.66667 -4.66666667 176 102 104.25000 -2.25000000 177 115 110.80000 4.20000000 178 126 117.52632 8.47368421 179 123 116.36364 6.63636364 180 114 116.88235 -2.88235294 181 76 84.83333 -8.83333333 182 115 116.65217 -1.65217391 183 112 116.88235 -4.88235294 184 81 86.04762 -5.04761905 185 77 86.04762 -9.04761905 186 92 84.83333 7.16666667 187 114 110.80000 3.20000000 188 99 105.33333 -6.33333333 189 38 71.87500 -33.87500000 190 107 107.92857 -0.92857143 191 92 86.04762 5.95238095 192 141 138.72727 2.27272727 193 120 117.55556 2.44444444 194 124 120.72727 3.27272727 195 129 132.73333 -3.73333333 196 103 98.28571 4.71428571 197 118 110.80000 7.20000000 198 111 105.33333 5.66666667 199 84 105.33333 -21.33333333 200 84 84.83333 -0.83333333 201 123 116.65217 6.34782609 202 124 123.57143 0.42857143 203 112 116.65217 -4.65217391 204 114 117.52632 -3.52631579 205 97 71.87500 25.12500000 206 132 132.05263 -0.05263158 207 104 110.80000 -6.80000000 208 110 110.80000 -0.80000000 209 127 116.36364 10.63636364 210 131 130.66667 0.33333333 211 136 146.75000 -10.75000000 212 87 86.04762 0.95238095 213 87 98.28571 -11.28571429 214 94 86.04762 7.95238095 215 135 132.73333 2.26666667 216 124 123.57143 0.42857143 217 102 98.28571 3.71428571 218 138 138.72727 -0.72727273 219 90 86.04762 3.95238095 220 71 71.87500 -0.87500000 221 112 116.36364 -4.36363636 222 105 116.88235 -11.88235294 223 108 110.80000 -2.80000000 224 118 116.65217 1.34782609 225 80 84.83333 -4.83333333 226 112 116.36364 -4.36363636 227 151 146.75000 4.25000000 228 118 123.57143 -5.57142857 229 95 95.75000 -0.75000000 230 138 132.05263 5.94736842 231 101 98.81250 2.18750000 232 121 120.72727 0.27272727 233 134 132.73333 1.26666667 234 130 132.05263 -2.05263158 235 121 123.57143 -2.57142857 236 130 120.78261 9.21739130 237 131 132.05263 -1.05263158 238 117 120.78261 -3.78260870 239 86 98.28571 -12.28571429 240 126 130.66667 -4.66666667 241 122 116.88235 5.11764706 242 110 105.33333 4.66666667 243 129 120.72727 8.27272727 244 87 84.83333 2.16666667 245 150 130.66667 19.33333333 246 109 116.65217 -7.65217391 247 137 132.05263 4.94736842 248 111 116.65217 -5.65217391 249 138 132.73333 5.26666667 250 123 132.73333 -9.73333333 251 82 86.04762 -4.04761905 252 120 132.73333 -12.73333333 253 118 123.57143 -5.57142857 254 99 98.81250 0.18750000 255 69 71.87500 -2.87500000 256 126 116.88235 9.11764706 257 119 123.00000 -4.00000000 258 116 107.92857 8.07142857 259 101 116.65217 -15.65217391 260 132 116.65217 15.34782609 261 85 84.83333 0.16666667 262 128 130.66667 -2.66666667 263 82 86.04762 -4.04761905 264 128 124.75000 3.25000000 265 143 138.72727 4.27272727 266 125 116.65217 8.34782609 267 147 138.72727 8.27272727 268 111 116.65217 -5.65217391 269 108 117.52632 -9.52631579 270 122 124.75000 -2.75000000 271 84 84.83333 -0.83333333 272 117 116.88235 0.11764706 273 120 117.55556 2.44444444 274 77 86.04762 -9.04761905 275 100 104.25000 -4.25000000 276 134 132.05263 1.94736842 277 123 132.73333 -9.73333333 278 123 120.78261 2.21739130 279 123 132.73333 -9.73333333 280 128 116.65217 11.34782609 281 108 116.65217 -8.65217391 282 118 117.70000 0.30000000 283 107 105.33333 1.66666667 284 105 117.55556 -12.55555556 285 111 110.80000 0.20000000 286 112 104.25000 7.75000000 287 121 116.88235 4.11764706 288 92 84.83333 7.16666667 289 97 84.83333 12.16666667 290 99 104.25000 -5.25000000 291 111 104.25000 6.75000000 292 93 86.04762 6.95238095 293 121 120.78261 0.21739130 294 86 86.04762 -0.04761905 295 125 128.44444 -3.44444444 296 96 98.28571 -2.28571429 297 126 120.78261 5.21739130 298 108 116.88235 -8.88235294 299 99 95.75000 3.25000000 300 137 138.72727 -1.72727273 301 105 98.28571 6.71428571 302 69 71.87500 -2.87500000 303 82 71.87500 10.12500000 304 115 107.92857 7.07142857 305 96 98.28571 -2.28571429 306 91 71.87500 19.12500000 307 128 130.66667 -2.66666667 308 91 95.75000 -4.75000000 309 92 105.33333 -13.33333333 310 78 71.87500 6.12500000 311 116 117.70000 -1.70000000 312 125 123.00000 2.00000000 313 113 120.78261 -7.78260870 314 130 130.66667 -0.66666667 315 131 116.65217 14.34782609 316 111 104.25000 6.75000000 317 126 120.78261 5.21739130 318 122 116.88235 5.11764706 319 130 123.57143 6.42857143 320 114 107.92857 6.07142857 321 102 98.28571 3.71428571 322 121 117.52632 3.47368421 323 122 123.57143 -1.57142857 324 81 86.04762 -5.04761905 325 129 132.73333 -3.73333333 326 124 117.52632 6.47368421 327 89 86.04762 2.95238095 328 139 132.73333 6.26666667 329 99 98.81250 0.18750000 330 127 120.72727 6.27272727 331 123 116.65217 6.34782609 332 87 86.04762 0.95238095 333 129 124.75000 4.25000000 334 97 98.81250 -1.81250000 335 119 116.88235 2.11764706 336 126 128.44444 -2.44444444 337 104 105.33333 -1.33333333 338 109 117.70000 -8.70000000 339 127 123.00000 4.00000000 340 52 71.87500 -19.87500000 341 125 120.78261 4.21739130 342 114 117.55556 -3.55555556 343 105 98.81250 6.18750000 344 122 124.75000 -2.75000000 345 128 132.73333 -4.73333333 346 126 116.65217 9.34782609 347 107 117.55556 -10.55555556 348 110 98.28571 11.71428571 349 126 123.57143 2.42857143 350 131 128.44444 2.55555556 351 123 117.52632 5.47368421 352 125 124.75000 0.25000000 353 117 120.72727 -3.72727273 354 144 138.72727 5.27272727 355 128 132.05263 -4.05263158 356 127 132.05263 -5.05263158 357 136 128.44444 7.55555556 358 120 117.52632 2.47368421 359 102 105.33333 -3.33333333 360 97 98.28571 -1.28571429 361 115 116.36364 -1.36363636 362 119 116.88235 2.11764706 363 118 120.78261 -2.78260870 364 87 84.83333 2.16666667 365 107 107.92857 -0.92857143 366 95 95.75000 -0.75000000 367 125 123.00000 2.00000000 368 118 123.00000 -5.00000000 369 136 132.73333 3.26666667 370 105 104.25000 0.75000000 371 116 98.81250 17.18750000 372 115 105.33333 9.66666667 373 123 117.52632 5.47368421 374 97 104.25000 -7.25000000 375 104 104.25000 -0.25000000 376 129 123.00000 6.00000000 377 104 104.25000 -0.25000000 378 91 95.75000 -4.75000000 379 121 128.44444 -7.44444444 380 113 116.65217 -3.65217391 381 120 123.57143 -3.57142857 382 106 105.33333 0.66666667 383 104 104.25000 -0.25000000 384 94 104.25000 -10.25000000 385 133 132.73333 0.26666667 386 124 132.05263 -8.05263158 387 107 104.25000 2.75000000 388 80 71.87500 8.12500000 389 112 105.33333 6.66666667 390 115 116.88235 -1.88235294 391 66 71.87500 -5.87500000 392 126 130.66667 -4.66666667 393 128 117.52632 10.47368421 394 133 130.66667 2.33333333 395 122 110.80000 11.20000000 396 140 132.73333 7.26666667 397 133 117.55556 15.44444444 398 130 132.73333 -2.73333333 399 92 98.81250 -6.81250000 400 141 132.73333 8.26666667 401 118 117.70000 0.30000000 402 119 107.92857 11.07142857 403 129 123.57143 5.42857143 404 94 95.75000 -1.75000000 405 138 132.73333 5.26666667 406 114 117.52632 -3.52631579 407 125 123.57143 1.42857143 408 116 116.36364 -0.36363636 409 132 138.72727 -6.72727273 410 116 105.33333 10.66666667 411 110 107.92857 2.07142857 412 117 116.65217 0.34782609 413 122 123.57143 -1.57142857 414 130 123.57143 6.42857143 415 98 104.25000 -6.25000000 416 86 86.04762 -0.04761905 417 128 120.78261 7.21739130 418 142 138.72727 3.27272727 419 121 120.72727 0.27272727 420 109 110.80000 -1.80000000 421 133 123.57143 9.42857143 422 89 98.28571 -9.28571429 423 115 116.88235 -1.88235294 424 66 71.87500 -5.87500000 425 117 117.70000 -0.70000000 426 89 86.04762 2.95238095 427 124 130.66667 -6.66666667 428 144 138.72727 5.27272727 429 123 117.70000 5.30000000 430 103 105.33333 -2.33333333 431 112 120.72727 -8.72727273 432 136 130.66667 5.33333333 433 94 98.81250 -4.81250000 434 122 120.78261 1.21739130 435 140 138.72727 1.27272727 436 112 105.33333 6.66666667 437 126 123.57143 2.42857143 438 133 132.73333 0.26666667 439 141 138.72727 2.27272727 440 119 123.00000 -4.00000000 441 114 107.92857 6.07142857 442 142 138.72727 3.27272727 443 149 146.75000 2.25000000 444 91 98.81250 -7.81250000 445 130 132.05263 -2.05263158 446 132 132.73333 -0.73333333 447 99 98.81250 0.18750000 > 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/4bc4j1334678825.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/5xjc51334678825.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/63zs31334678826.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/7vvns1334678826.tab") + } > > try(system("convert tmp/2aiyy1334678825.ps tmp/2aiyy1334678825.png",intern=TRUE)) character(0) > try(system("convert tmp/35jts1334678825.ps tmp/35jts1334678825.png",intern=TRUE)) character(0) > try(system("convert tmp/4bc4j1334678825.ps tmp/4bc4j1334678825.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 8.811 0.316 9.141