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 = 'CSUQ' > par7 = 'all' > par6 = 'all' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'COLLES actuals' > 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] 93 106 71 91 96 108 93 95 89 72 107 102 88 95 94 96 92 110 [19] 94 95 72 103 89 96 92 90 86 90 99 86 108 94 102 100 90 112 [37] 98 81 116 101 85 104 92 49 94 105 94 85 96 79 106 79 101 90 [55] 114 99 79 94 88 93 91 101 81 116 86 95 91 95 78 70 109 109 [73] 81 94 87 73 86 93 113 97 85 103 105 97 86 118 102 94 91 89 [91] 67 104 100 86 109 97 77 88 115 103 84 106 97 87 106 103 97 110 [109] 102 78 101 93 83 104 85 111 104 70 90 92 90 71 90 72 83 120 [127] 73 93 90 98 85 101 89 108 96 79 103 93 107 87 84 65 72 87 [145] 80 92 87 106 87 92 88 92 96 86 94 98 96 79 93 81 72 109 [163] 72 74 88 97 97 92 93 89 98 109 99 99 98 93 105 88 102 101 [181] 90 93 96 100 83 97 106 86 99 94 103 110 86 87 104 96 100 82 [199] 72 88 103 80 93 88 56 120 86 82 101 89 66 87 87 94 92 75 [217] 77 85 84 53 74 89 83 103 69 68 98 72 84 71 87 88 76 92 [235] 91 61 66 88 98 85 82 70 78 99 74 69 90 93 104 87 89 57 [253] 91 82 71 63 93 87 86 83 71 86 81 81 73 64 81 79 76 84 [271] 68 69 68 104 70 81 80 86 85 101 74 93 75 84 100 67 89 83 [289] 80 62 77 93 82 104 101 73 91 78 83 76 89 93 93 76 87 77 [307] 67 88 76 91 82 81 93 67 85 87 65 81 103 69 83 82 102 74 [325] 95 75 76 72 84 99 95 81 98 90 93 81 72 72 75 57 68 70 [343] 70 90 87 100 69 78 75 71 85 88 83 72 85 79 79 85 89 70 [361] 95 89 72 89 89 74 90 92 88 113 89 94 76 94 85 79 77 69 [379] 88 86 82 84 96 82 88 111 67 73 105 94 96 97 70 91 92 68 [397] 104 87 96 88 95 75 84 72 91 89 67 81 93 106 100 63 84 81 [415] 78 > 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 53 56 57 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 1 1 1 2 1 1 2 1 2 2 6 5 6 8 6 14 5 6 6 7 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 5 6 9 4 14 9 9 10 13 14 16 16 16 13 10 12 21 14 9 12 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 9 8 7 7 9 6 9 9 4 7 2 3 5 3 2 1 2 1 1 2 118 120 1 2 > 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] 93 106 71 91 96 108 93 95 89 72 107 102 88 95 94 96 92 110 [19] 94 95 72 103 89 96 92 90 86 90 99 86 108 94 102 100 90 112 [37] 98 81 116 101 85 104 92 49 94 105 94 85 96 79 106 79 101 90 [55] 114 99 79 94 88 93 91 101 81 116 86 95 91 95 78 70 109 109 [73] 81 94 87 73 86 93 113 97 85 103 105 97 86 118 102 94 91 89 [91] 67 104 100 86 109 97 77 88 115 103 84 106 97 87 106 103 97 110 [109] 102 78 101 93 83 104 85 111 104 70 90 92 90 71 90 72 83 120 [127] 73 93 90 98 85 101 89 108 96 79 103 93 107 87 84 65 72 87 [145] 80 92 87 106 87 92 88 92 96 86 94 98 96 79 93 81 72 109 [163] 72 74 88 97 97 92 93 89 98 109 99 99 98 93 105 88 102 101 [181] 90 93 96 100 83 97 106 86 99 94 103 110 86 87 104 96 100 82 [199] 72 88 103 80 93 88 56 120 86 82 101 89 66 87 87 94 92 75 [217] 77 85 84 53 74 89 83 103 69 68 98 72 84 71 87 88 76 92 [235] 91 61 66 88 98 85 82 70 78 99 74 69 90 93 104 87 89 57 [253] 91 82 71 63 93 87 86 83 71 86 81 81 73 64 81 79 76 84 [271] 68 69 68 104 70 81 80 86 85 101 74 93 75 84 100 67 89 83 [289] 80 62 77 93 82 104 101 73 91 78 83 76 89 93 93 76 87 77 [307] 67 88 76 91 82 81 93 67 85 87 65 81 103 69 83 82 102 74 [325] 95 75 76 72 84 99 95 81 98 90 93 81 72 72 75 57 68 70 [343] 70 90 87 100 69 78 75 71 85 88 83 72 85 79 79 85 89 70 [361] 95 89 72 89 89 74 90 92 88 113 89 94 76 94 85 79 77 69 [379] 88 86 82 84 96 82 88 111 67 73 105 94 96 97 70 91 92 68 [397] 104 87 96 88 95 75 84 72 91 89 67 81 93 106 100 63 84 81 [415] 78 > 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/1xztl1335898348.tab") + } + } > m Conditional inference tree with 5 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: 415 1) U23 <= 3; criterion = 1, statistic = 45.54 2) U23 <= 1; criterion = 0.989, statistic = 12.873 3)* weights = 17 2) U23 > 1 4)* weights = 150 1) U23 > 3 5) U17 <= 3; criterion = 1, statistic = 24.72 6)* weights = 112 5) U17 > 3 7) U28 <= 3; criterion = 0.986, statistic = 12.464 8)* weights = 38 7) U28 > 3 9)* weights = 98 > postscript(file="/var/wessaorg/rcomp/tmp/29irn1335898348.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/3st8x1335898348.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 93 89.26316 3.736842105 2 106 95.47959 10.520408163 3 71 85.00667 -14.006666667 4 91 95.47959 -4.479591837 5 96 87.01786 8.982142857 6 108 89.26316 18.736842105 7 93 87.01786 5.982142857 8 95 87.01786 7.982142857 9 89 89.26316 -0.263157895 10 72 85.00667 -13.006666667 11 107 89.26316 17.736842105 12 102 95.47959 6.520408163 13 88 89.26316 -1.263157895 14 95 87.01786 7.982142857 15 94 85.00667 8.993333333 16 96 95.47959 0.520408163 17 92 87.01786 4.982142857 18 110 85.00667 24.993333333 19 94 87.01786 6.982142857 20 95 89.26316 5.736842105 21 72 87.01786 -15.017857143 22 103 85.00667 17.993333333 23 89 85.00667 3.993333333 24 96 95.47959 0.520408163 25 92 95.47959 -3.479591837 26 90 85.00667 4.993333333 27 86 87.01786 -1.017857143 28 90 85.00667 4.993333333 29 99 95.47959 3.520408163 30 86 89.26316 -3.263157895 31 108 95.47959 12.520408163 32 94 85.00667 8.993333333 33 102 87.01786 14.982142857 34 100 89.26316 10.736842105 35 90 95.47959 -5.479591837 36 112 95.47959 16.520408163 37 98 85.00667 12.993333333 38 81 85.00667 -4.006666667 39 116 95.47959 20.520408163 40 101 95.47959 5.520408163 41 85 95.47959 -10.479591837 42 104 85.00667 18.993333333 43 92 87.01786 4.982142857 44 49 74.47059 -25.470588235 45 94 85.00667 8.993333333 46 105 89.26316 15.736842105 47 94 87.01786 6.982142857 48 85 87.01786 -2.017857143 49 96 95.47959 0.520408163 50 79 95.47959 -16.479591837 51 106 89.26316 16.736842105 52 79 85.00667 -6.006666667 53 101 85.00667 15.993333333 54 90 85.00667 4.993333333 55 114 95.47959 18.520408163 56 99 87.01786 11.982142857 57 79 87.01786 -8.017857143 58 94 89.26316 4.736842105 59 88 85.00667 2.993333333 60 93 87.01786 5.982142857 61 91 85.00667 5.993333333 62 101 95.47959 5.520408163 63 81 85.00667 -4.006666667 64 116 87.01786 28.982142857 65 86 85.00667 0.993333333 66 95 95.47959 -0.479591837 67 91 87.01786 3.982142857 68 95 95.47959 -0.479591837 69 78 85.00667 -7.006666667 70 70 85.00667 -15.006666667 71 109 95.47959 13.520408163 72 109 95.47959 13.520408163 73 81 85.00667 -4.006666667 74 94 85.00667 8.993333333 75 87 95.47959 -8.479591837 76 73 85.00667 -12.006666667 77 86 85.00667 0.993333333 78 93 85.00667 7.993333333 79 113 85.00667 27.993333333 80 97 87.01786 9.982142857 81 85 85.00667 -0.006666667 82 103 95.47959 7.520408163 83 105 95.47959 9.520408163 84 97 95.47959 1.520408163 85 86 85.00667 0.993333333 86 118 85.00667 32.993333333 87 102 95.47959 6.520408163 88 94 85.00667 8.993333333 89 91 95.47959 -4.479591837 90 89 87.01786 1.982142857 91 67 85.00667 -18.006666667 92 104 95.47959 8.520408163 93 100 87.01786 12.982142857 94 86 85.00667 0.993333333 95 109 95.47959 13.520408163 96 97 95.47959 1.520408163 97 77 85.00667 -8.006666667 98 88 85.00667 2.993333333 99 115 85.00667 29.993333333 100 103 89.26316 13.736842105 101 84 87.01786 -3.017857143 102 106 89.26316 16.736842105 103 97 89.26316 7.736842105 104 87 87.01786 -0.017857143 105 106 95.47959 10.520408163 106 103 85.00667 17.993333333 107 97 85.00667 11.993333333 108 110 87.01786 22.982142857 109 102 85.00667 16.993333333 110 78 74.47059 3.529411765 111 101 87.01786 13.982142857 112 93 74.47059 18.529411765 113 83 87.01786 -4.017857143 114 104 89.26316 14.736842105 115 85 85.00667 -0.006666667 116 111 95.47959 15.520408163 117 104 85.00667 18.993333333 118 70 87.01786 -17.017857143 119 90 85.00667 4.993333333 120 92 87.01786 4.982142857 121 90 85.00667 4.993333333 122 71 89.26316 -18.263157895 123 90 95.47959 -5.479591837 124 72 87.01786 -15.017857143 125 83 87.01786 -4.017857143 126 120 87.01786 32.982142857 127 73 74.47059 -1.470588235 128 93 85.00667 7.993333333 129 90 85.00667 4.993333333 130 98 89.26316 8.736842105 131 85 87.01786 -2.017857143 132 101 85.00667 15.993333333 133 89 85.00667 3.993333333 134 108 85.00667 22.993333333 135 96 85.00667 10.993333333 136 79 85.00667 -6.006666667 137 103 87.01786 15.982142857 138 93 95.47959 -2.479591837 139 107 95.47959 11.520408163 140 87 95.47959 -8.479591837 141 84 89.26316 -5.263157895 142 65 85.00667 -20.006666667 143 72 85.00667 -13.006666667 144 87 87.01786 -0.017857143 145 80 89.26316 -9.263157895 146 92 85.00667 6.993333333 147 87 85.00667 1.993333333 148 106 85.00667 20.993333333 149 87 87.01786 -0.017857143 150 92 87.01786 4.982142857 151 88 87.01786 0.982142857 152 92 85.00667 6.993333333 153 96 95.47959 0.520408163 154 86 87.01786 -1.017857143 155 94 87.01786 6.982142857 156 98 85.00667 12.993333333 157 96 85.00667 10.993333333 158 79 85.00667 -6.006666667 159 93 95.47959 -2.479591837 160 81 89.26316 -8.263157895 161 72 87.01786 -15.017857143 162 109 87.01786 21.982142857 163 72 89.26316 -17.263157895 164 74 95.47959 -21.479591837 165 88 85.00667 2.993333333 166 97 87.01786 9.982142857 167 97 95.47959 1.520408163 168 92 87.01786 4.982142857 169 93 95.47959 -2.479591837 170 89 85.00667 3.993333333 171 98 85.00667 12.993333333 172 109 85.00667 23.993333333 173 99 85.00667 13.993333333 174 99 85.00667 13.993333333 175 98 87.01786 10.982142857 176 93 85.00667 7.993333333 177 105 74.47059 30.529411765 178 88 85.00667 2.993333333 179 102 85.00667 16.993333333 180 101 95.47959 5.520408163 181 90 87.01786 2.982142857 182 93 87.01786 5.982142857 183 96 95.47959 0.520408163 184 100 85.00667 14.993333333 185 83 89.26316 -6.263157895 186 97 85.00667 11.993333333 187 106 85.00667 20.993333333 188 86 95.47959 -9.479591837 189 99 85.00667 13.993333333 190 94 87.01786 6.982142857 191 103 87.01786 15.982142857 192 110 95.47959 14.520408163 193 86 87.01786 -1.017857143 194 87 89.26316 -2.263157895 195 104 95.47959 8.520408163 196 96 95.47959 0.520408163 197 100 95.47959 4.520408163 198 82 85.00667 -3.006666667 199 72 85.00667 -13.006666667 200 88 95.47959 -7.479591837 201 103 85.00667 17.993333333 202 80 95.47959 -15.479591837 203 93 85.00667 7.993333333 204 88 87.01786 0.982142857 205 56 87.01786 -31.017857143 206 120 87.01786 32.982142857 207 86 85.00667 0.993333333 208 82 95.47959 -13.479591837 209 101 95.47959 5.520408163 210 89 95.47959 -6.479591837 211 66 74.47059 -8.470588235 212 87 87.01786 -0.017857143 213 87 85.00667 1.993333333 214 94 87.01786 6.982142857 215 92 95.47959 -3.479591837 216 75 89.26316 -14.263157895 217 77 87.01786 -10.017857143 218 85 89.26316 -4.263157895 219 84 95.47959 -11.479591837 220 53 85.00667 -32.006666667 221 74 85.00667 -11.006666667 222 89 85.00667 3.993333333 223 83 89.26316 -6.263157895 224 103 85.00667 17.993333333 225 69 87.01786 -18.017857143 226 68 85.00667 -17.006666667 227 98 89.26316 8.736842105 228 72 87.01786 -15.017857143 229 84 87.01786 -3.017857143 230 71 85.00667 -14.006666667 231 87 95.47959 -8.479591837 232 88 95.47959 -7.479591837 233 76 74.47059 1.529411765 234 92 85.00667 6.993333333 235 91 95.47959 -4.479591837 236 61 85.00667 -24.006666667 237 66 74.47059 -8.470588235 238 88 95.47959 -7.479591837 239 98 95.47959 2.520408163 240 85 87.01786 -2.017857143 241 82 85.00667 -3.006666667 242 70 85.00667 -15.006666667 243 78 85.00667 -7.006666667 244 99 89.26316 9.736842105 245 74 85.00667 -11.006666667 246 69 87.01786 -18.017857143 247 90 95.47959 -5.479591837 248 93 95.47959 -2.479591837 249 104 95.47959 8.520408163 250 87 74.47059 12.529411765 251 89 87.01786 1.982142857 252 57 87.01786 -30.017857143 253 91 85.00667 5.993333333 254 82 87.01786 -5.017857143 255 71 87.01786 -16.017857143 256 63 85.00667 -22.006666667 257 93 85.00667 7.993333333 258 87 85.00667 1.993333333 259 86 89.26316 -3.263157895 260 83 85.00667 -2.006666667 261 71 85.00667 -14.006666667 262 86 85.00667 0.993333333 263 81 89.26316 -8.263157895 264 81 85.00667 -4.006666667 265 73 87.01786 -14.017857143 266 64 87.01786 -23.017857143 267 81 85.00667 -4.006666667 268 79 89.26316 -10.263157895 269 76 85.00667 -9.006666667 270 84 85.00667 -1.006666667 271 68 85.00667 -17.006666667 272 69 87.01786 -18.017857143 273 68 74.47059 -6.470588235 274 104 95.47959 8.520408163 275 70 74.47059 -4.470588235 276 81 85.00667 -4.006666667 277 80 85.00667 -5.006666667 278 86 87.01786 -1.017857143 279 85 87.01786 -2.017857143 280 101 87.01786 13.982142857 281 74 87.01786 -13.017857143 282 93 74.47059 18.529411765 283 75 85.00667 -10.006666667 284 84 85.00667 -1.006666667 285 100 87.01786 12.982142857 286 67 85.00667 -18.006666667 287 89 95.47959 -6.479591837 288 83 85.00667 -2.006666667 289 80 85.00667 -5.006666667 290 62 74.47059 -12.470588235 291 77 95.47959 -18.479591837 292 93 95.47959 -2.479591837 293 82 85.00667 -3.006666667 294 104 95.47959 8.520408163 295 101 87.01786 13.982142857 296 73 87.01786 -14.017857143 297 91 95.47959 -4.479591837 298 78 85.00667 -7.006666667 299 83 89.26316 -6.263157895 300 76 87.01786 -11.017857143 301 89 85.00667 3.993333333 302 93 85.00667 7.993333333 303 93 87.01786 5.982142857 304 76 74.47059 1.529411765 305 87 87.01786 -0.017857143 306 77 87.01786 -10.017857143 307 67 85.00667 -18.006666667 308 88 95.47959 -7.479591837 309 76 87.01786 -11.017857143 310 91 87.01786 3.982142857 311 82 85.00667 -3.006666667 312 81 85.00667 -4.006666667 313 93 87.01786 5.982142857 314 67 85.00667 -18.006666667 315 85 87.01786 -2.017857143 316 87 95.47959 -8.479591837 317 65 85.00667 -20.006666667 318 81 89.26316 -8.263157895 319 103 95.47959 7.520408163 320 69 74.47059 -5.470588235 321 83 85.00667 -2.006666667 322 82 85.00667 -3.006666667 323 102 87.01786 14.982142857 324 74 87.01786 -13.017857143 325 95 95.47959 -0.479591837 326 75 87.01786 -12.017857143 327 76 85.00667 -9.006666667 328 72 85.00667 -13.006666667 329 84 95.47959 -11.479591837 330 99 95.47959 3.520408163 331 95 87.01786 7.982142857 332 81 87.01786 -6.017857143 333 98 87.01786 10.982142857 334 90 87.01786 2.982142857 335 93 89.26316 3.736842105 336 81 87.01786 -6.017857143 337 72 74.47059 -2.470588235 338 72 85.00667 -13.006666667 339 75 87.01786 -12.017857143 340 57 89.26316 -32.263157895 341 68 85.00667 -17.006666667 342 70 85.00667 -15.006666667 343 70 85.00667 -15.006666667 344 90 85.00667 4.993333333 345 87 87.01786 -0.017857143 346 100 95.47959 4.520408163 347 69 85.00667 -16.006666667 348 78 85.00667 -7.006666667 349 75 85.00667 -10.006666667 350 71 87.01786 -16.017857143 351 85 89.26316 -4.263157895 352 88 85.00667 2.993333333 353 83 85.00667 -2.006666667 354 72 85.00667 -13.006666667 355 85 95.47959 -10.479591837 356 79 85.00667 -6.006666667 357 79 87.01786 -8.017857143 358 85 87.01786 -2.017857143 359 89 85.00667 3.993333333 360 70 85.00667 -15.006666667 361 95 95.47959 -0.479591837 362 89 89.26316 -0.263157895 363 72 87.01786 -15.017857143 364 89 85.00667 3.993333333 365 89 85.00667 3.993333333 366 74 85.00667 -11.006666667 367 90 95.47959 -5.479591837 368 92 95.47959 -3.479591837 369 88 87.01786 0.982142857 370 113 95.47959 17.520408163 371 89 87.01786 1.982142857 372 94 95.47959 -1.479591837 373 76 87.01786 -11.017857143 374 94 95.47959 -1.479591837 375 85 95.47959 -10.479591837 376 79 87.01786 -8.017857143 377 77 85.00667 -8.006666667 378 69 85.00667 -16.006666667 379 88 95.47959 -7.479591837 380 86 85.00667 0.993333333 381 82 87.01786 -5.017857143 382 84 85.00667 -1.006666667 383 96 87.01786 8.982142857 384 82 87.01786 -5.017857143 385 88 87.01786 0.982142857 386 111 95.47959 15.520408163 387 67 85.00667 -18.006666667 388 73 85.00667 -12.006666667 389 105 95.47959 9.520408163 390 94 87.01786 6.982142857 391 96 95.47959 0.520408163 392 97 87.01786 9.982142857 393 70 85.00667 -15.006666667 394 91 87.01786 3.982142857 395 92 95.47959 -3.479591837 396 68 85.00667 -17.006666667 397 104 95.47959 8.520408163 398 87 87.01786 -0.017857143 399 96 95.47959 0.520408163 400 88 85.00667 2.993333333 401 95 87.01786 7.982142857 402 75 95.47959 -20.479591837 403 84 87.01786 -3.017857143 404 72 87.01786 -15.017857143 405 91 95.47959 -4.479591837 406 89 95.47959 -6.479591837 407 67 95.47959 -28.479591837 408 81 89.26316 -8.263157895 409 93 95.47959 -2.479591837 410 106 95.47959 10.520408163 411 100 95.47959 4.520408163 412 63 74.47059 -11.470588235 413 84 85.00667 -1.006666667 414 81 87.01786 -6.017857143 415 78 87.01786 -9.017857143 > 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/4pqup1335898348.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/5wnid1335898348.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/67snh1335898348.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/7v45j1335898348.tab") + } > > try(system("convert tmp/29irn1335898348.ps tmp/29irn1335898348.png",intern=TRUE)) character(0) > try(system("convert tmp/3st8x1335898348.ps tmp/3st8x1335898348.png",intern=TRUE)) character(0) > try(system("convert tmp/4pqup1335898348.ps tmp/4pqup1335898348.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.721 0.371 8.093