R version 2.12.0 (2010-10-15) Copyright (C) 2010 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 = 'ATTLES separate' > par8 = 'ATTLES separate' > par7 = 'all' > par6 = 'prep' > par5 = 'male' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'ATTLES separate' > par8 <- 'ATTLES separate' > par7 <- 'all' > par6 <- 'prep' > par5 <- 'male' > 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] 28 38 35 40 39 35 38 35 35 39 37 35 40 32 34 38 31 31 34 36 33 38 35 37 27 [26] 31 37 36 38 38 37 28 40 32 33 35 39 34 37 36 37 38 32 33 33 39 34 31 34 31 [51] 38 35 42 38 34 39 38 34 32 32 34 35 37 41 34 31 41 31 30 31 30 35 31 37 34 [76] 33 35 31 37 36 29 33 34 32 37 31 27 36 31 34 38 36 39 39 39 29 35 36 39 39 [101] 39 42 42 39 34 37 30 37 42 40 31 32 34 36 31 32 35 39 37 30 33 38 28 37 28 [126] 46 33 37 32 33 31 36 37 33 36 28 39 40 30 37 29 33 31 40 34 22 35 31 31 37 [151] 37 49 37 36 30 31 42 39 32 32 48 38 39 39 35 32 35 31 34 38 35 36 41 39 34 [176] 33 25 28 38 34 34 31 37 29 37 39 40 38 25 32 35 30 27 46 30 31 29 37 32 35 [201] 30 40 36 38 41 45 40 35 30 29 36 33 32 29 40 35 34 36 40 37 42 27 34 38 31 [226] 33 35 30 34 37 24 31 38 36 35 35 33 38 32 31 44 33 42 36 33 34 42 26 36 36 [251] 35 31 33 28 38 37 30 30 31 31 35 20 37 30 33 36 32 30 36 35 31 36 39 36 36 [276] 27 34 33 29 31 41 34 39 36 31 45 33 36 34 36 32 36 35 27 35 35 38 29 31 38 [301] 36 31 31 29 42 30 33 36 31 31 42 29 34 31 35 36 31 37 31 35 43 29 42 > 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]) 20 22 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 48 1 1 1 2 1 6 7 12 16 39 18 22 27 32 31 28 23 21 11 5 11 1 1 2 2 1 49 1 > colnames(x) [1] "endo" "A11" "A12" "A13" "A14" "A15" "A16" "A17" "A18" "A19" [11] "A20" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 28 38 35 40 39 35 38 35 35 39 37 35 40 32 34 38 31 31 34 36 33 38 35 37 27 [26] 31 37 36 38 38 37 28 40 32 33 35 39 34 37 36 37 38 32 33 33 39 34 31 34 31 [51] 38 35 42 38 34 39 38 34 32 32 34 35 37 41 34 31 41 31 30 31 30 35 31 37 34 [76] 33 35 31 37 36 29 33 34 32 37 31 27 36 31 34 38 36 39 39 39 29 35 36 39 39 [101] 39 42 42 39 34 37 30 37 42 40 31 32 34 36 31 32 35 39 37 30 33 38 28 37 28 [126] 46 33 37 32 33 31 36 37 33 36 28 39 40 30 37 29 33 31 40 34 22 35 31 31 37 [151] 37 49 37 36 30 31 42 39 32 32 48 38 39 39 35 32 35 31 34 38 35 36 41 39 34 [176] 33 25 28 38 34 34 31 37 29 37 39 40 38 25 32 35 30 27 46 30 31 29 37 32 35 [201] 30 40 36 38 41 45 40 35 30 29 36 33 32 29 40 35 34 36 40 37 42 27 34 38 31 [226] 33 35 30 34 37 24 31 38 36 35 35 33 38 32 31 44 33 42 36 33 34 42 26 36 36 [251] 35 31 33 28 38 37 30 30 31 31 35 20 37 30 33 36 32 30 36 35 31 36 39 36 36 [276] 27 34 33 29 31 41 34 39 36 31 45 33 36 34 36 32 36 35 27 35 35 38 29 31 38 [301] 36 31 31 29 42 30 33 36 31 31 42 29 34 31 35 36 31 37 31 35 43 29 42 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/1hsnq1335895850.tab") + } + } > m Conditional inference tree with 19 terminal nodes Response: endo Inputs: A11, A12, A13, A14, A15, A16, A17, A18, A19, A20 Number of observations: 323 1) A15 <= 3; criterion = 1, statistic = 91.813 2) A18 <= 2; criterion = 1, statistic = 37.522 3) A17 <= 3; criterion = 0.996, statistic = 12.474 4)* weights = 12 3) A17 > 3 5)* weights = 13 2) A18 > 2 6) A20 <= 3; criterion = 1, statistic = 36.802 7) A12 <= 2; criterion = 1, statistic = 21.77 8)* weights = 8 7) A12 > 2 9) A14 <= 3; criterion = 0.998, statistic = 13.453 10)* weights = 31 9) A14 > 3 11) A12 <= 3; criterion = 0.971, statistic = 8.863 12)* weights = 15 11) A12 > 3 13) A13 <= 3; criterion = 0.971, statistic = 8.851 14)* weights = 8 13) A13 > 3 15)* weights = 24 6) A20 > 3 16) A19 <= 3; criterion = 0.995, statistic = 12.029 17)* weights = 20 16) A19 > 3 18)* weights = 20 1) A15 > 3 19) A20 <= 3; criterion = 1, statistic = 48.617 20) A11 <= 3; criterion = 1, statistic = 26.642 21) A19 <= 2; criterion = 0.995, statistic = 12.013 22)* weights = 10 21) A19 > 2 23) A18 <= 3; criterion = 0.956, statistic = 8.069 24)* weights = 10 23) A18 > 3 25)* weights = 21 20) A11 > 3 26) A14 <= 3; criterion = 1, statistic = 20.006 27)* weights = 27 26) A14 > 3 28) A19 <= 3; criterion = 0.984, statistic = 9.977 29)* weights = 8 28) A19 > 3 30)* weights = 20 19) A20 > 3 31) A13 <= 4; criterion = 1, statistic = 23.486 32) A18 <= 3; criterion = 1, statistic = 17.401 33)* weights = 15 32) A18 > 3 34)* weights = 36 31) A13 > 4 35) A16 <= 3; criterion = 0.982, statistic = 9.727 36)* weights = 11 35) A16 > 3 37)* weights = 14 > postscript(file="/var/www/rcomp/tmp/2oz5q1335895850.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/www/rcomp/tmp/39dzr1335895850.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 28 30.76923 -2.76923077 2 38 30.76923 7.23076923 3 35 34.96296 0.03703704 4 40 38.08333 1.91666667 5 39 38.08333 0.91666667 6 35 34.93333 0.06666667 7 38 34.96296 3.03703704 8 35 33.70000 1.30000000 9 35 32.00000 3.00000000 10 39 38.08333 0.91666667 11 37 38.70000 -1.70000000 12 35 33.70000 1.30000000 13 40 38.08333 1.91666667 14 32 32.40000 -0.40000000 15 34 30.80000 3.20000000 16 38 34.96296 3.03703704 17 31 32.25000 -1.25000000 18 31 31.67742 -0.67741935 19 34 34.41667 -0.41666667 20 36 35.75000 0.25000000 21 33 31.67742 1.32258065 22 38 34.96296 3.03703704 23 35 34.96296 0.03703704 24 37 34.76190 2.23809524 25 27 28.25000 -1.25000000 26 31 32.25000 -1.25000000 27 37 38.70000 -1.70000000 28 36 32.25000 3.75000000 29 38 38.08333 -0.08333333 30 38 38.08333 -0.08333333 31 37 38.08333 -1.08333333 32 28 26.91667 1.08333333 33 40 38.08333 1.91666667 34 32 36.30000 -4.30000000 35 33 34.96296 -1.96296296 36 35 31.67742 3.32258065 37 39 38.08333 0.91666667 38 34 35.75000 -1.75000000 39 37 38.08333 -1.08333333 40 36 34.96296 1.03703704 41 37 38.08333 -1.08333333 42 38 38.08333 -0.08333333 43 32 34.96296 -2.96296296 44 33 30.80000 2.20000000 45 33 33.70000 -0.70000000 46 39 34.93333 4.06666667 47 34 32.00000 2.00000000 48 31 30.80000 0.20000000 49 34 32.00000 2.00000000 50 31 31.67742 -0.67741935 51 38 38.08333 -0.08333333 52 35 35.75000 -0.75000000 53 42 34.93333 7.06666667 54 38 38.08333 -0.08333333 55 34 35.75000 -1.75000000 56 39 36.30000 2.70000000 57 38 38.70000 -0.70000000 58 34 36.30000 -2.30000000 59 32 31.67742 0.32258065 60 32 34.96296 -2.96296296 61 34 34.96296 -0.96296296 62 35 34.96296 0.03703704 63 37 36.30000 0.70000000 64 41 38.70000 2.30000000 65 34 31.67742 2.32258065 66 31 34.96296 -3.96296296 67 41 43.42857 -2.42857143 68 31 33.70000 -2.70000000 69 30 31.67742 -1.67741935 70 31 34.76190 -3.76190476 71 30 34.93333 -4.93333333 72 35 35.75000 -0.75000000 73 31 34.93333 -3.93333333 74 37 34.93333 2.06666667 75 34 34.96296 -0.96296296 76 33 31.67742 1.32258065 77 35 38.08333 -3.08333333 78 31 32.00000 -1.00000000 79 37 34.96296 2.03703704 80 36 38.08333 -2.08333333 81 29 34.93333 -5.93333333 82 33 32.25000 0.75000000 83 34 31.67742 2.32258065 84 32 32.00000 0.00000000 85 37 34.93333 2.06666667 86 31 31.67742 -0.67741935 87 27 30.76923 -3.76923077 88 36 38.08333 -2.08333333 89 31 32.25000 -1.25000000 90 34 34.41667 -0.41666667 91 38 38.70000 -0.70000000 92 36 34.93333 1.06666667 93 39 38.70000 0.30000000 94 39 38.08333 0.91666667 95 39 34.93333 4.06666667 96 29 30.76923 -1.76923077 97 35 38.08333 -3.08333333 98 36 38.70000 -2.70000000 99 39 36.30000 2.70000000 100 39 34.96296 4.03703704 101 39 38.08333 0.91666667 102 42 38.70000 3.30000000 103 42 38.08333 3.91666667 104 39 38.08333 0.91666667 105 34 33.70000 0.30000000 106 37 38.70000 -1.70000000 107 30 32.40000 -2.40000000 108 37 38.08333 -1.08333333 109 42 43.42857 -1.42857143 110 40 38.70000 1.30000000 111 31 30.76923 0.23076923 112 32 32.40000 -0.40000000 113 34 38.08333 -4.08333333 114 36 34.76190 1.23809524 115 31 33.70000 -2.70000000 116 32 32.40000 -0.40000000 117 35 32.40000 2.60000000 118 39 34.93333 4.06666667 119 37 34.41667 2.58333333 120 30 30.76923 -0.76923077 121 33 31.67742 1.32258065 122 38 39.18182 -1.18181818 123 28 30.80000 -2.80000000 124 37 38.08333 -1.08333333 125 28 30.80000 -2.80000000 126 46 43.42857 2.57142857 127 33 34.96296 -1.96296296 128 37 33.70000 3.30000000 129 32 30.80000 1.20000000 130 33 36.30000 -3.30000000 131 31 33.70000 -2.70000000 132 36 31.67742 4.32258065 133 37 33.70000 3.30000000 134 33 34.96296 -1.96296296 135 36 34.41667 1.58333333 136 28 28.25000 -0.25000000 137 39 34.96296 4.03703704 138 40 38.08333 1.91666667 139 30 31.67742 -1.67741935 140 37 39.18182 -2.18181818 141 29 28.25000 0.75000000 142 33 32.00000 1.00000000 143 31 32.00000 -1.00000000 144 40 38.08333 1.91666667 145 34 33.70000 0.30000000 146 22 28.25000 -6.25000000 147 35 34.96296 0.03703704 148 31 28.25000 2.75000000 149 31 30.76923 0.23076923 150 37 35.75000 1.25000000 151 37 36.30000 0.70000000 152 49 43.42857 5.57142857 153 37 38.08333 -1.08333333 154 36 34.96296 1.03703704 155 30 31.67742 -1.67741935 156 31 32.00000 -1.00000000 157 42 36.30000 5.70000000 158 39 43.42857 -4.42857143 159 32 33.70000 -1.70000000 160 32 34.96296 -2.96296296 161 48 43.42857 4.57142857 162 38 34.76190 3.23809524 163 39 38.08333 0.91666667 164 39 35.75000 3.25000000 165 35 33.70000 1.30000000 166 32 28.25000 3.75000000 167 35 34.76190 0.23809524 168 31 31.67742 -0.67741935 169 34 34.41667 -0.41666667 170 38 38.08333 -0.08333333 171 35 34.96296 0.03703704 172 36 34.76190 1.23809524 173 41 38.08333 2.91666667 174 39 38.08333 0.91666667 175 34 34.76190 -0.76190476 176 33 31.67742 1.32258065 177 25 30.80000 -5.80000000 178 28 26.91667 1.08333333 179 38 38.70000 -0.70000000 180 34 34.76190 -0.76190476 181 34 34.41667 -0.41666667 182 31 31.67742 -0.67741935 183 37 36.30000 0.70000000 184 29 26.91667 2.08333333 185 37 34.41667 2.58333333 186 39 36.30000 2.70000000 187 40 39.18182 0.81818182 188 38 34.76190 3.23809524 189 25 26.91667 -1.91666667 190 32 34.41667 -2.41666667 191 35 34.41667 0.58333333 192 30 30.76923 -0.76923077 193 27 28.25000 -1.25000000 194 46 43.42857 2.57142857 195 30 26.91667 3.08333333 196 31 32.00000 -1.00000000 197 29 33.70000 -4.70000000 198 37 36.30000 0.70000000 199 32 34.76190 -2.76190476 200 35 34.41667 0.58333333 201 30 31.67742 -1.67741935 202 40 34.76190 5.23809524 203 36 33.70000 2.30000000 204 38 36.30000 1.70000000 205 41 38.70000 2.30000000 206 45 39.18182 5.81818182 207 40 43.42857 -3.42857143 208 35 32.25000 2.75000000 209 30 31.67742 -1.67741935 210 29 34.93333 -5.93333333 211 36 39.18182 -3.18181818 212 33 34.76190 -1.76190476 213 32 30.80000 1.20000000 214 29 30.76923 -1.76923077 215 40 39.18182 0.81818182 216 35 34.93333 0.06666667 217 34 32.00000 2.00000000 218 36 38.70000 -2.70000000 219 40 38.70000 1.30000000 220 37 34.76190 2.23809524 221 42 39.18182 2.81818182 222 27 26.91667 0.08333333 223 34 30.76923 3.23076923 224 38 33.70000 4.30000000 225 31 31.67742 -0.67741935 226 33 32.40000 0.60000000 227 35 33.70000 1.30000000 228 30 26.91667 3.08333333 229 34 33.70000 0.30000000 230 37 34.41667 2.58333333 231 24 26.91667 -2.91666667 232 31 31.67742 -0.67741935 233 38 39.18182 -1.18181818 234 36 34.96296 1.03703704 235 35 36.30000 -1.30000000 236 35 36.30000 -1.30000000 237 33 33.70000 -0.70000000 238 38 39.18182 -1.18181818 239 32 36.30000 -4.30000000 240 31 32.40000 -1.40000000 241 44 43.42857 0.57142857 242 33 30.76923 2.23076923 243 42 38.70000 3.30000000 244 36 34.96296 1.03703704 245 33 34.41667 -1.41666667 246 34 32.40000 1.60000000 247 42 38.70000 3.30000000 248 26 26.91667 -0.91666667 249 36 34.41667 1.58333333 250 36 36.30000 -0.30000000 251 35 34.41667 0.58333333 252 31 34.41667 -3.41666667 253 33 34.41667 -1.41666667 254 28 31.67742 -3.67741935 255 38 38.70000 -0.70000000 256 37 34.76190 2.23809524 257 30 31.67742 -1.67741935 258 30 31.67742 -1.67741935 259 31 34.93333 -3.93333333 260 31 34.76190 -3.76190476 261 35 34.93333 0.06666667 262 20 26.91667 -6.91666667 263 37 38.70000 -1.70000000 264 30 33.70000 -3.70000000 265 33 32.40000 0.60000000 266 36 35.75000 0.25000000 267 32 34.76190 -2.76190476 268 30 28.25000 1.75000000 269 36 34.96296 1.03703704 270 35 34.96296 0.03703704 271 31 32.00000 -1.00000000 272 36 38.08333 -2.08333333 273 39 39.18182 -0.18181818 274 36 34.41667 1.58333333 275 36 34.41667 1.58333333 276 27 26.91667 0.08333333 277 34 32.00000 2.00000000 278 33 34.76190 -1.76190476 279 29 26.91667 2.08333333 280 31 31.67742 -0.67741935 281 41 43.42857 -2.42857143 282 34 30.80000 3.20000000 283 39 38.70000 0.30000000 284 36 34.76190 1.23809524 285 31 30.76923 0.23076923 286 45 43.42857 1.57142857 287 33 34.41667 -1.41666667 288 36 38.70000 -2.70000000 289 34 33.70000 0.30000000 290 36 38.08333 -2.08333333 291 32 32.40000 -0.40000000 292 36 34.76190 1.23809524 293 35 31.67742 3.32258065 294 27 32.25000 -5.25000000 295 35 34.41667 0.58333333 296 35 36.30000 -1.30000000 297 38 36.30000 1.70000000 298 29 32.00000 -3.00000000 299 31 34.76190 -3.76190476 300 38 39.18182 -1.18181818 301 36 34.41667 1.58333333 302 31 34.96296 -3.96296296 303 31 31.67742 -0.67741935 304 29 32.00000 -3.00000000 305 42 38.08333 3.91666667 306 30 31.67742 -1.67741935 307 33 34.76190 -1.76190476 308 36 38.08333 -2.08333333 309 31 30.80000 0.20000000 310 31 31.67742 -0.67741935 311 42 43.42857 -1.42857143 312 29 30.76923 -1.76923077 313 34 32.25000 1.75000000 314 31 31.67742 -0.67741935 315 35 36.30000 -1.30000000 316 36 36.30000 -0.30000000 317 31 34.41667 -3.41666667 318 37 34.41667 2.58333333 319 31 32.00000 -1.00000000 320 35 31.67742 3.32258065 321 43 43.42857 -0.42857143 322 29 34.41667 -5.41666667 323 42 43.42857 -1.42857143 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/www/rcomp/tmp/4c0au1335895850.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/www/rcomp/tmp/5qj1y1335895850.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/www/rcomp/tmp/6xww51335895850.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/www/rcomp/tmp/7tcol1335895850.tab") + } > > try(system("convert tmp/2oz5q1335895850.ps tmp/2oz5q1335895850.png",intern=TRUE)) character(0) > try(system("convert tmp/39dzr1335895850.ps tmp/39dzr1335895850.png",intern=TRUE)) character(0) > try(system("convert tmp/4c0au1335895850.ps tmp/4c0au1335895850.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.38 0.80 7.31