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 = 'bachelor' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'COLLES actuals' > par8 <- 'COLLES actuals' > par7 <- 'all' > par6 <- 'bachelor' > 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] 102 94 85 87 77 83 79 110 90 95 80 95 105 91 69 81 75 98 [19] 101 96 86 91 72 76 95 96 92 77 90 85 81 80 91 89 78 66 [37] 79 91 88 61 77 81 91 75 87 93 85 88 86 93 77 92 80 98 [55] 109 95 75 88 87 84 82 107 94 86 89 95 81 87 99 87 83 88 [73] 89 68 117 88 84 94 109 108 61 107 80 92 94 95 83 92 75 94 [91] 83 110 80 101 81 59 90 94 83 90 82 93 94 84 110 69 97 95 [109] 98 78 89 72 83 120 73 90 93 90 98 85 101 89 108 96 86 115 [127] 79 103 93 107 87 84 65 72 87 80 92 87 106 87 92 88 92 96 [145] 86 94 98 96 79 93 81 72 109 72 96 74 88 97 97 92 93 89 [163] 98 109 99 99 98 93 105 88 102 101 90 93 96 100 83 97 68 106 [181] 86 78 99 94 103 110 86 87 104 96 100 111 82 72 88 103 80 93 [199] 88 56 120 86 82 102 74 95 75 76 72 84 99 95 81 98 90 93 [217] 81 72 72 75 57 68 70 70 90 87 100 69 78 75 71 85 88 83 [235] 72 85 79 82 79 85 89 70 95 89 72 89 89 74 90 92 88 113 [253] 89 94 76 94 85 79 77 69 88 86 82 84 96 82 88 111 67 73 [271] 105 94 96 97 70 91 110 92 68 104 87 96 88 95 75 84 72 91 [289] 89 67 81 93 106 100 63 84 81 78 90 108 66 99 65 93 100 92 [307] 100 77 85 80 69 91 53 91 86 95 66 95 75 90 90 83 92 84 [325] 86 72 73 100 79 71 82 99 85 80 85 98 99 86 73 78 90 103 [343] 87 76 102 73 101 83 80 79 63 96 75 103 89 105 78 80 95 96 [361] 71 80 92 67 97 79 79 83 77 82 79 83 71 83 73 86 77 72 [379] 73 82 65 67 78 70 78 88 85 > 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]) 53 56 57 59 61 63 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1 1 1 1 2 2 3 3 4 4 5 5 4 14 7 3 10 4 8 9 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 12 12 10 10 13 9 12 13 13 16 13 14 9 13 13 12 14 13 6 9 99 100 101 102 103 104 105 106 107 108 109 110 111 113 115 117 120 8 7 5 4 5 2 4 3 3 3 4 5 2 1 1 1 2 > 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] 102 94 85 87 77 83 79 110 90 95 80 95 105 91 69 81 75 98 [19] 101 96 86 91 72 76 95 96 92 77 90 85 81 80 91 89 78 66 [37] 79 91 88 61 77 81 91 75 87 93 85 88 86 93 77 92 80 98 [55] 109 95 75 88 87 84 82 107 94 86 89 95 81 87 99 87 83 88 [73] 89 68 117 88 84 94 109 108 61 107 80 92 94 95 83 92 75 94 [91] 83 110 80 101 81 59 90 94 83 90 82 93 94 84 110 69 97 95 [109] 98 78 89 72 83 120 73 90 93 90 98 85 101 89 108 96 86 115 [127] 79 103 93 107 87 84 65 72 87 80 92 87 106 87 92 88 92 96 [145] 86 94 98 96 79 93 81 72 109 72 96 74 88 97 97 92 93 89 [163] 98 109 99 99 98 93 105 88 102 101 90 93 96 100 83 97 68 106 [181] 86 78 99 94 103 110 86 87 104 96 100 111 82 72 88 103 80 93 [199] 88 56 120 86 82 102 74 95 75 76 72 84 99 95 81 98 90 93 [217] 81 72 72 75 57 68 70 70 90 87 100 69 78 75 71 85 88 83 [235] 72 85 79 82 79 85 89 70 95 89 72 89 89 74 90 92 88 113 [253] 89 94 76 94 85 79 77 69 88 86 82 84 96 82 88 111 67 73 [271] 105 94 96 97 70 91 110 92 68 104 87 96 88 95 75 84 72 91 [289] 89 67 81 93 106 100 63 84 81 78 90 108 66 99 65 93 100 92 [307] 100 77 85 80 69 91 53 91 86 95 66 95 75 90 90 83 92 84 [325] 86 72 73 100 79 71 82 99 85 80 85 98 99 86 73 78 90 103 [343] 87 76 102 73 101 83 80 79 63 96 75 103 89 105 78 80 95 96 [361] 71 80 92 67 97 79 79 83 77 82 79 83 71 83 73 86 77 72 [379] 73 82 65 67 78 70 78 88 85 > 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/13tpd1337162598.tab") + } + } > m Conditional inference tree with 23 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: 387 1) C33 <= 3; criterion = 1, statistic = 166.564 2) C25 <= 3; criterion = 1, statistic = 70.281 3) C47 <= 2; criterion = 1, statistic = 20.947 4)* weights = 7 3) C47 > 2 5) C37 <= 3; criterion = 1, statistic = 18.299 6) C27 <= 2; criterion = 0.986, statistic = 11.76 7)* weights = 9 6) C27 > 2 8) C41 <= 3; criterion = 0.965, statistic = 10.079 9)* weights = 27 8) C41 > 3 10)* weights = 14 5) C37 > 3 11) C9 <= 3; criterion = 0.966, statistic = 10.134 12)* weights = 13 11) C9 > 3 13)* weights = 8 2) C25 > 3 14) C5 <= 3; criterion = 1, statistic = 53.471 15) C17 <= 2; criterion = 0.994, statistic = 13.264 16)* weights = 7 15) C17 > 2 17)* weights = 29 14) C5 > 3 18) C23 <= 3; criterion = 1, statistic = 20.807 19) C9 <= 3; criterion = 0.979, statistic = 11.019 20)* weights = 15 19) C9 > 3 21)* weights = 18 18) C23 > 3 22) C7 <= 3; criterion = 0.985, statistic = 11.684 23)* weights = 9 22) C7 > 3 24)* weights = 31 1) C33 > 3 25) C25 <= 4; criterion = 1, statistic = 77.132 26) C43 <= 4; criterion = 1, statistic = 52.354 27) C37 <= 4; criterion = 1, statistic = 36.951 28) C25 <= 3; criterion = 1, statistic = 30.058 29)* weights = 27 28) C25 > 3 30) C7 <= 3; criterion = 1, statistic = 20.797 31)* weights = 24 30) C7 > 3 32) C17 <= 3; criterion = 1, statistic = 20.019 33)* weights = 27 32) C17 > 3 34) C9 <= 3; criterion = 0.997, statistic = 14.451 35)* weights = 8 34) C9 > 3 36)* weights = 26 27) C37 > 4 37)* weights = 20 26) C43 > 4 38)* weights = 17 25) C25 > 4 39) C21 <= 4; criterion = 1, statistic = 22.135 40) C19 <= 3; criterion = 0.995, statistic = 13.581 41)* weights = 12 40) C19 > 3 42) C33 <= 4; criterion = 0.981, statistic = 11.239 43)* weights = 12 42) C33 > 4 44)* weights = 12 39) C21 > 4 45)* weights = 15 > postscript(file="/var/wessaorg/rcomp/tmp/2ksd41337162598.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/3t7491337162598.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 102 95.75000 6.2500000 2 94 93.45161 0.5483871 3 85 87.70370 -2.7037037 4 87 85.29167 1.7083333 5 77 79.62963 -2.6296296 6 83 87.70370 -4.7037037 7 79 72.25926 6.7407407 8 110 110.13333 -0.1333333 9 90 87.70370 2.2962963 10 95 95.75000 -0.7500000 11 80 82.40000 -2.4000000 12 95 94.84615 0.1538462 13 105 101.23529 3.7647059 14 91 88.55556 2.4444444 15 69 82.40000 -13.4000000 16 81 79.62963 1.3703704 17 75 79.13793 -4.1379310 18 98 94.41667 3.5833333 19 101 101.23529 -0.2352941 20 96 97.41667 -1.4166667 21 86 85.29167 0.7083333 22 91 85.29167 5.7083333 23 72 72.25926 -0.2592593 24 76 77.64286 -1.6428571 25 95 94.41667 0.5833333 26 96 94.84615 1.1538462 27 92 97.41667 -5.4166667 28 77 79.62963 -2.6296296 29 90 88.55556 1.4444444 30 85 88.55556 -3.5555556 31 81 84.37500 -3.3750000 32 80 79.62963 0.3703704 33 91 93.45161 -2.4516129 34 89 88.00000 1.0000000 35 78 79.62963 -1.6296296 36 66 69.42857 -3.4285714 37 79 88.00000 -9.0000000 38 91 87.70370 3.2962963 39 88 85.29167 2.7083333 40 61 62.42857 -1.4285714 41 77 69.11111 7.8888889 42 81 84.37500 -3.3750000 43 91 87.70370 3.2962963 44 75 84.37500 -9.3750000 45 87 88.55556 -1.5555556 46 93 95.75000 -2.7500000 47 85 87.70370 -2.7037037 48 88 84.37500 3.6250000 49 86 87.70370 -1.7037037 50 93 101.23529 -8.2352941 51 77 82.40000 -5.4000000 52 92 87.70370 4.2962963 53 80 82.40000 -2.4000000 54 98 94.84615 3.1538462 55 109 101.23529 7.7647059 56 95 93.45161 1.5483871 57 75 77.61538 -2.6153846 58 88 94.84615 -6.8461538 59 87 93.45161 -6.4516129 60 84 88.00000 -4.0000000 61 82 72.25926 9.7407407 62 107 97.41667 9.5833333 63 94 93.45161 0.5483871 64 86 77.61538 8.3846154 65 89 93.45161 -4.4516129 66 95 94.84615 0.1538462 67 81 85.29167 -4.2916667 68 87 95.75000 -8.7500000 69 99 95.75000 3.2500000 70 87 93.45161 -6.4516129 71 83 87.70370 -4.7037037 72 88 87.70370 0.2962963 73 89 93.45161 -4.4516129 74 68 79.13793 -11.1379310 75 117 110.13333 6.8666667 76 88 94.84615 -6.8461538 77 84 87.11111 -3.1111111 78 94 94.41667 -0.4166667 79 109 105.41667 3.5833333 80 108 105.41667 2.5833333 81 61 72.25926 -11.2592593 82 107 101.23529 5.7647059 83 80 82.40000 -2.4000000 84 92 87.70370 4.2962963 85 94 87.70370 6.2962963 86 95 93.45161 1.5483871 87 83 87.70370 -4.7037037 88 92 97.41667 -5.4166667 89 75 77.64286 -2.6428571 90 94 79.62963 14.3703704 91 83 77.61538 5.3846154 92 110 110.13333 -0.1333333 93 80 82.40000 -2.4000000 94 101 95.75000 5.2500000 95 81 94.41667 -13.4166667 96 59 62.42857 -3.4285714 97 90 82.40000 7.6000000 98 94 97.41667 -3.4166667 99 83 87.70370 -4.7037037 100 90 94.84615 -4.8461538 101 82 88.00000 -6.0000000 102 93 97.41667 -4.4166667 103 94 95.75000 -1.7500000 104 84 88.55556 -4.5555556 105 110 105.41667 4.5833333 106 69 79.62963 -10.6296296 107 97 101.23529 -4.2352941 108 95 87.70370 7.2962963 109 98 95.75000 2.2500000 110 78 79.62963 -1.6296296 111 89 95.75000 -6.7500000 112 72 77.61538 -5.6153846 113 83 79.62963 3.3703704 114 120 110.13333 9.8666667 115 73 77.64286 -4.6428571 116 90 88.55556 1.4444444 117 93 101.23529 -8.2352941 118 90 88.55556 1.4444444 119 98 95.75000 2.2500000 120 85 87.70370 -2.7037037 121 101 94.41667 6.5833333 122 89 87.70370 1.2962963 123 108 93.45161 14.5483871 124 96 94.41667 1.5833333 125 86 87.11111 -1.1111111 126 115 110.13333 4.8666667 127 79 77.61538 1.3846154 128 103 101.23529 1.7647059 129 93 94.84615 -1.8461538 130 107 105.41667 1.5833333 131 87 85.29167 1.7083333 132 84 77.64286 6.3571429 133 65 79.62963 -14.6296296 134 72 72.25926 -0.2592593 135 87 87.70370 -0.7037037 136 80 85.29167 -5.2916667 137 92 82.40000 9.6000000 138 87 88.00000 -1.0000000 139 106 101.23529 4.7647059 140 87 84.37500 2.6250000 141 92 94.84615 -2.8461538 142 88 79.62963 8.3703704 143 92 94.84615 -2.8461538 144 96 95.75000 0.2500000 145 86 79.62963 6.3703704 146 94 88.00000 6.0000000 147 98 101.23529 -3.2352941 148 96 101.23529 -5.2352941 149 79 77.64286 1.3571429 150 93 93.45161 -0.4516129 151 81 77.61538 3.3846154 152 72 72.25926 -0.2592593 153 109 101.23529 7.7647059 154 72 72.25926 -0.2592593 155 96 94.84615 1.1538462 156 74 77.61538 -3.6153846 157 88 88.55556 -0.5555556 158 97 94.84615 2.1538462 159 97 95.75000 1.2500000 160 92 84.37500 7.6250000 161 93 93.45161 -0.4516129 162 89 85.29167 3.7083333 163 98 97.41667 0.5833333 164 109 110.13333 -1.1333333 165 99 105.41667 -6.4166667 166 99 94.84615 4.1538462 167 98 94.84615 3.1538462 168 93 88.00000 5.0000000 169 105 105.41667 -0.4166667 170 88 79.62963 8.3703704 171 102 105.41667 -3.4166667 172 101 97.41667 3.5833333 173 90 87.70370 2.2962963 174 93 93.45161 -0.4516129 175 96 88.00000 8.0000000 176 100 93.45161 6.5483871 177 83 79.62963 3.3703704 178 97 95.75000 1.2500000 179 68 72.25926 -4.2592593 180 106 110.13333 -4.1333333 181 86 87.70370 -1.7037037 182 78 77.64286 0.3571429 183 99 101.23529 -2.2352941 184 94 93.45161 0.5483871 185 103 105.41667 -2.4166667 186 110 110.13333 -0.1333333 187 86 94.84615 -8.8461538 188 87 79.62963 7.3703704 189 104 101.23529 2.7647059 190 96 94.84615 1.1538462 191 100 101.23529 -1.2352941 192 111 94.41667 16.5833333 193 82 85.29167 -3.2916667 194 72 72.25926 -0.2592593 195 88 88.55556 -0.5555556 196 103 94.84615 8.1538462 197 80 79.62963 0.3703704 198 93 94.84615 -1.8461538 199 88 93.45161 -5.4516129 200 56 69.11111 -13.1111111 201 120 110.13333 9.8666667 202 86 77.61538 8.3846154 203 82 88.55556 -6.5555556 204 102 93.45161 8.5483871 205 74 77.64286 -3.6428571 206 95 94.41667 0.5833333 207 75 79.13793 -4.1379310 208 76 79.13793 -3.1379310 209 72 79.13793 -7.1379310 210 84 79.13793 4.8620690 211 99 97.41667 1.5833333 212 95 88.55556 6.4444444 213 81 79.13793 1.8620690 214 98 93.45161 4.5483871 215 90 85.29167 4.7083333 216 93 93.45161 -0.4516129 217 81 79.62963 1.3703704 218 72 79.62963 -7.6296296 219 72 77.64286 -5.6428571 220 75 77.64286 -2.6428571 221 57 62.42857 -5.4285714 222 68 69.11111 -1.1111111 223 70 72.25926 -2.2592593 224 70 72.25926 -2.2592593 225 90 85.29167 4.7083333 226 87 87.11111 -0.1111111 227 100 95.75000 4.2500000 228 69 79.13793 -10.1379310 229 78 82.40000 -4.4000000 230 75 72.25926 2.7407407 231 71 79.13793 -8.1379310 232 85 88.55556 -3.5555556 233 88 87.70370 0.2962963 234 83 82.40000 0.6000000 235 72 69.11111 2.8888889 236 85 79.13793 5.8620690 237 79 79.13793 -0.1379310 238 82 84.37500 -2.3750000 239 79 77.61538 1.3846154 240 85 88.55556 -3.5555556 241 89 87.70370 1.2962963 242 70 69.11111 0.8888889 243 95 94.84615 0.1538462 244 89 84.37500 4.6250000 245 72 62.42857 9.5714286 246 89 79.13793 9.8620690 247 89 85.29167 3.7083333 248 74 79.13793 -5.1379310 249 90 88.55556 1.4444444 250 92 94.84615 -2.8461538 251 88 82.40000 5.6000000 252 113 110.13333 2.8666667 253 89 93.45161 -4.4516129 254 94 79.13793 14.8620690 255 76 77.64286 -1.6428571 256 94 93.45161 0.5483871 257 85 93.45161 -8.4516129 258 79 79.62963 -0.6296296 259 77 69.42857 7.5714286 260 69 79.62963 -10.6296296 261 88 88.55556 -0.5555556 262 86 85.29167 0.7083333 263 82 72.25926 9.7407407 264 84 79.13793 4.8620690 265 96 93.45161 2.5483871 266 82 93.45161 -11.4516129 267 88 82.40000 5.6000000 268 111 105.41667 5.5833333 269 67 69.11111 -2.1111111 270 73 79.62963 -6.6296296 271 105 105.41667 -0.4166667 272 94 93.45161 0.5483871 273 96 95.75000 0.2500000 274 97 110.13333 -13.1333333 275 70 77.61538 -7.6153846 276 91 87.11111 3.8888889 277 110 110.13333 -0.1333333 278 92 95.75000 -3.7500000 279 68 79.13793 -11.1379310 280 104 110.13333 -6.1333333 281 87 87.70370 -0.7037037 282 96 93.45161 2.5483871 283 88 87.11111 0.8888889 284 95 93.45161 1.5483871 285 75 72.25926 2.7407407 286 84 87.11111 -3.1111111 287 72 72.25926 -0.2592593 288 91 93.45161 -2.4516129 289 89 94.41667 -5.4166667 290 67 69.42857 -2.4285714 291 81 79.13793 1.8620690 292 93 94.41667 -1.4166667 293 106 105.41667 0.5833333 294 100 88.55556 11.4444444 295 63 62.42857 0.5714286 296 84 79.13793 4.8620690 297 81 77.64286 3.3571429 298 78 77.61538 0.3846154 299 90 85.29167 4.7083333 300 108 110.13333 -2.1333333 301 66 69.11111 -3.1111111 302 99 97.41667 1.5833333 303 65 72.25926 -7.2592593 304 93 94.84615 -1.8461538 305 100 95.75000 4.2500000 306 92 93.45161 -1.4516129 307 100 105.41667 -5.4166667 308 77 82.40000 -5.4000000 309 85 79.13793 5.8620690 310 80 79.13793 0.8620690 311 69 72.25926 -3.2592593 312 91 85.29167 5.7083333 313 53 62.42857 -9.4285714 314 91 95.75000 -4.7500000 315 86 77.64286 8.3571429 316 95 87.70370 7.2962963 317 66 69.42857 -3.4285714 318 95 94.84615 0.1538462 319 75 72.25926 2.7407407 320 90 95.75000 -5.7500000 321 90 87.11111 2.8888889 322 83 79.62963 3.3703704 323 92 94.41667 -2.4166667 324 84 79.13793 4.8620690 325 86 79.13793 6.8620690 326 72 62.42857 9.5714286 327 73 72.25926 0.7407407 328 100 95.75000 4.2500000 329 79 85.29167 -6.2916667 330 71 69.11111 1.8888889 331 82 87.11111 -5.1111111 332 99 94.84615 4.1538462 333 85 77.64286 7.3571429 334 80 85.29167 -5.2916667 335 85 79.62963 5.3703704 336 98 93.45161 4.5483871 337 99 94.84615 4.1538462 338 86 79.13793 6.8620690 339 73 72.25926 0.7407407 340 78 79.13793 -1.1379310 341 90 88.55556 1.4444444 342 103 97.41667 5.5833333 343 87 85.29167 1.7083333 344 76 79.13793 -3.1379310 345 102 93.45161 8.5483871 346 73 72.25926 0.7407407 347 101 94.84615 6.1538462 348 83 85.29167 -2.2916667 349 80 79.62963 0.3703704 350 79 72.25926 6.7407407 351 63 69.42857 -6.4285714 352 96 101.23529 -5.2352941 353 75 69.11111 5.8888889 354 103 110.13333 -7.1333333 355 89 85.29167 3.7083333 356 105 101.23529 3.7647059 357 78 82.40000 -4.4000000 358 80 85.29167 -5.2916667 359 95 97.41667 -2.4166667 360 96 82.40000 13.6000000 361 71 72.25926 -1.2592593 362 80 69.42857 10.5714286 363 92 87.11111 4.8888889 364 67 77.61538 -10.6153846 365 97 94.84615 2.1538462 366 79 77.61538 1.3846154 367 79 79.62963 -0.6296296 368 83 87.70370 -4.7037037 369 77 79.62963 -2.6296296 370 82 85.29167 -3.2916667 371 79 79.13793 -0.1379310 372 83 87.70370 -4.7037037 373 71 72.25926 -1.2592593 374 83 85.29167 -2.2916667 375 73 77.64286 -4.6428571 376 86 88.55556 -2.5555556 377 77 85.29167 -8.2916667 378 72 79.13793 -7.1379310 379 73 72.25926 0.7407407 380 82 79.13793 2.8620690 381 65 72.25926 -7.2592593 382 67 69.42857 -2.4285714 383 78 79.62963 -1.6296296 384 70 72.25926 -2.2592593 385 78 79.13793 -1.1379310 386 88 94.41667 -6.4166667 387 85 87.70370 -2.7037037 > 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/41tzq1337162598.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/5545n1337162598.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/6j6zd1337162598.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/7jrdt1337162598.tab") + } > > try(system("convert tmp/2ksd41337162598.ps tmp/2ksd41337162598.png",intern=TRUE)) character(0) > try(system("convert tmp/3t7491337162598.ps tmp/3t7491337162598.png",intern=TRUE)) character(0) > try(system("convert tmp/41tzq1337162598.ps tmp/41tzq1337162598.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.779 0.325 8.123