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 = 'COLLES actuals' > par8 = 'COLLES actuals' > par7 = 'all' > par6 = 'prep' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'COLLES actuals' > par8 <- 'COLLES actuals' > 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] 90 95 96 93 102 93 82 98 89 88 102 83 108 86 97 89 103 115 [19] 90 88 81 74 75 93 87 92 95 105 93 90 87 105 92 89 85 100 [37] 83 97 95 73 94 99 99 88 86 89 95 83 72 98 85 84 80 108 [55] 72 110 93 85 95 94 80 93 83 92 106 93 95 96 90 102 93 93 [73] 93 106 71 91 96 108 93 95 89 72 107 102 88 95 94 96 92 110 [91] 94 95 72 103 89 96 92 90 86 90 99 86 89 108 94 83 76 102 [109] 100 90 112 89 98 81 116 101 85 104 92 49 94 105 94 85 96 79 [127] 106 79 101 90 114 99 79 94 88 93 91 77 101 81 116 86 95 91 [145] 95 78 70 109 109 81 94 87 73 86 93 113 97 85 103 105 97 86 [163] 118 102 77 94 91 89 67 104 100 86 109 97 77 88 88 115 103 84 [181] 106 97 87 106 103 97 110 102 78 101 93 83 104 85 111 104 70 90 [199] 92 90 83 71 90 101 89 66 87 87 94 92 75 77 85 84 53 74 [217] 89 83 103 84 69 68 98 72 84 71 87 88 76 92 91 61 66 88 [235] 98 85 82 70 78 99 74 69 90 93 104 87 89 57 91 82 71 63 [253] 93 87 86 83 71 86 81 81 73 64 81 79 76 84 68 69 68 104 [271] 70 81 80 86 85 101 74 93 75 84 100 67 89 83 80 62 77 93 [289] 82 104 101 73 91 78 83 76 89 93 93 76 87 77 67 88 76 91 [307] 82 81 93 67 85 87 65 81 103 69 83 82 76 99 75 86 92 95 [325] 85 95 94 60 62 91 88 73 83 64 75 95 81 92 81 86 94 93 [343] 95 95 87 87 91 91 79 99 89 104 87 86 88 84 74 85 90 83 [361] 88 80 81 77 90 86 83 77 88 98 95 101 75 79 88 77 93 76 [379] 107 89 92 82 84 90 82 76 95 109 90 77 76 83 86 82 96 92 [397] 110 77 86 100 98 101 76 80 86 107 78 69 92 84 83 89 74 79 [415] 52 86 79 95 88 91 80 94 68 89 65 84 88 64 82 82 75 93 [433] 87 90 69 88 > 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]) 49 52 53 57 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1 1 1 1 1 1 2 1 3 2 2 4 4 6 4 5 5 5 6 7 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 11 11 5 8 7 13 11 17 11 13 19 15 18 18 17 12 14 24 14 19 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 7 7 7 7 5 9 7 7 8 4 5 3 4 4 4 1 1 1 1 2 116 118 2 1 > colnames(x) [1] "endo" "C1" "C3" "C5" "C7" "C9" "C11" "C13" "C15" "C17" [11] "C19" "C21" "C23" "C25" "C27" "C29" "C31" "C33" "C35" "C37" [21] "C39" "C41" "C43" "C45" "C47" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 90 95 96 93 102 93 82 98 89 88 102 83 108 86 97 89 103 115 [19] 90 88 81 74 75 93 87 92 95 105 93 90 87 105 92 89 85 100 [37] 83 97 95 73 94 99 99 88 86 89 95 83 72 98 85 84 80 108 [55] 72 110 93 85 95 94 80 93 83 92 106 93 95 96 90 102 93 93 [73] 93 106 71 91 96 108 93 95 89 72 107 102 88 95 94 96 92 110 [91] 94 95 72 103 89 96 92 90 86 90 99 86 89 108 94 83 76 102 [109] 100 90 112 89 98 81 116 101 85 104 92 49 94 105 94 85 96 79 [127] 106 79 101 90 114 99 79 94 88 93 91 77 101 81 116 86 95 91 [145] 95 78 70 109 109 81 94 87 73 86 93 113 97 85 103 105 97 86 [163] 118 102 77 94 91 89 67 104 100 86 109 97 77 88 88 115 103 84 [181] 106 97 87 106 103 97 110 102 78 101 93 83 104 85 111 104 70 90 [199] 92 90 83 71 90 101 89 66 87 87 94 92 75 77 85 84 53 74 [217] 89 83 103 84 69 68 98 72 84 71 87 88 76 92 91 61 66 88 [235] 98 85 82 70 78 99 74 69 90 93 104 87 89 57 91 82 71 63 [253] 93 87 86 83 71 86 81 81 73 64 81 79 76 84 68 69 68 104 [271] 70 81 80 86 85 101 74 93 75 84 100 67 89 83 80 62 77 93 [289] 82 104 101 73 91 78 83 76 89 93 93 76 87 77 67 88 76 91 [307] 82 81 93 67 85 87 65 81 103 69 83 82 76 99 75 86 92 95 [325] 85 95 94 60 62 91 88 73 83 64 75 95 81 92 81 86 94 93 [343] 95 95 87 87 91 91 79 99 89 104 87 86 88 84 74 85 90 83 [361] 88 80 81 77 90 86 83 77 88 98 95 101 75 79 88 77 93 76 [379] 107 89 92 82 84 90 82 76 95 109 90 77 76 83 86 82 96 92 [397] 110 77 86 100 98 101 76 80 86 107 78 69 92 84 83 89 74 79 [415] 52 86 79 95 88 91 80 94 68 89 65 84 88 64 82 82 75 93 [433] 87 90 69 88 > 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/1pm4i1337162442.tab") + } + } > m Conditional inference tree with 27 terminal nodes Response: endo Inputs: C1, C3, C5, C7, C9, C11, C13, C15, C17, C19, C21, C23, C25, C27, C29, C31, C33, C35, C37, C39, C41, C43, C45, C47 Number of observations: 436 1) C41 <= 3; criterion = 1, statistic = 175.651 2) C21 <= 3; criterion = 1, statistic = 56.859 3) C25 <= 3; criterion = 1, statistic = 39.647 4) C13 <= 3; criterion = 1, statistic = 18.469 5) C47 <= 2; criterion = 0.996, statistic = 14.282 6)* weights = 10 5) C47 > 2 7)* weights = 26 4) C13 > 3 8)* weights = 16 3) C25 > 3 9) C33 <= 3; criterion = 1, statistic = 23.319 10) C47 <= 3; criterion = 0.986, statistic = 11.762 11)* weights = 15 10) C47 > 3 12)* weights = 16 9) C33 > 3 13) C15 <= 3; criterion = 0.989, statistic = 12.205 14)* weights = 7 13) C15 > 3 15)* weights = 15 2) C21 > 3 16) C5 <= 3; criterion = 0.997, statistic = 14.529 17)* weights = 20 16) C5 > 3 18)* weights = 27 1) C41 > 3 19) C25 <= 4; criterion = 1, statistic = 92.171 20) C33 <= 3; criterion = 1, statistic = 58.861 21) C27 <= 2; criterion = 1, statistic = 24.545 22)* weights = 7 21) C27 > 2 23) C5 <= 3; criterion = 1, statistic = 19.537 24)* weights = 28 23) C5 > 3 25) C11 <= 4; criterion = 0.998, statistic = 15.646 26) C25 <= 3; criterion = 0.995, statistic = 13.805 27)* weights = 11 26) C25 > 3 28)* weights = 33 25) C11 > 4 29)* weights = 8 20) C33 > 3 30) C45 <= 4; criterion = 1, statistic = 39.826 31) C11 <= 3; criterion = 1, statistic = 27.142 32)* weights = 19 31) C11 > 3 33) C47 <= 3; criterion = 1, statistic = 23.009 34) C1 <= 3; criterion = 0.978, statistic = 10.954 35)* weights = 10 34) C1 > 3 36)* weights = 10 33) C47 > 3 37) C9 <= 3; criterion = 0.999, statistic = 16.833 38)* weights = 13 37) C9 > 3 39) C15 <= 3; criterion = 0.981, statistic = 11.27 40)* weights = 10 39) C15 > 3 41)* weights = 27 30) C45 > 4 42) C9 <= 4; criterion = 0.982, statistic = 11.379 43)* weights = 16 42) C9 > 4 44)* weights = 12 19) C25 > 4 45) C23 <= 4; criterion = 1, statistic = 27.47 46) C15 <= 3; criterion = 0.999, statistic = 17.19 47)* weights = 19 46) C15 > 3 48) C35 <= 4; criterion = 0.993, statistic = 13.013 49)* weights = 23 48) C35 > 4 50)* weights = 10 45) C23 > 4 51) C13 <= 4; criterion = 0.971, statistic = 10.452 52)* weights = 11 51) C13 > 4 53)* weights = 17 > postscript(file="/var/wessaorg/rcomp/tmp/2w94t1337162442.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/39g5z1337162442.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 90 89.15152 0.84848485 2 95 89.11111 5.88888889 3 96 96.59259 -0.59259259 4 93 85.10526 7.89473684 5 102 96.59259 5.40740741 6 93 90.90000 2.10000000 7 82 85.10526 -3.10526316 8 98 96.00000 2.00000000 9 89 90.90000 -1.90000000 10 88 89.15152 -1.15151515 11 102 103.83333 -1.83333333 12 83 84.60000 -1.60000000 13 108 103.83333 4.16666667 14 86 81.14286 4.85714286 15 97 96.00000 1.00000000 16 89 89.15152 -0.15151515 17 103 103.83333 -0.83333333 18 115 105.60000 9.40000000 19 90 85.10526 4.89473684 20 88 89.15152 -1.15151515 21 81 84.60000 -3.60000000 22 74 73.33333 0.66666667 23 75 70.00000 5.00000000 24 93 85.10526 7.89473684 25 87 101.18182 -14.18181818 26 92 97.52174 -5.52173913 27 95 82.75000 12.25000000 28 105 108.94118 -3.94117647 29 93 90.90000 2.10000000 30 90 90.60000 -0.60000000 31 87 90.90000 -3.90000000 32 105 103.83333 1.16666667 33 92 92.52632 -0.52631579 34 89 89.15152 -0.15151515 35 85 89.15152 -4.15151515 36 100 101.18182 -1.18181818 37 83 74.57143 8.42857143 38 97 96.59259 0.40740741 39 95 97.52174 -2.52173913 40 73 70.00000 3.00000000 41 94 89.15152 4.84848485 42 99 90.90000 8.10000000 43 99 97.52174 1.47826087 44 88 84.60000 3.40000000 45 86 76.62500 9.37500000 46 89 94.50000 -5.50000000 47 95 96.59259 -1.59259259 48 83 83.80000 -0.80000000 49 72 76.62500 -4.62500000 50 98 105.60000 -7.60000000 51 85 76.62500 8.37500000 52 84 89.15152 -5.15151515 53 80 74.57143 5.42857143 54 108 101.18182 6.81818182 55 72 74.57143 -2.57142857 56 110 105.60000 4.40000000 57 93 89.15152 3.84848485 58 85 89.15152 -4.15151515 59 95 96.00000 -1.00000000 60 94 89.15152 4.84848485 61 80 73.33333 6.66666667 62 93 97.52174 -4.52173913 63 83 90.60000 -7.60000000 64 92 92.00000 0.00000000 65 106 103.83333 2.16666667 66 93 103.83333 -10.83333333 67 95 92.52632 2.47368421 68 96 96.59259 -0.59259259 69 90 92.00000 -2.00000000 70 102 90.60000 11.40000000 71 93 96.00000 -3.00000000 72 93 79.31250 13.68750000 73 93 94.50000 -1.50000000 74 106 108.94118 -2.94117647 75 71 70.00000 1.00000000 76 91 96.00000 -5.00000000 77 96 96.00000 0.00000000 78 108 108.94118 -0.94117647 79 93 96.59259 -3.59259259 80 95 90.60000 4.40000000 81 89 88.69231 0.30769231 82 72 70.00000 2.00000000 83 107 97.52174 9.47826087 84 102 108.94118 -6.94117647 85 88 85.10526 2.89473684 86 95 92.52632 2.47368421 87 94 89.11111 4.88888889 88 96 96.00000 0.00000000 89 92 101.18182 -9.18181818 90 110 105.60000 4.40000000 91 94 88.69231 5.30769231 92 95 97.52174 -2.52173913 93 72 70.00000 2.00000000 94 103 92.52632 10.47368421 95 89 92.52632 -3.52631579 96 96 96.59259 -0.59259259 97 92 96.59259 -4.59259259 98 90 89.15152 0.84848485 99 86 82.18182 3.81818182 100 90 90.60000 -0.60000000 101 99 97.52174 1.47826087 102 86 82.18182 3.81818182 103 89 85.10526 3.89473684 104 108 92.52632 15.47368421 105 94 96.00000 -2.00000000 106 83 82.75000 0.25000000 107 76 79.31250 -3.31250000 108 102 96.59259 5.40740741 109 100 101.18182 -1.18181818 110 90 89.11111 0.88888889 111 112 108.94118 3.05882353 112 89 90.90000 -1.90000000 113 98 89.11111 8.88888889 114 81 83.80000 -2.80000000 115 116 108.94118 7.05882353 116 101 96.59259 4.40740741 117 85 79.31250 5.68750000 118 104 101.18182 2.81818182 119 92 88.69231 3.30769231 120 49 59.70000 -10.70000000 121 94 92.52632 1.47368421 122 105 101.18182 3.81818182 123 94 89.11111 4.88888889 124 85 85.10526 -0.10526316 125 96 89.15152 6.84848485 126 79 89.15152 -10.15151515 127 106 101.18182 4.81818182 128 79 82.75000 -3.75000000 129 101 94.50000 6.50000000 130 90 90.90000 -0.90000000 131 114 108.94118 5.05882353 132 99 103.83333 -4.83333333 133 79 85.10526 -6.10526316 134 94 96.00000 -2.00000000 135 88 89.11111 -1.11111111 136 93 92.00000 1.00000000 137 91 92.52632 -1.52631579 138 77 73.33333 3.66666667 139 101 97.52174 3.47826087 140 81 82.75000 -1.75000000 141 116 108.94118 7.05882353 142 86 85.10526 0.89473684 143 95 89.15152 5.84848485 144 91 89.15152 1.84848485 145 95 97.52174 -2.52173913 146 78 82.75000 -4.75000000 147 70 70.00000 0.00000000 148 109 97.52174 11.47826087 149 109 108.94118 0.05882353 150 81 85.10526 -4.10526316 151 94 89.15152 4.84848485 152 87 89.15152 -2.15151515 153 73 70.00000 3.00000000 154 86 89.11111 -3.11111111 155 93 89.15152 3.84848485 156 113 101.18182 11.81818182 157 97 92.00000 5.00000000 158 85 82.75000 2.25000000 159 103 96.00000 7.00000000 160 105 96.59259 8.40740741 161 97 94.50000 2.50000000 162 86 92.00000 -6.00000000 163 118 108.94118 9.05882353 164 102 96.00000 6.00000000 165 77 79.31250 -2.31250000 166 94 92.00000 2.00000000 167 91 90.90000 0.10000000 168 89 88.69231 0.30769231 169 67 70.00000 -3.00000000 170 104 105.60000 -1.60000000 171 100 94.50000 5.50000000 172 86 82.18182 3.81818182 173 109 105.60000 3.40000000 174 97 96.59259 0.40740741 175 77 73.33333 3.66666667 176 88 88.69231 -0.69230769 177 88 83.80000 4.20000000 178 115 103.83333 11.16666667 179 103 108.94118 -5.94117647 180 84 88.69231 -4.69230769 181 106 96.59259 9.40740741 182 97 89.15152 7.84848485 183 87 89.15152 -2.15151515 184 106 101.18182 4.81818182 185 103 97.52174 5.47826087 186 97 89.11111 7.88888889 187 110 108.94118 1.05882353 188 102 103.83333 -1.83333333 189 78 92.52632 -14.52631579 190 101 103.83333 -2.83333333 191 93 89.15152 3.84848485 192 83 85.10526 -2.10526316 193 104 97.52174 6.47826087 194 85 83.80000 1.20000000 195 111 108.94118 2.05882353 196 104 108.94118 -4.94117647 197 70 59.70000 10.30000000 198 90 88.69231 1.30769231 199 92 89.11111 2.88888889 200 90 89.15152 0.84848485 201 83 82.18182 0.81818182 202 71 73.33333 -2.33333333 203 90 89.11111 0.88888889 204 101 89.11111 11.88888889 205 89 82.75000 6.25000000 206 66 76.62500 -10.62500000 207 87 84.60000 2.40000000 208 87 90.60000 -3.60000000 209 94 92.52632 1.47368421 210 92 89.15152 2.84848485 211 75 76.62500 -1.62500000 212 77 83.80000 -6.80000000 213 85 83.80000 1.20000000 214 84 89.11111 -5.11111111 215 53 59.70000 -6.70000000 216 74 76.62500 -2.62500000 217 89 90.90000 -1.90000000 218 83 79.31250 3.68750000 219 103 96.59259 6.40740741 220 84 76.62500 7.37500000 221 69 73.33333 -4.33333333 222 68 59.70000 8.30000000 223 98 94.50000 3.50000000 224 72 76.62500 -4.62500000 225 84 82.75000 1.25000000 226 71 74.57143 -3.57142857 227 87 89.15152 -2.15151515 228 88 88.69231 -0.69230769 229 76 89.15152 -13.15151515 230 92 90.60000 1.40000000 231 91 96.59259 -5.59259259 232 61 59.70000 1.30000000 233 66 70.00000 -4.00000000 234 88 84.60000 3.40000000 235 98 92.52632 5.47368421 236 85 82.75000 2.25000000 237 82 81.14286 0.85714286 238 70 73.33333 -3.33333333 239 78 76.62500 1.37500000 240 99 97.52174 1.47826087 241 74 76.62500 -2.62500000 242 69 70.00000 -1.00000000 243 90 97.52174 -7.52173913 244 93 96.00000 -3.00000000 245 104 105.60000 -1.60000000 246 87 85.10526 1.89473684 247 89 92.52632 -3.52631579 248 57 59.70000 -2.70000000 249 91 85.10526 5.89473684 250 82 76.62500 5.37500000 251 71 73.33333 -2.33333333 252 63 70.00000 -7.00000000 253 93 90.60000 2.40000000 254 87 82.75000 4.25000000 255 86 92.52632 -6.52631579 256 83 84.60000 -1.60000000 257 71 74.57143 -3.57142857 258 86 97.52174 -11.52173913 259 81 82.75000 -1.75000000 260 81 82.75000 -1.75000000 261 73 79.31250 -6.31250000 262 64 70.00000 -6.00000000 263 81 83.80000 -2.80000000 264 79 76.62500 2.37500000 265 76 79.31250 -3.31250000 266 84 85.10526 -1.10526316 267 68 70.00000 -2.00000000 268 69 73.33333 -4.33333333 269 68 70.00000 -2.00000000 270 104 96.00000 8.00000000 271 70 76.62500 -6.62500000 272 81 73.33333 7.66666667 273 80 83.80000 -3.80000000 274 86 89.11111 -3.11111111 275 85 89.15152 -4.15151515 276 101 96.59259 4.40740741 277 74 70.00000 4.00000000 278 93 96.59259 -3.59259259 279 75 82.18182 -7.18181818 280 84 89.15152 -5.15151515 281 100 105.60000 -5.60000000 282 67 70.00000 -3.00000000 283 89 82.75000 6.25000000 284 83 89.11111 -6.11111111 285 80 92.52632 -12.52631579 286 62 59.70000 2.30000000 287 77 83.80000 -6.80000000 288 93 89.15152 3.84848485 289 82 82.75000 -0.75000000 290 104 97.52174 6.47826087 291 101 108.94118 -7.94117647 292 73 83.80000 -10.80000000 293 91 94.50000 -3.50000000 294 78 79.31250 -1.31250000 295 83 82.75000 0.25000000 296 76 70.00000 6.00000000 297 89 88.69231 0.30769231 298 93 96.59259 -3.59259259 299 93 96.00000 -3.00000000 300 76 82.18182 -6.18181818 301 87 94.50000 -7.50000000 302 77 82.18182 -5.18181818 303 67 85.10526 -18.10526316 304 88 79.31250 8.68750000 305 76 70.00000 6.00000000 306 91 89.15152 1.84848485 307 82 79.31250 2.68750000 308 81 82.75000 -1.75000000 309 93 83.80000 9.20000000 310 67 70.00000 -3.00000000 311 85 82.75000 2.25000000 312 87 89.11111 -2.11111111 313 65 70.00000 -5.00000000 314 81 82.75000 -1.75000000 315 103 103.83333 -0.83333333 316 69 76.62500 -7.62500000 317 83 85.10526 -2.10526316 318 82 84.60000 -2.60000000 319 76 82.75000 -6.75000000 320 99 105.60000 -6.60000000 321 75 82.75000 -7.75000000 322 86 83.80000 2.20000000 323 92 92.00000 0.00000000 324 95 96.59259 -1.59259259 325 85 85.10526 -0.10526316 326 95 97.52174 -2.52173913 327 94 92.00000 2.00000000 328 60 59.70000 0.30000000 329 62 70.00000 -8.00000000 330 91 83.80000 7.20000000 331 88 90.60000 -2.60000000 332 73 70.00000 3.00000000 333 83 89.11111 -6.11111111 334 64 73.33333 -9.33333333 335 75 73.33333 1.66666667 336 95 92.00000 3.00000000 337 81 82.18182 -1.18181818 338 92 101.18182 -9.18181818 339 81 79.31250 1.68750000 340 86 82.75000 3.25000000 341 94 96.00000 -2.00000000 342 93 97.52174 -4.52173913 343 95 92.52632 2.47368421 344 95 97.52174 -2.52173913 345 87 83.80000 3.20000000 346 87 92.00000 -5.00000000 347 91 90.60000 0.40000000 348 91 89.11111 1.88888889 349 79 82.75000 -3.75000000 350 99 97.52174 1.47826087 351 89 90.90000 -1.90000000 352 104 97.52174 6.47826087 353 87 89.11111 -2.11111111 354 86 89.11111 -3.11111111 355 88 92.52632 -4.52631579 356 84 96.59259 -12.59259259 357 74 76.62500 -2.62500000 358 85 89.11111 -4.11111111 359 90 97.52174 -7.52173913 360 83 89.11111 -6.11111111 361 88 89.15152 -1.15151515 362 80 89.11111 -9.11111111 363 81 89.15152 -8.15151515 364 77 81.14286 -4.14285714 365 90 88.69231 1.30769231 366 86 83.80000 2.20000000 367 83 90.60000 -7.60000000 368 77 79.31250 -2.31250000 369 88 82.18182 5.81818182 370 98 90.60000 7.40000000 371 95 96.59259 -1.59259259 372 101 96.59259 4.40740741 373 75 70.00000 5.00000000 374 79 82.75000 -3.75000000 375 88 96.59259 -8.59259259 376 77 79.31250 -2.31250000 377 93 96.00000 -3.00000000 378 76 70.00000 6.00000000 379 107 108.94118 -1.94117647 380 89 89.11111 -0.11111111 381 92 90.60000 1.40000000 382 82 83.80000 -1.80000000 383 84 82.18182 1.81818182 384 90 89.11111 0.88888889 385 82 81.14286 0.85714286 386 76 74.57143 1.42857143 387 95 96.59259 -1.59259259 388 109 103.83333 5.16666667 389 90 92.52632 -2.52631579 390 77 79.31250 -2.31250000 391 76 81.14286 -5.14285714 392 83 85.10526 -2.10526316 393 86 90.60000 -4.60000000 394 82 82.18182 -0.18181818 395 96 97.52174 -1.52173913 396 92 89.11111 2.88888889 397 110 108.94118 1.05882353 398 77 79.31250 -2.31250000 399 86 76.62500 9.37500000 400 100 96.59259 3.40740741 401 98 92.52632 5.47368421 402 101 96.59259 4.40740741 403 76 81.14286 -5.14285714 404 80 82.75000 -2.75000000 405 86 84.60000 1.40000000 406 107 105.60000 1.40000000 407 78 82.75000 -4.75000000 408 69 74.57143 -5.57142857 409 92 83.80000 8.20000000 410 84 89.11111 -5.11111111 411 83 82.75000 0.25000000 412 89 90.60000 -1.60000000 413 74 70.00000 4.00000000 414 79 73.33333 5.66666667 415 52 59.70000 -7.70000000 416 86 84.60000 1.40000000 417 79 83.80000 -4.80000000 418 95 92.52632 2.47368421 419 88 83.80000 4.20000000 420 91 89.11111 1.88888889 421 80 88.69231 -8.69230769 422 94 89.15152 4.84848485 423 68 73.33333 -5.33333333 424 89 81.14286 7.85714286 425 65 59.70000 5.30000000 426 84 82.75000 1.25000000 427 88 82.75000 5.25000000 428 64 70.00000 -6.00000000 429 82 84.60000 -2.60000000 430 82 83.80000 -1.80000000 431 75 73.33333 1.66666667 432 93 88.69231 4.30769231 433 87 88.69231 -1.69230769 434 90 96.59259 -6.59259259 435 69 79.31250 -10.31250000 436 88 85.10526 2.89473684 > 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/4slbs1337162442.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/57jbf1337162442.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/6sijz1337162442.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/7jdhc1337162442.tab") + } > > try(system("convert tmp/2w94t1337162442.ps tmp/2w94t1337162442.png",intern=TRUE)) character(0) > try(system("convert tmp/39g5z1337162442.ps tmp/39g5z1337162442.png",intern=TRUE)) character(0) > try(system("convert tmp/4slbs1337162442.ps tmp/4slbs1337162442.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 9.205 0.405 9.640