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 = 'Exam Items' > par8 = 'Learning Activities' > par7 = 'all' > par6 = 'prep' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'Exam Items' > par8 <- 'Learning Activities' > par7 <- 'all' > par6 <- 'prep' > par5 <- 'all' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '0' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., 2012, Recursive Partitioning (Regression Trees) in Information Management (v1.0.8) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_regression_trees.wasp/ > #Source of accompanying publication: > # > library(party) Loading required package: survival Loading required package: splines Loading required package: grid Loading required package: modeltools Loading required package: stats4 Loading required package: coin Loading required package: mvtnorm Loading required package: zoo Loading required package: sandwich Loading required package: strucchange Loading required package: vcd Loading required package: MASS Loading required package: colorspace > library(Hmisc) Attaching package: 'Hmisc' The following object(s) are masked from 'package:survival': untangle.specials The following object(s) are masked from 'package:base': format.pval, round.POSIXt, trunc.POSIXt, units > par1 <- as.numeric(par1) > par3 <- as.numeric(par3) > x <- as.data.frame(read.table(file='http://www.wessa.net/download/utaut.csv',sep=',',header=T)) > x$U25 <- 6-x$U25 > if(par5 == 'female') x <- x[x$Gender==0,] > if(par5 == 'male') x <- x[x$Gender==1,] > if(par6 == 'prep') x <- x[x$Pop==1,] > if(par6 == 'bachelor') x <- x[x$Pop==0,] > if(par7 != 'all') { + x <- x[x$Year==as.numeric(par7),] + } > cAc <- with(x,cbind( A1, A2, A3, A4, A5, A6, A7, A8, A9,A10)) > cAs <- with(x,cbind(A11,A12,A13,A14,A15,A16,A17,A18,A19,A20)) > cA <- cbind(cAc,cAs) > cCa <- with(x,cbind(C1,C3,C5,C7, C9,C11,C13,C15,C17,C19,C21,C23,C25,C27,C29,C31,C33,C35,C37,C39,C41,C43,C45,C47)) > cCp <- with(x,cbind(C2,C4,C6,C8,C10,C12,C14,C16,C18,C20,C22,C24,C26,C28,C30,C32,C34,C36,C38,C40,C42,C44,C46,C48)) > cC <- cbind(cCa,cCp) > cU <- with(x,cbind(U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33)) > cE <- with(x,cbind(BC,NNZFG,MRT,AFL,LPM,LPC,W,WPA)) > cX <- with(x,cbind(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14,X15,X16,X17,X18)) > if (par8=='ATTLES connected') x <- cAc > if (par8=='ATTLES separate') x <- cAs > if (par8=='ATTLES all') x <- cA > if (par8=='COLLES actuals') x <- cCa > if (par8=='COLLES preferred') x <- cCp > if (par8=='COLLES all') x <- cC > if (par8=='CSUQ') x <- cU > if (par8=='Learning Activities') x <- cE > if (par8=='Exam Items') x <- cX > if (par9=='ATTLES connected') y <- cAc > if (par9=='ATTLES separate') y <- cAs > if (par9=='ATTLES all') y <- cA > if (par9=='COLLES actuals') y <- cCa > if (par9=='COLLES preferred') y <- cCp > if (par9=='COLLES all') y <- cC > if (par9=='CSUQ') y <- cU > if (par9=='Learning Activities') y <- cE > if (par9=='Exam Items') y <- cX > if (par1==0) { + nr <- length(y[,1]) + nc <- length(y[1,]) + mysum <- array(0,dim=nr) + for(jjj in 1:nr) { + for(iii in 1:nc) { + mysum[jjj] = mysum[jjj] + y[jjj,iii] + } + } + y <- mysum + } else { + y <- y[,par1] + } > nx <- cbind(y,x) > colnames(nx) <- c('endo',colnames(x)) > x <- nx > par1=1 > ncol <- length(x[1,]) > for (jjj in 1:ncol) { + x <- x[!is.na(x[,jjj]),] + } > x <- as.data.frame(x) > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "endo" > x[,par1] [1] 12 8 1 2 5 12 11 9 2 4 5 4 5 4 -1 6 6 2 11 5 7 6 7 10 11 [26] 9 3 5 4 5 7 5 1 4 4 5 7 8 2 0 9 8 3 5 3 6 7 7 3 7 [51] 8 8 6 9 5 6 7 5 8 4 14 4 3 11 8 8 9 12 2 4 2 3 11 11 9 [76] 4 1 5 2 5 -1 7 4 3 7 7 5 8 7 5 10 7 5 9 4 2 5 12 4 6 [101] 5 7 8 11 3 1 13 7 2 5 3 -1 0 6 10 -2 8 11 11 9 10 2 8 12 10 [126] 2 0 9 -2 6 6 6 12 9 7 15 13 7 14 10 16 14 14 11 14 0 14 3 14 4 [151] 8 8 7 6 10 11 3 13 10 10 15 4 10 13 12 10 4 11 6 -4 0 6 7 11 13 [176] 6 10 5 0 0 7 8 6 11 0 8 0 0 8 17 9 -2 6 6 2 14 4 -1 2 10 [201] 9 -1 8 8 8 2 8 12 5 6 3 6 9 15 11 10 2 11 7 11 9 11 12 5 4 [226] -2 11 7 13 6 -3 9 9 8 11 3 5 13 3 12 9 15 14 8 7 9 13 8 11 8 [251] 9 10 11 -3 7 3 15 7 4 10 10 0 4 15 4 15 6 2 6 14 13 6 11 0 9 [276] 8 3 8 7 7 -2 0 > 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]) -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 2 5 5 13 4 16 16 21 23 24 27 27 20 17 23 10 9 10 7 1 1 > colnames(x) [1] "endo" "BC" "NNZFG" "MRT" "AFL" "LPM" "LPC" "W" "WPA" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 12 8 1 2 5 12 11 9 2 4 5 4 5 4 -1 6 6 2 11 5 7 6 7 10 11 [26] 9 3 5 4 5 7 5 1 4 4 5 7 8 2 0 9 8 3 5 3 6 7 7 3 7 [51] 8 8 6 9 5 6 7 5 8 4 14 4 3 11 8 8 9 12 2 4 2 3 11 11 9 [76] 4 1 5 2 5 -1 7 4 3 7 7 5 8 7 5 10 7 5 9 4 2 5 12 4 6 [101] 5 7 8 11 3 1 13 7 2 5 3 -1 0 6 10 -2 8 11 11 9 10 2 8 12 10 [126] 2 0 9 -2 6 6 6 12 9 7 15 13 7 14 10 16 14 14 11 14 0 14 3 14 4 [151] 8 8 7 6 10 11 3 13 10 10 15 4 10 13 12 10 4 11 6 -4 0 6 7 11 13 [176] 6 10 5 0 0 7 8 6 11 0 8 0 0 8 17 9 -2 6 6 2 14 4 -1 2 10 [201] 9 -1 8 8 8 2 8 12 5 6 3 6 9 15 11 10 2 11 7 11 9 11 12 5 4 [226] -2 11 7 13 6 -3 9 9 8 11 3 5 13 3 12 9 15 14 8 7 9 13 8 11 8 [251] 9 10 11 -3 7 3 15 7 4 10 10 0 4 15 4 15 6 2 6 14 13 6 11 0 9 [276] 8 3 8 7 7 -2 0 > 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/11zs51335901204.tab") + } + } > m Conditional inference tree with 4 terminal nodes Response: endo Inputs: BC, NNZFG, MRT, AFL, LPM, LPC, W, WPA Number of observations: 282 1) W <= 6229; criterion = 1, statistic = 23.025 2) WPA <= 3733; criterion = 1, statistic = 17.39 3) NNZFG <= 48; criterion = 0.983, statistic = 9.437 4)* weights = 15 3) NNZFG > 48 5)* weights = 87 2) WPA > 3733 6)* weights = 113 1) W > 6229 7)* weights = 67 > postscript(file="/var/www/rcomp/tmp/2gqr91335901204.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/386rv1335901204.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 12 7.283186 4.7168142 2 8 5.333333 2.6666667 3 1 7.283186 -6.2831858 4 2 5.333333 -3.3333333 5 5 7.283186 -2.2831858 6 12 5.333333 6.6666667 7 11 7.283186 3.7168142 8 9 5.333333 3.6666667 9 2 7.283186 -5.2831858 10 4 5.333333 -1.3333333 11 5 7.283186 -2.2831858 12 4 5.333333 -1.3333333 13 5 5.333333 -0.3333333 14 4 7.283186 -3.2831858 15 -1 7.283186 -8.2831858 16 6 5.333333 0.6666667 17 6 5.333333 0.6666667 18 2 5.333333 -3.3333333 19 11 5.333333 5.6666667 20 5 9.208955 -4.2089552 21 7 5.333333 1.6666667 22 6 9.208955 -3.2089552 23 7 9.208955 -2.2089552 24 10 5.333333 4.6666667 25 11 7.283186 3.7168142 26 9 7.283186 1.7168142 27 3 7.283186 -4.2831858 28 5 7.283186 -2.2831858 29 4 7.283186 -3.2831858 30 5 7.283186 -2.2831858 31 7 7.283186 -0.2831858 32 5 7.283186 -2.2831858 33 1 7.283186 -6.2831858 34 4 1.400000 2.6000000 35 4 5.333333 -1.3333333 36 5 7.283186 -2.2831858 37 7 7.283186 -0.2831858 38 8 7.283186 0.7168142 39 2 7.283186 -5.2831858 40 0 7.283186 -7.2831858 41 9 9.208955 -0.2089552 42 8 7.283186 0.7168142 43 3 5.333333 -2.3333333 44 5 5.333333 -0.3333333 45 3 7.283186 -4.2831858 46 6 5.333333 0.6666667 47 7 5.333333 1.6666667 48 7 7.283186 -0.2831858 49 3 7.283186 -4.2831858 50 7 7.283186 -0.2831858 51 8 5.333333 2.6666667 52 8 7.283186 0.7168142 53 6 7.283186 -1.2831858 54 9 7.283186 1.7168142 55 5 7.283186 -2.2831858 56 6 7.283186 -1.2831858 57 7 5.333333 1.6666667 58 5 7.283186 -2.2831858 59 8 7.283186 0.7168142 60 4 5.333333 -1.3333333 61 14 9.208955 4.7910448 62 4 5.333333 -1.3333333 63 3 5.333333 -2.3333333 64 11 7.283186 3.7168142 65 8 7.283186 0.7168142 66 8 5.333333 2.6666667 67 9 5.333333 3.6666667 68 12 7.283186 4.7168142 69 2 7.283186 -5.2831858 70 4 7.283186 -3.2831858 71 2 5.333333 -3.3333333 72 3 5.333333 -2.3333333 73 11 5.333333 5.6666667 74 11 7.283186 3.7168142 75 9 7.283186 1.7168142 76 4 5.333333 -1.3333333 77 1 5.333333 -4.3333333 78 5 5.333333 -0.3333333 79 2 5.333333 -3.3333333 80 5 7.283186 -2.2831858 81 -1 7.283186 -8.2831858 82 7 5.333333 1.6666667 83 4 5.333333 -1.3333333 84 3 5.333333 -2.3333333 85 7 7.283186 -0.2831858 86 7 5.333333 1.6666667 87 5 7.283186 -2.2831858 88 8 7.283186 0.7168142 89 7 5.333333 1.6666667 90 5 1.400000 3.6000000 91 10 7.283186 2.7168142 92 7 7.283186 -0.2831858 93 5 5.333333 -0.3333333 94 9 7.283186 1.7168142 95 4 5.333333 -1.3333333 96 2 5.333333 -3.3333333 97 5 7.283186 -2.2831858 98 12 7.283186 4.7168142 99 4 7.283186 -3.2831858 100 6 7.283186 -1.2831858 101 5 7.283186 -2.2831858 102 7 5.333333 1.6666667 103 8 1.400000 6.6000000 104 11 9.208955 1.7910448 105 3 5.333333 -2.3333333 106 1 7.283186 -6.2831858 107 13 7.283186 5.7168142 108 7 5.333333 1.6666667 109 2 5.333333 -3.3333333 110 5 5.333333 -0.3333333 111 3 5.333333 -2.3333333 112 -1 5.333333 -6.3333333 113 0 5.333333 -5.3333333 114 6 5.333333 0.6666667 115 10 5.333333 4.6666667 116 -2 5.333333 -7.3333333 117 8 7.283186 0.7168142 118 11 7.283186 3.7168142 119 11 5.333333 5.6666667 120 9 5.333333 3.6666667 121 10 7.283186 2.7168142 122 2 1.400000 0.6000000 123 8 7.283186 0.7168142 124 12 7.283186 4.7168142 125 10 9.208955 0.7910448 126 2 5.333333 -3.3333333 127 0 7.283186 -7.2831858 128 9 5.333333 3.6666667 129 -2 5.333333 -7.3333333 130 6 7.283186 -1.2831858 131 6 5.333333 0.6666667 132 6 9.208955 -3.2089552 133 12 7.283186 4.7168142 134 9 9.208955 -0.2089552 135 7 7.283186 -0.2831858 136 15 9.208955 5.7910448 137 13 5.333333 7.6666667 138 7 9.208955 -2.2089552 139 14 9.208955 4.7910448 140 10 7.283186 2.7168142 141 16 7.283186 8.7168142 142 14 7.283186 6.7168142 143 14 9.208955 4.7910448 144 11 5.333333 5.6666667 145 14 9.208955 4.7910448 146 0 9.208955 -9.2089552 147 14 9.208955 4.7910448 148 3 7.283186 -4.2831858 149 14 9.208955 4.7910448 150 4 7.283186 -3.2831858 151 8 5.333333 2.6666667 152 8 9.208955 -1.2089552 153 7 7.283186 -0.2831858 154 6 7.283186 -1.2831858 155 10 7.283186 2.7168142 156 11 9.208955 1.7910448 157 3 5.333333 -2.3333333 158 13 9.208955 3.7910448 159 10 9.208955 0.7910448 160 10 7.283186 2.7168142 161 15 9.208955 5.7910448 162 4 9.208955 -5.2089552 163 10 5.333333 4.6666667 164 13 7.283186 5.7168142 165 12 9.208955 2.7910448 166 10 9.208955 0.7910448 167 4 9.208955 -5.2089552 168 11 9.208955 1.7910448 169 6 7.283186 -1.2831858 170 -4 1.400000 -5.4000000 171 0 5.333333 -5.3333333 172 6 7.283186 -1.2831858 173 7 5.333333 1.6666667 174 11 7.283186 3.7168142 175 13 9.208955 3.7910448 176 6 5.333333 0.6666667 177 10 9.208955 0.7910448 178 5 5.333333 -0.3333333 179 0 7.283186 -7.2831858 180 0 1.400000 -1.4000000 181 7 9.208955 -2.2089552 182 8 7.283186 0.7168142 183 6 9.208955 -3.2089552 184 11 5.333333 5.6666667 185 0 1.400000 -1.4000000 186 8 5.333333 2.6666667 187 0 5.333333 -5.3333333 188 0 1.400000 -1.4000000 189 8 9.208955 -1.2089552 190 17 7.283186 9.7168142 191 9 9.208955 -0.2089552 192 -2 1.400000 -3.4000000 193 6 9.208955 -3.2089552 194 6 9.208955 -3.2089552 195 2 9.208955 -7.2089552 196 14 9.208955 4.7910448 197 4 7.283186 -3.2831858 198 -1 5.333333 -6.3333333 199 2 7.283186 -5.2831858 200 10 9.208955 0.7910448 201 9 7.283186 1.7168142 202 -1 5.333333 -6.3333333 203 8 9.208955 -1.2089552 204 8 7.283186 0.7168142 205 8 5.333333 2.6666667 206 2 5.333333 -3.3333333 207 8 7.283186 0.7168142 208 12 9.208955 2.7910448 209 5 9.208955 -4.2089552 210 6 9.208955 -3.2089552 211 3 1.400000 1.6000000 212 6 7.283186 -1.2831858 213 9 9.208955 -0.2089552 214 15 7.283186 7.7168142 215 11 5.333333 5.6666667 216 10 7.283186 2.7168142 217 2 7.283186 -5.2831858 218 11 9.208955 1.7910448 219 7 5.333333 1.6666667 220 11 7.283186 3.7168142 221 9 9.208955 -0.2089552 222 11 7.283186 3.7168142 223 12 9.208955 2.7910448 224 5 5.333333 -0.3333333 225 4 5.333333 -1.3333333 226 -2 1.400000 -3.4000000 227 11 9.208955 1.7910448 228 7 7.283186 -0.2831858 229 13 9.208955 3.7910448 230 6 9.208955 -3.2089552 231 -3 7.283186 -10.2831858 232 9 5.333333 3.6666667 233 9 7.283186 1.7168142 234 8 7.283186 0.7168142 235 11 9.208955 1.7910448 236 3 9.208955 -6.2089552 237 5 5.333333 -0.3333333 238 13 7.283186 5.7168142 239 3 9.208955 -6.2089552 240 12 7.283186 4.7168142 241 9 9.208955 -0.2089552 242 15 7.283186 7.7168142 243 14 9.208955 4.7910448 244 8 9.208955 -1.2089552 245 7 9.208955 -2.2089552 246 9 7.283186 1.7168142 247 13 9.208955 3.7910448 248 8 9.208955 -1.2089552 249 11 7.283186 3.7168142 250 8 5.333333 2.6666667 251 9 7.283186 1.7168142 252 10 7.283186 2.7168142 253 11 7.283186 3.7168142 254 -3 5.333333 -8.3333333 255 7 9.208955 -2.2089552 256 3 7.283186 -4.2831858 257 15 9.208955 5.7910448 258 7 5.333333 1.6666667 259 4 7.283186 -3.2831858 260 10 7.283186 2.7168142 261 10 5.333333 4.6666667 262 0 1.400000 -1.4000000 263 4 7.283186 -3.2831858 264 15 9.208955 5.7910448 265 4 9.208955 -5.2089552 266 15 7.283186 7.7168142 267 6 7.283186 -1.2831858 268 2 9.208955 -7.2089552 269 6 9.208955 -3.2089552 270 14 9.208955 4.7910448 271 13 7.283186 5.7168142 272 6 5.333333 0.6666667 273 11 9.208955 1.7910448 274 0 1.400000 -1.4000000 275 9 7.283186 1.7168142 276 8 7.283186 0.7168142 277 3 5.333333 -2.3333333 278 8 5.333333 2.6666667 279 7 1.400000 5.6000000 280 7 9.208955 -2.2089552 281 -2 5.333333 -7.3333333 282 0 1.400000 -1.4000000 > 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/44jwy1335901204.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/5u4sf1335901204.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/66m1x1335901204.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/7a5he1335901204.tab") + } > > try(system("convert tmp/2gqr91335901204.ps tmp/2gqr91335901204.png",intern=TRUE)) character(0) > try(system("convert tmp/386rv1335901204.ps tmp/386rv1335901204.png",intern=TRUE)) character(0) > try(system("convert tmp/44jwy1335901204.ps tmp/44jwy1335901204.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.340 0.650 6.098