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 = 'Exam Items' > par8 = 'CSUQ' > par7 = 'all' > par6 = 'all' > par5 = 'all' > par4 = 'yes' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'Exam Items' > par8 <- 'CSUQ' > par7 <- 'all' > par6 <- 'all' > par5 <- 'all' > par4 <- 'yes' > 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] 15 13 7 14 10 16 14 14 11 14 0 14 3 14 4 8 8 7 [19] 6 10 11 13 10 12 10 15 4 10 13 12 10 11 6 6 7 11 [37] 13 5 7 8 6 11 8 0 8 17 9 6 6 2 14 4 -1 10 [55] -1 8 8 8 2 8 12 5 6 6 9 15 11 5 10 2 11 11 [73] 9 11 12 5 4 -2 11 7 13 6 9 9 8 11 3 5 8 13 [91] 12 9 15 10 14 8 7 9 13 8 8 9 10 11 -3 7 3 15 [109] 7 4 10 10 4 15 4 15 6 2 6 14 13 6 11 9 8 3 [127] 7 7 -2 6 10 8 5 12 2 14 8 8 0 11 7 12 10 9 [145] 11 10 11 16 9 8 6 10 13 10 10 6 8 7 10 10 16 7 [163] 13 1 11 10 8 7 12 12 6 15 9 11 14 9 11 12 0 12 [181] 7 5 0 8 10 7 8 1 7 11 4 16 6 16 6 3 8 7 [199] 0 11 5 11 -2 18 12 14 3 8 7 8 8 8 7 11 10 8 [217] 10 6 9 14 5 8 1 9 6 11 12 2 6 5 11 3 5 11 [235] 6 11 0 4 10 8 4 -2 5 14 0 6 3 5 3 9 3 4 [253] 1 3 9 14 9 4 4 5 6 1 4 10 0 6 4 7 6 14 [271] 7 -1 9 1 4 2 3 2 2 4 -3 2 8 5 12 9 -2 -12 [289] 5 -2 -2 5 -1 4 6 -4 5 7 8 2 10 4 9 2 4 2 [307] 2 8 8 6 5 10 10 9 1 10 12 12 7 -4 -4 -4 5 8 [325] -1 9 11 0 -1 5 9 3 -2 1 -3 1 5 7 2 0 6 9 [343] 8 10 3 1 4 14 7 4 -3 8 6 0 7 -1 5 2 3 8 [361] -3 2 3 0 5 7 7 9 2 3 4 9 4 1 5 8 3 3 [379] 7 7 13 7 1 6 11 12 3 2 5 7 5 4 5 3 4 5 [397] 6 0 6 13 4 -2 8 12 9 12 10 1 0 0 0 8 4 11 [415] 7 8 3 3 10 3 6 10 3 11 4 2 8 8 2 4 14 3 [433] 10 6 5 7 1 4 8 13 5 7 5 9 11 1 > 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]) -12 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 4 5 9 7 17 15 21 26 31 32 35 36 46 29 35 32 19 13 18 15 16 17 18 8 5 1 1 > colnames(x) [1] "endo" "U1" "U2" "U3" "U4" "U5" "U6" "U7" "U8" "U9" [11] "U10" "U11" "U12" "U13" "U14" "U15" "U16" "U17" "U18" "U19" [21] "U20" "U21" "U22" "U23" "U24" "U25" "U26" "U27" "U28" "U29" [31] "U30" "U31" "U32" "U33" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 15 13 7 14 10 16 14 14 11 14 0 14 3 14 4 8 8 7 [19] 6 10 11 13 10 12 10 15 4 10 13 12 10 11 6 6 7 11 [37] 13 5 7 8 6 11 8 0 8 17 9 6 6 2 14 4 -1 10 [55] -1 8 8 8 2 8 12 5 6 6 9 15 11 5 10 2 11 11 [73] 9 11 12 5 4 -2 11 7 13 6 9 9 8 11 3 5 8 13 [91] 12 9 15 10 14 8 7 9 13 8 8 9 10 11 -3 7 3 15 [109] 7 4 10 10 4 15 4 15 6 2 6 14 13 6 11 9 8 3 [127] 7 7 -2 6 10 8 5 12 2 14 8 8 0 11 7 12 10 9 [145] 11 10 11 16 9 8 6 10 13 10 10 6 8 7 10 10 16 7 [163] 13 1 11 10 8 7 12 12 6 15 9 11 14 9 11 12 0 12 [181] 7 5 0 8 10 7 8 1 7 11 4 16 6 16 6 3 8 7 [199] 0 11 5 11 -2 18 12 14 3 8 7 8 8 8 7 11 10 8 [217] 10 6 9 14 5 8 1 9 6 11 12 2 6 5 11 3 5 11 [235] 6 11 0 4 10 8 4 -2 5 14 0 6 3 5 3 9 3 4 [253] 1 3 9 14 9 4 4 5 6 1 4 10 0 6 4 7 6 14 [271] 7 -1 9 1 4 2 3 2 2 4 -3 2 8 5 12 9 -2 -12 [289] 5 -2 -2 5 -1 4 6 -4 5 7 8 2 10 4 9 2 4 2 [307] 2 8 8 6 5 10 10 9 1 10 12 12 7 -4 -4 -4 5 8 [325] -1 9 11 0 -1 5 9 3 -2 1 -3 1 5 7 2 0 6 9 [343] 8 10 3 1 4 14 7 4 -3 8 6 0 7 -1 5 2 3 8 [361] -3 2 3 0 5 7 7 9 2 3 4 9 4 1 5 8 3 3 [379] 7 7 13 7 1 6 11 12 3 2 5 7 5 4 5 3 4 5 [397] 6 0 6 13 4 -2 8 12 9 12 10 1 0 0 0 8 4 11 [415] 7 8 3 3 10 3 6 10 3 11 4 2 8 8 2 4 14 3 [433] 10 6 5 7 1 4 8 13 5 7 5 9 11 1 > 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/1p5491335782983.tab") + } + } > m Conditional inference tree with 2 terminal nodes Response: endo Inputs: U1, U2, U3, U4, U5, U6, U7, U8, U9, U10, U11, U12, U13, U14, U15, U16, U17, U18, U19, U20, U21, U22, U23, U24, U25, U26, U27, U28, U29, U30, U31, U32, U33 Number of observations: 446 1) U20 <= 3; criterion = 0.993, statistic = 13.643 2)* weights = 138 1) U20 > 3 3)* weights = 308 > postscript(file="/var/wessaorg/rcomp/tmp/21de11335782983.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/3mnn21335782983.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 15 7.305195 7.6948052 2 13 7.305195 5.6948052 3 7 7.305195 -0.3051948 4 14 7.305195 6.6948052 5 10 7.305195 2.6948052 6 16 7.305195 8.6948052 7 14 7.305195 6.6948052 8 14 5.637681 8.3623188 9 11 7.305195 3.6948052 10 14 5.637681 8.3623188 11 0 7.305195 -7.3051948 12 14 7.305195 6.6948052 13 3 7.305195 -4.3051948 14 14 7.305195 6.6948052 15 4 5.637681 -1.6376812 16 8 7.305195 0.6948052 17 8 7.305195 0.6948052 18 7 7.305195 -0.3051948 19 6 7.305195 -1.3051948 20 10 7.305195 2.6948052 21 11 7.305195 3.6948052 22 13 7.305195 5.6948052 23 10 7.305195 2.6948052 24 12 7.305195 4.6948052 25 10 7.305195 2.6948052 26 15 7.305195 7.6948052 27 4 7.305195 -3.3051948 28 10 7.305195 2.6948052 29 13 5.637681 7.3623188 30 12 7.305195 4.6948052 31 10 7.305195 2.6948052 32 11 7.305195 3.6948052 33 6 5.637681 0.3623188 34 6 7.305195 -1.3051948 35 7 7.305195 -0.3051948 36 11 7.305195 3.6948052 37 13 7.305195 5.6948052 38 5 5.637681 -0.6376812 39 7 5.637681 1.3623188 40 8 7.305195 0.6948052 41 6 7.305195 -1.3051948 42 11 7.305195 3.6948052 43 8 7.305195 0.6948052 44 0 7.305195 -7.3051948 45 8 5.637681 2.3623188 46 17 7.305195 9.6948052 47 9 7.305195 1.6948052 48 6 7.305195 -1.3051948 49 6 5.637681 0.3623188 50 2 5.637681 -3.6376812 51 14 7.305195 6.6948052 52 4 7.305195 -3.3051948 53 -1 7.305195 -8.3051948 54 10 7.305195 2.6948052 55 -1 5.637681 -6.6376812 56 8 7.305195 0.6948052 57 8 7.305195 0.6948052 58 8 7.305195 0.6948052 59 2 5.637681 -3.6376812 60 8 7.305195 0.6948052 61 12 5.637681 6.3623188 62 5 7.305195 -2.3051948 63 6 7.305195 -1.3051948 64 6 7.305195 -1.3051948 65 9 7.305195 1.6948052 66 15 7.305195 7.6948052 67 11 7.305195 3.6948052 68 5 5.637681 -0.6376812 69 10 7.305195 2.6948052 70 2 7.305195 -5.3051948 71 11 7.305195 3.6948052 72 11 7.305195 3.6948052 73 9 5.637681 3.3623188 74 11 7.305195 3.6948052 75 12 7.305195 4.6948052 76 5 5.637681 -0.6376812 77 4 7.305195 -3.3051948 78 -2 7.305195 -9.3051948 79 11 7.305195 3.6948052 80 7 7.305195 -0.3051948 81 13 7.305195 5.6948052 82 6 5.637681 0.3623188 83 9 5.637681 3.3623188 84 9 7.305195 1.6948052 85 8 7.305195 0.6948052 86 11 7.305195 3.6948052 87 3 7.305195 -4.3051948 88 5 5.637681 -0.6376812 89 8 5.637681 2.3623188 90 13 7.305195 5.6948052 91 12 5.637681 6.3623188 92 9 5.637681 3.3623188 93 15 7.305195 7.6948052 94 10 7.305195 2.6948052 95 14 7.305195 6.6948052 96 8 7.305195 0.6948052 97 7 7.305195 -0.3051948 98 9 7.305195 1.6948052 99 13 7.305195 5.6948052 100 8 7.305195 0.6948052 101 8 7.305195 0.6948052 102 9 7.305195 1.6948052 103 10 7.305195 2.6948052 104 11 5.637681 5.3623188 105 -3 5.637681 -8.6376812 106 7 5.637681 1.3623188 107 3 7.305195 -4.3051948 108 15 7.305195 7.6948052 109 7 7.305195 -0.3051948 110 4 7.305195 -3.3051948 111 10 7.305195 2.6948052 112 10 5.637681 4.3623188 113 4 7.305195 -3.3051948 114 15 7.305195 7.6948052 115 4 7.305195 -3.3051948 116 15 7.305195 7.6948052 117 6 5.637681 0.3623188 118 2 5.637681 -3.6376812 119 6 7.305195 -1.3051948 120 14 7.305195 6.6948052 121 13 7.305195 5.6948052 122 6 7.305195 -1.3051948 123 11 5.637681 5.3623188 124 9 5.637681 3.3623188 125 8 7.305195 0.6948052 126 3 7.305195 -4.3051948 127 7 7.305195 -0.3051948 128 7 5.637681 1.3623188 129 -2 5.637681 -7.6376812 130 6 5.637681 0.3623188 131 10 7.305195 2.6948052 132 8 5.637681 2.3623188 133 5 7.305195 -2.3051948 134 12 5.637681 6.3623188 135 2 5.637681 -3.6376812 136 14 7.305195 6.6948052 137 8 5.637681 2.3623188 138 8 5.637681 2.3623188 139 0 5.637681 -5.6376812 140 11 7.305195 3.6948052 141 7 7.305195 -0.3051948 142 12 7.305195 4.6948052 143 10 5.637681 4.3623188 144 9 7.305195 1.6948052 145 11 7.305195 3.6948052 146 10 7.305195 2.6948052 147 11 7.305195 3.6948052 148 16 7.305195 8.6948052 149 9 7.305195 1.6948052 150 8 7.305195 0.6948052 151 6 7.305195 -1.3051948 152 10 7.305195 2.6948052 153 13 7.305195 5.6948052 154 10 5.637681 4.3623188 155 10 7.305195 2.6948052 156 6 7.305195 -1.3051948 157 8 7.305195 0.6948052 158 7 7.305195 -0.3051948 159 10 7.305195 2.6948052 160 10 5.637681 4.3623188 161 16 7.305195 8.6948052 162 7 7.305195 -0.3051948 163 13 7.305195 5.6948052 164 1 5.637681 -4.6376812 165 11 7.305195 3.6948052 166 10 7.305195 2.6948052 167 8 7.305195 0.6948052 168 7 7.305195 -0.3051948 169 12 7.305195 4.6948052 170 12 5.637681 6.3623188 171 6 7.305195 -1.3051948 172 15 7.305195 7.6948052 173 9 5.637681 3.3623188 174 11 7.305195 3.6948052 175 14 5.637681 8.3623188 176 9 7.305195 1.6948052 177 11 7.305195 3.6948052 178 12 7.305195 4.6948052 179 0 7.305195 -7.3051948 180 12 5.637681 6.3623188 181 7 7.305195 -0.3051948 182 5 7.305195 -2.3051948 183 0 5.637681 -5.6376812 184 8 5.637681 2.3623188 185 10 5.637681 4.3623188 186 7 7.305195 -0.3051948 187 8 7.305195 0.6948052 188 1 5.637681 -4.6376812 189 7 5.637681 1.3623188 190 11 5.637681 5.3623188 191 4 7.305195 -3.3051948 192 16 5.637681 10.3623188 193 6 7.305195 -1.3051948 194 16 7.305195 8.6948052 195 6 5.637681 0.3623188 196 3 7.305195 -4.3051948 197 8 7.305195 0.6948052 198 7 7.305195 -0.3051948 199 0 5.637681 -5.6376812 200 11 7.305195 3.6948052 201 5 7.305195 -2.3051948 202 11 7.305195 3.6948052 203 -2 7.305195 -9.3051948 204 18 5.637681 12.3623188 205 12 7.305195 4.6948052 206 14 7.305195 6.6948052 207 3 7.305195 -4.3051948 208 8 7.305195 0.6948052 209 7 7.305195 -0.3051948 210 8 7.305195 0.6948052 211 8 5.637681 2.3623188 212 8 5.637681 2.3623188 213 7 5.637681 1.3623188 214 11 7.305195 3.6948052 215 10 7.305195 2.6948052 216 8 5.637681 2.3623188 217 10 7.305195 2.6948052 218 6 5.637681 0.3623188 219 9 5.637681 3.3623188 220 14 7.305195 6.6948052 221 5 7.305195 -2.3051948 222 8 7.305195 0.6948052 223 1 7.305195 -6.3051948 224 9 5.637681 3.3623188 225 6 7.305195 -1.3051948 226 11 7.305195 3.6948052 227 12 7.305195 4.6948052 228 2 5.637681 -3.6376812 229 6 7.305195 -1.3051948 230 5 5.637681 -0.6376812 231 11 7.305195 3.6948052 232 3 7.305195 -4.3051948 233 5 7.305195 -2.3051948 234 11 7.305195 3.6948052 235 6 7.305195 -1.3051948 236 11 7.305195 3.6948052 237 0 7.305195 -7.3051948 238 4 5.637681 -1.6376812 239 10 7.305195 2.6948052 240 8 7.305195 0.6948052 241 4 7.305195 -3.3051948 242 -2 7.305195 -9.3051948 243 5 5.637681 -0.6376812 244 14 7.305195 6.6948052 245 0 7.305195 -7.3051948 246 6 7.305195 -1.3051948 247 3 7.305195 -4.3051948 248 5 7.305195 -2.3051948 249 3 7.305195 -4.3051948 250 9 5.637681 3.3623188 251 3 7.305195 -4.3051948 252 4 7.305195 -3.3051948 253 1 5.637681 -4.6376812 254 3 5.637681 -2.6376812 255 9 7.305195 1.6948052 256 14 7.305195 6.6948052 257 9 5.637681 3.3623188 258 4 7.305195 -3.3051948 259 4 7.305195 -3.3051948 260 5 5.637681 -0.6376812 261 6 7.305195 -1.3051948 262 1 5.637681 -4.6376812 263 4 7.305195 -3.3051948 264 10 7.305195 2.6948052 265 0 7.305195 -7.3051948 266 6 7.305195 -1.3051948 267 4 7.305195 -3.3051948 268 7 7.305195 -0.3051948 269 6 7.305195 -1.3051948 270 14 5.637681 8.3623188 271 7 7.305195 -0.3051948 272 -1 5.637681 -6.6376812 273 9 5.637681 3.3623188 274 1 5.637681 -4.6376812 275 4 7.305195 -3.3051948 276 2 7.305195 -5.3051948 277 3 7.305195 -4.3051948 278 2 7.305195 -5.3051948 279 2 7.305195 -5.3051948 280 4 7.305195 -3.3051948 281 -3 7.305195 -10.3051948 282 2 7.305195 -5.3051948 283 8 5.637681 2.3623188 284 5 7.305195 -2.3051948 285 12 5.637681 6.3623188 286 9 7.305195 1.6948052 287 -2 5.637681 -7.6376812 288 -12 5.637681 -17.6376812 289 5 5.637681 -0.6376812 290 -2 5.637681 -7.6376812 291 -2 5.637681 -7.6376812 292 5 7.305195 -2.3051948 293 -1 5.637681 -6.6376812 294 4 7.305195 -3.3051948 295 6 5.637681 0.3623188 296 -4 7.305195 -11.3051948 297 5 7.305195 -2.3051948 298 7 5.637681 1.3623188 299 8 7.305195 0.6948052 300 2 5.637681 -3.6376812 301 10 5.637681 4.3623188 302 4 5.637681 -1.6376812 303 9 5.637681 3.3623188 304 2 5.637681 -3.6376812 305 4 5.637681 -1.6376812 306 2 7.305195 -5.3051948 307 2 5.637681 -3.6376812 308 8 7.305195 0.6948052 309 8 5.637681 2.3623188 310 6 7.305195 -1.3051948 311 5 7.305195 -2.3051948 312 10 7.305195 2.6948052 313 10 7.305195 2.6948052 314 9 7.305195 1.6948052 315 1 5.637681 -4.6376812 316 10 7.305195 2.6948052 317 12 7.305195 4.6948052 318 12 7.305195 4.6948052 319 7 5.637681 1.3623188 320 -4 5.637681 -9.6376812 321 -4 7.305195 -11.3051948 322 -4 7.305195 -11.3051948 323 5 5.637681 -0.6376812 324 8 7.305195 0.6948052 325 -1 7.305195 -8.3051948 326 9 5.637681 3.3623188 327 11 7.305195 3.6948052 328 0 5.637681 -5.6376812 329 -1 7.305195 -8.3051948 330 5 7.305195 -2.3051948 331 9 5.637681 3.3623188 332 3 7.305195 -4.3051948 333 -2 5.637681 -7.6376812 334 1 7.305195 -6.3051948 335 -3 7.305195 -10.3051948 336 1 7.305195 -6.3051948 337 5 7.305195 -2.3051948 338 7 7.305195 -0.3051948 339 2 5.637681 -3.6376812 340 0 7.305195 -7.3051948 341 6 5.637681 0.3623188 342 9 5.637681 3.3623188 343 8 7.305195 0.6948052 344 10 7.305195 2.6948052 345 3 7.305195 -4.3051948 346 1 5.637681 -4.6376812 347 4 5.637681 -1.6376812 348 14 7.305195 6.6948052 349 7 7.305195 -0.3051948 350 4 7.305195 -3.3051948 351 -3 7.305195 -10.3051948 352 8 7.305195 0.6948052 353 6 7.305195 -1.3051948 354 0 7.305195 -7.3051948 355 7 7.305195 -0.3051948 356 -1 7.305195 -8.3051948 357 5 7.305195 -2.3051948 358 2 7.305195 -5.3051948 359 3 5.637681 -2.6376812 360 8 7.305195 0.6948052 361 -3 7.305195 -10.3051948 362 2 7.305195 -5.3051948 363 3 5.637681 -2.6376812 364 0 5.637681 -5.6376812 365 5 5.637681 -0.6376812 366 7 7.305195 -0.3051948 367 7 7.305195 -0.3051948 368 9 7.305195 1.6948052 369 2 5.637681 -3.6376812 370 3 5.637681 -2.6376812 371 4 7.305195 -3.3051948 372 9 7.305195 1.6948052 373 4 5.637681 -1.6376812 374 1 5.637681 -4.6376812 375 5 7.305195 -2.3051948 376 8 5.637681 2.3623188 377 3 5.637681 -2.6376812 378 3 7.305195 -4.3051948 379 7 7.305195 -0.3051948 380 7 7.305195 -0.3051948 381 13 7.305195 5.6948052 382 7 5.637681 1.3623188 383 1 5.637681 -4.6376812 384 6 7.305195 -1.3051948 385 11 7.305195 3.6948052 386 12 5.637681 6.3623188 387 3 5.637681 -2.6376812 388 2 7.305195 -5.3051948 389 5 7.305195 -2.3051948 390 7 5.637681 1.3623188 391 5 7.305195 -2.3051948 392 4 7.305195 -3.3051948 393 5 7.305195 -2.3051948 394 3 7.305195 -4.3051948 395 4 7.305195 -3.3051948 396 5 5.637681 -0.6376812 397 6 7.305195 -1.3051948 398 0 5.637681 -5.6376812 399 6 7.305195 -1.3051948 400 13 7.305195 5.6948052 401 4 5.637681 -1.6376812 402 -2 7.305195 -9.3051948 403 8 5.637681 2.3623188 404 12 7.305195 4.6948052 405 9 7.305195 1.6948052 406 12 7.305195 4.6948052 407 10 7.305195 2.6948052 408 1 7.305195 -6.3051948 409 0 7.305195 -7.3051948 410 0 5.637681 -5.6376812 411 0 7.305195 -7.3051948 412 8 7.305195 0.6948052 413 4 7.305195 -3.3051948 414 11 5.637681 5.3623188 415 7 5.637681 1.3623188 416 8 7.305195 0.6948052 417 3 7.305195 -4.3051948 418 3 7.305195 -4.3051948 419 10 7.305195 2.6948052 420 3 7.305195 -4.3051948 421 6 5.637681 0.3623188 422 10 7.305195 2.6948052 423 3 5.637681 -2.6376812 424 11 7.305195 3.6948052 425 4 5.637681 -1.6376812 426 2 7.305195 -5.3051948 427 8 7.305195 0.6948052 428 8 7.305195 0.6948052 429 2 7.305195 -5.3051948 430 4 7.305195 -3.3051948 431 14 7.305195 6.6948052 432 3 5.637681 -2.6376812 433 10 7.305195 2.6948052 434 6 7.305195 -1.3051948 435 5 7.305195 -2.3051948 436 7 7.305195 -0.3051948 437 1 7.305195 -6.3051948 438 4 7.305195 -3.3051948 439 8 7.305195 0.6948052 440 13 5.637681 7.3623188 441 5 7.305195 -2.3051948 442 7 7.305195 -0.3051948 443 5 5.637681 -0.6376812 444 9 7.305195 1.6948052 445 11 7.305195 3.6948052 446 1 5.637681 -4.6376812 > 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/4wk1u1335782983.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/5akpb1335782983.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/6x1hq1335782983.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/7h71g1335782983.tab") + } > > try(system("convert tmp/21de11335782983.ps tmp/21de11335782983.png",intern=TRUE)) character(0) > try(system("convert tmp/3mnn21335782983.ps tmp/3mnn21335782983.png",intern=TRUE)) character(0) > try(system("convert tmp/4wk1u1335782983.ps tmp/4wk1u1335782983.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.104 0.331 7.431