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 = 'Learning Activities' > par8 = 'CSUQ' > par7 = 'all' > par6 = 'all' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '6' > par9 <- 'Learning Activities' > par8 <- 'CSUQ' > par7 <- 'all' > par6 <- 'all' > par5 <- 'all' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '6' > #'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] 110.48 158.49 109.88 102.41 93.41 114.02 75.65 89.74 145.13 71.70 [11] 327.35 89.17 134.18 78.59 94.08 137.70 79.74 59.67 79.16 265.19 [21] 364.40 237.94 78.54 106.48 115.14 60.19 123.55 134.63 148.46 130.49 [31] 155.99 90.98 121.02 88.93 99.00 85.09 124.76 168.70 122.32 141.25 [41] 118.02 33.78 160.05 122.54 128.91 88.75 527.46 81.58 81.94 93.68 [51] 155.44 120.67 173.94 82.68 125.18 67.33 93.45 137.94 152.61 200.14 [61] 181.91 91.33 290.53 188.59 152.24 226.37 262.36 103.55 109.82 127.45 [71] 261.97 111.55 118.22 131.28 91.71 66.04 97.72 159.32 162.68 166.66 [81] 73.35 114.52 134.39 142.14 125.13 86.02 155.49 98.87 149.69 274.96 [91] 106.46 208.69 109.73 193.12 330.79 116.88 203.46 146.74 173.41 114.99 [101] 89.82 200.71 99.65 222.23 138.86 186.38 107.98 122.22 123.28 119.98 [111] 83.26 74.99 121.85 144.26 170.41 90.02 210.03 89.79 121.66 186.20 [121] 82.12 87.38 29.70 156.94 129.49 112.13 104.36 119.78 46.28 91.28 [131] 88.38 176.18 91.90 89.74 54.92 107.57 132.72 137.17 82.34 104.54 [141] 121.39 143.58 66.78 105.74 97.87 99.20 71.29 81.78 53.74 100.16 [151] 61.36 199.35 102.23 65.76 110.58 140.78 94.73 278.35 60.10 56.39 [161] 89.01 222.44 46.75 85.50 102.06 121.68 68.65 74.86 120.14 143.62 [171] 94.85 59.21 205.54 109.83 92.75 120.54 103.67 127.91 59.08 89.23 [181] 219.74 66.43 66.00 75.02 138.38 81.17 121.67 67.25 75.90 71.61 [191] 111.50 48.37 77.39 85.89 103.26 69.33 97.54 56.29 70.78 60.91 [201] 160.28 141.02 80.64 148.89 159.80 118.63 78.20 78.62 85.20 149.34 [211] 119.14 77.40 97.36 68.44 96.66 142.06 87.61 62.45 89.88 69.90 > 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]) 29.7 33.78 46.28 46.75 48.37 53.74 54.92 56.29 56.39 59.08 59.21 1 1 1 1 1 1 1 1 1 1 1 59.67 60.1 60.19 60.91 61.36 62.45 65.76 66 66.04 66.43 66.78 1 1 1 1 1 1 1 1 1 1 1 67.25 67.33 68.44 68.65 69.33 69.9 70.78 71.29 71.61 71.7 73.35 1 1 1 1 1 1 1 1 1 1 1 74.86 74.99 75.02 75.65 75.9 77.39 77.4 78.2 78.54 78.59 78.62 1 1 1 1 1 1 1 1 1 1 1 79.16 79.74 80.64 81.17 81.58 81.78 81.94 82.12 82.34 82.68 83.26 1 1 1 1 1 1 1 1 1 1 1 85.09 85.2 85.5 85.89 86.02 87.38 87.61 88.38 88.75 88.93 89.01 1 1 1 1 1 1 1 1 1 1 1 89.17 89.23 89.74 89.79 89.82 89.88 90.02 90.98 91.28 91.33 91.71 1 1 2 1 1 1 1 1 1 1 1 91.9 92.75 93.41 93.45 93.68 94.08 94.73 94.85 96.66 97.36 97.54 1 1 1 1 1 1 1 1 1 1 1 97.72 97.87 98.87 99 99.2 99.65 100.16 102.06 102.23 102.41 103.26 1 1 1 1 1 1 1 1 1 1 1 103.55 103.67 104.36 104.54 105.74 106.46 106.48 107.57 107.98 109.73 109.82 1 1 1 1 1 1 1 1 1 1 1 109.83 109.88 110.48 110.58 111.5 111.55 112.13 114.02 114.52 114.99 115.14 1 1 1 1 1 1 1 1 1 1 1 116.88 118.02 118.22 118.63 119.14 119.78 119.98 120.14 120.54 120.67 121.02 1 1 1 1 1 1 1 1 1 1 1 121.39 121.66 121.67 121.68 121.85 122.22 122.32 122.54 123.28 123.55 124.76 1 1 1 1 1 1 1 1 1 1 1 125.13 125.18 127.45 127.91 128.91 129.49 130.49 131.28 132.72 134.18 134.39 1 1 1 1 1 1 1 1 1 1 1 134.63 137.17 137.7 137.94 138.38 138.86 140.78 141.02 141.25 142.06 142.14 1 1 1 1 1 1 1 1 1 1 1 143.58 143.62 144.26 145.13 146.74 148.46 148.89 149.34 149.69 152.24 152.61 1 1 1 1 1 1 1 1 1 1 1 155.44 155.49 155.99 156.94 158.49 159.32 159.8 160.05 160.28 162.68 166.66 1 1 1 1 1 1 1 1 1 1 1 168.7 170.41 173.41 173.94 176.18 181.91 186.2 186.38 188.59 193.12 199.35 1 1 1 1 1 1 1 1 1 1 1 200.14 200.71 203.46 205.54 208.69 210.03 219.74 222.23 222.44 226.37 237.94 1 1 1 1 1 1 1 1 1 1 1 261.97 262.36 265.19 274.96 278.35 290.53 327.35 330.79 364.4 527.46 1 1 1 1 1 1 1 1 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] 110.48 158.49 109.88 102.41 93.41 114.02 75.65 89.74 145.13 71.70 [11] 327.35 89.17 134.18 78.59 94.08 137.70 79.74 59.67 79.16 265.19 [21] 364.40 237.94 78.54 106.48 115.14 60.19 123.55 134.63 148.46 130.49 [31] 155.99 90.98 121.02 88.93 99.00 85.09 124.76 168.70 122.32 141.25 [41] 118.02 33.78 160.05 122.54 128.91 88.75 527.46 81.58 81.94 93.68 [51] 155.44 120.67 173.94 82.68 125.18 67.33 93.45 137.94 152.61 200.14 [61] 181.91 91.33 290.53 188.59 152.24 226.37 262.36 103.55 109.82 127.45 [71] 261.97 111.55 118.22 131.28 91.71 66.04 97.72 159.32 162.68 166.66 [81] 73.35 114.52 134.39 142.14 125.13 86.02 155.49 98.87 149.69 274.96 [91] 106.46 208.69 109.73 193.12 330.79 116.88 203.46 146.74 173.41 114.99 [101] 89.82 200.71 99.65 222.23 138.86 186.38 107.98 122.22 123.28 119.98 [111] 83.26 74.99 121.85 144.26 170.41 90.02 210.03 89.79 121.66 186.20 [121] 82.12 87.38 29.70 156.94 129.49 112.13 104.36 119.78 46.28 91.28 [131] 88.38 176.18 91.90 89.74 54.92 107.57 132.72 137.17 82.34 104.54 [141] 121.39 143.58 66.78 105.74 97.87 99.20 71.29 81.78 53.74 100.16 [151] 61.36 199.35 102.23 65.76 110.58 140.78 94.73 278.35 60.10 56.39 [161] 89.01 222.44 46.75 85.50 102.06 121.68 68.65 74.86 120.14 143.62 [171] 94.85 59.21 205.54 109.83 92.75 120.54 103.67 127.91 59.08 89.23 [181] 219.74 66.43 66.00 75.02 138.38 81.17 121.67 67.25 75.90 71.61 [191] 111.50 48.37 77.39 85.89 103.26 69.33 97.54 56.29 70.78 60.91 [201] 160.28 141.02 80.64 148.89 159.80 118.63 78.20 78.62 85.20 149.34 [211] 119.14 77.40 97.36 68.44 96.66 142.06 87.61 62.45 89.88 69.90 > 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/1q75a1335898790.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: 220 1) U15 <= 3; criterion = 0.972, statistic = 11.114 2)* weights = 96 1) U15 > 3 3)* weights = 124 > postscript(file="/var/www/rcomp/tmp/2zvos1335898790.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/3eoaa1335898790.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 110.48 135.4512 -24.9712097 2 158.49 135.4512 23.0387903 3 109.88 135.4512 -25.5712097 4 102.41 135.4512 -33.0412097 5 93.41 135.4512 -42.0412097 6 114.02 104.9667 9.0533333 7 75.65 104.9667 -29.3166667 8 89.74 104.9667 -15.2266667 9 145.13 135.4512 9.6787903 10 71.70 104.9667 -33.2666667 11 327.35 135.4512 191.8987903 12 89.17 104.9667 -15.7966667 13 134.18 135.4512 -1.2712097 14 78.59 104.9667 -26.3766667 15 94.08 104.9667 -10.8866667 16 137.70 104.9667 32.7333333 17 79.74 135.4512 -55.7112097 18 59.67 135.4512 -75.7812097 19 79.16 104.9667 -25.8066667 20 265.19 135.4512 129.7387903 21 364.40 135.4512 228.9487903 22 237.94 104.9667 132.9733333 23 78.54 135.4512 -56.9112097 24 106.48 104.9667 1.5133333 25 115.14 135.4512 -20.3112097 26 60.19 135.4512 -75.2612097 27 123.55 135.4512 -11.9012097 28 134.63 104.9667 29.6633333 29 148.46 135.4512 13.0087903 30 130.49 135.4512 -4.9612097 31 155.99 135.4512 20.5387903 32 90.98 104.9667 -13.9866667 33 121.02 104.9667 16.0533333 34 88.93 104.9667 -16.0366667 35 99.00 104.9667 -5.9666667 36 85.09 135.4512 -50.3612097 37 124.76 104.9667 19.7933333 38 168.70 104.9667 63.7333333 39 122.32 135.4512 -13.1312097 40 141.25 135.4512 5.7987903 41 118.02 135.4512 -17.4312097 42 33.78 104.9667 -71.1866667 43 160.05 135.4512 24.5987903 44 122.54 135.4512 -12.9112097 45 128.91 135.4512 -6.5412097 46 88.75 135.4512 -46.7012097 47 527.46 135.4512 392.0087903 48 81.58 135.4512 -53.8712097 49 81.94 104.9667 -23.0266667 50 93.68 135.4512 -41.7712097 51 155.44 135.4512 19.9887903 52 120.67 135.4512 -14.7812097 53 173.94 104.9667 68.9733333 54 82.68 104.9667 -22.2866667 55 125.18 104.9667 20.2133333 56 67.33 104.9667 -37.6366667 57 93.45 135.4512 -42.0012097 58 137.94 104.9667 32.9733333 59 152.61 104.9667 47.6433333 60 200.14 104.9667 95.1733333 61 181.91 135.4512 46.4587903 62 91.33 135.4512 -44.1212097 63 290.53 135.4512 155.0787903 64 188.59 135.4512 53.1387903 65 152.24 104.9667 47.2733333 66 226.37 135.4512 90.9187903 67 262.36 135.4512 126.9087903 68 103.55 135.4512 -31.9012097 69 109.82 135.4512 -25.6312097 70 127.45 135.4512 -8.0012097 71 261.97 104.9667 157.0033333 72 111.55 135.4512 -23.9012097 73 118.22 135.4512 -17.2312097 74 131.28 104.9667 26.3133333 75 91.71 135.4512 -43.7412097 76 66.04 135.4512 -69.4112097 77 97.72 135.4512 -37.7312097 78 159.32 135.4512 23.8687903 79 162.68 135.4512 27.2287903 80 166.66 104.9667 61.6933333 81 73.35 104.9667 -31.6166667 82 114.52 135.4512 -20.9312097 83 134.39 135.4512 -1.0612097 84 142.14 135.4512 6.6887903 85 125.13 135.4512 -10.3212097 86 86.02 104.9667 -18.9466667 87 155.49 135.4512 20.0387903 88 98.87 104.9667 -6.0966667 89 149.69 104.9667 44.7233333 90 274.96 135.4512 139.5087903 91 106.46 135.4512 -28.9912097 92 208.69 135.4512 73.2387903 93 109.73 135.4512 -25.7212097 94 193.12 135.4512 57.6687903 95 330.79 135.4512 195.3387903 96 116.88 104.9667 11.9133333 97 203.46 135.4512 68.0087903 98 146.74 135.4512 11.2887903 99 173.41 135.4512 37.9587903 100 114.99 104.9667 10.0233333 101 89.82 104.9667 -15.1466667 102 200.71 135.4512 65.2587903 103 99.65 135.4512 -35.8012097 104 222.23 135.4512 86.7787903 105 138.86 135.4512 3.4087903 106 186.38 135.4512 50.9287903 107 107.98 135.4512 -27.4712097 108 122.22 104.9667 17.2533333 109 123.28 104.9667 18.3133333 110 119.98 135.4512 -15.4712097 111 83.26 104.9667 -21.7066667 112 74.99 104.9667 -29.9766667 113 121.85 135.4512 -13.6012097 114 144.26 104.9667 39.2933333 115 170.41 135.4512 34.9587903 116 90.02 104.9667 -14.9466667 117 210.03 135.4512 74.5787903 118 89.79 135.4512 -45.6612097 119 121.66 104.9667 16.6933333 120 186.20 104.9667 81.2333333 121 82.12 135.4512 -53.3312097 122 87.38 135.4512 -48.0712097 123 29.70 104.9667 -75.2666667 124 156.94 104.9667 51.9733333 125 129.49 135.4512 -5.9612097 126 112.13 135.4512 -23.3212097 127 104.36 104.9667 -0.6066667 128 119.78 104.9667 14.8133333 129 46.28 135.4512 -89.1712097 130 91.28 104.9667 -13.6866667 131 88.38 104.9667 -16.5866667 132 176.18 135.4512 40.7287903 133 91.90 135.4512 -43.5512097 134 89.74 104.9667 -15.2266667 135 54.92 104.9667 -50.0466667 136 107.57 104.9667 2.6033333 137 132.72 135.4512 -2.7312097 138 137.17 135.4512 1.7187903 139 82.34 104.9667 -22.6266667 140 104.54 135.4512 -30.9112097 141 121.39 135.4512 -14.0612097 142 143.58 135.4512 8.1287903 143 66.78 135.4512 -68.6712097 144 105.74 135.4512 -29.7112097 145 97.87 135.4512 -37.5812097 146 99.20 104.9667 -5.7666667 147 71.29 104.9667 -33.6766667 148 81.78 135.4512 -53.6712097 149 53.74 104.9667 -51.2266667 150 100.16 104.9667 -4.8066667 151 61.36 104.9667 -43.6066667 152 199.35 104.9667 94.3833333 153 102.23 135.4512 -33.2212097 154 65.76 135.4512 -69.6912097 155 110.58 104.9667 5.6133333 156 140.78 135.4512 5.3287903 157 94.73 135.4512 -40.7212097 158 278.35 104.9667 173.3833333 159 60.10 104.9667 -44.8666667 160 56.39 104.9667 -48.5766667 161 89.01 135.4512 -46.4412097 162 222.44 135.4512 86.9887903 163 46.75 104.9667 -58.2166667 164 85.50 104.9667 -19.4666667 165 102.06 104.9667 -2.9066667 166 121.68 135.4512 -13.7712097 167 68.65 135.4512 -66.8012097 168 74.86 104.9667 -30.1066667 169 120.14 135.4512 -15.3112097 170 143.62 135.4512 8.1687903 171 94.85 135.4512 -40.6012097 172 59.21 135.4512 -76.2412097 173 205.54 135.4512 70.0887903 174 109.83 104.9667 4.8633333 175 92.75 104.9667 -12.2166667 176 120.54 135.4512 -14.9112097 177 103.67 135.4512 -31.7812097 178 127.91 104.9667 22.9433333 179 59.08 104.9667 -45.8866667 180 89.23 104.9667 -15.7366667 181 219.74 135.4512 84.2887903 182 66.43 104.9667 -38.5366667 183 66.00 104.9667 -38.9666667 184 75.02 104.9667 -29.9466667 185 138.38 135.4512 2.9287903 186 81.17 135.4512 -54.2812097 187 121.67 135.4512 -13.7812097 188 67.25 104.9667 -37.7166667 189 75.90 104.9667 -29.0666667 190 71.61 135.4512 -63.8412097 191 111.50 135.4512 -23.9512097 192 48.37 135.4512 -87.0812097 193 77.39 104.9667 -27.5766667 194 85.89 104.9667 -19.0766667 195 103.26 135.4512 -32.1912097 196 69.33 135.4512 -66.1212097 197 97.54 104.9667 -7.4266667 198 56.29 104.9667 -48.6766667 199 70.78 104.9667 -34.1866667 200 60.91 135.4512 -74.5412097 201 160.28 104.9667 55.3133333 202 141.02 135.4512 5.5687903 203 80.64 104.9667 -24.3266667 204 148.89 135.4512 13.4387903 205 159.80 104.9667 54.8333333 206 118.63 104.9667 13.6633333 207 78.20 104.9667 -26.7666667 208 78.62 104.9667 -26.3466667 209 85.20 135.4512 -50.2512097 210 149.34 135.4512 13.8887903 211 119.14 135.4512 -16.3112097 212 77.40 135.4512 -58.0512097 213 97.36 104.9667 -7.6066667 214 68.44 104.9667 -36.5266667 215 96.66 135.4512 -38.7912097 216 142.06 135.4512 6.6087903 217 87.61 104.9667 -17.3566667 218 62.45 135.4512 -73.0012097 219 89.88 104.9667 -15.0866667 220 69.90 104.9667 -35.0666667 > 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/4ylhv1335898790.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/5bbis1335898790.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/6dkwx1335898790.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/7eth21335898790.tab") + } > > try(system("convert tmp/2zvos1335898790.ps tmp/2zvos1335898790.png",intern=TRUE)) character(0) > try(system("convert tmp/3eoaa1335898790.ps tmp/3eoaa1335898790.png",intern=TRUE)) character(0) > try(system("convert tmp/4ylhv1335898790.ps tmp/4ylhv1335898790.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.540 0.690 5.389