R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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. > x <- array(list(1 + ,162556 + ,162556 + ,1081 + ,1081 + ,213118 + ,213118 + ,230380558 + ,6282929 + ,1 + ,29790 + ,29790 + ,309 + ,309 + ,81767 + ,81767 + ,25266003 + ,4324047 + ,1 + ,87550 + ,87550 + ,458 + ,458 + ,153198 + ,153198 + ,70164684 + ,4108272 + ,0 + ,84738 + ,0 + ,588 + ,0 + ,-26007 + ,0 + ,-15292116 + ,-1212617 + ,1 + ,54660 + ,54660 + ,299 + ,299 + ,126942 + ,126942 + ,37955658 + ,1485329 + ,1 + ,42634 + ,42634 + ,156 + ,156 + ,157214 + ,157214 + ,24525384 + ,1779876 + ,0 + ,40949 + ,0 + ,481 + ,0 + ,129352 + ,0 + ,62218312 + ,1367203 + ,1 + ,42312 + ,42312 + ,323 + ,323 + ,234817 + ,234817 + ,75845891 + ,2519076 + ,1 + ,37704 + ,37704 + ,452 + ,452 + ,60448 + ,60448 + ,27322496 + ,912684 + ,1 + ,16275 + ,16275 + ,109 + ,109 + ,47818 + ,47818 + ,5212162 + ,1443586 + ,0 + ,25830 + ,0 + ,115 + ,0 + ,245546 + ,0 + ,28237790 + ,1220017 + ,0 + ,12679 + ,0 + ,110 + ,0 + ,48020 + ,0 + ,5282200 + ,984885 + ,1 + ,18014 + ,18014 + ,239 + ,239 + ,-1710 + ,-1710 + ,-408690 + ,1457425 + ,0 + ,43556 + ,0 + ,247 + ,0 + ,32648 + ,0 + ,8064056 + ,-572920 + ,1 + ,24524 + ,24524 + ,497 + ,497 + ,95350 + ,95350 + ,47388950 + ,929144 + ,0 + ,6532 + ,0 + ,103 + ,0 + ,151352 + ,0 + ,15589256 + ,1151176 + ,0 + ,7123 + ,0 + ,109 + ,0 + ,288170 + ,0 + ,31410530 + ,790090 + ,1 + ,20813 + ,20813 + ,502 + ,502 + ,114337 + ,114337 + ,57397174 + ,774497 + ,1 + ,37597 + ,37597 + ,248 + ,248 + ,37884 + ,37884 + ,9395232 + ,990576 + ,0 + ,17821 + ,0 + ,373 + ,0 + ,122844 + ,0 + ,45820812 + ,454195 + ,1 + ,12988 + ,12988 + ,119 + ,119 + ,82340 + ,82340 + ,9798460 + ,876607 + ,1 + ,22330 + ,22330 + ,84 + ,84 + ,79801 + ,79801 + ,6703284 + ,711969 + ,0 + ,13326 + ,0 + ,102 + ,0 + ,165548 + ,0 + ,16885896 + ,702380 + ,0 + ,16189 + ,0 + ,295 + ,0 + ,116384 + ,0 + ,34333280 + ,264449 + ,0 + ,7146 + ,0 + ,105 + ,0 + ,134028 + ,0 + ,14072940 + ,450033 + ,0 + ,15824 + ,0 + ,64 + ,0 + ,63838 + ,0 + ,4085632 + ,541063 + ,1 + ,26088 + ,26088 + ,267 + ,267 + ,74996 + ,74996 + ,20023932 + ,588864 + ,0 + ,11326 + ,0 + ,129 + ,0 + ,31080 + ,0 + ,4009320 + ,-37216 + ,0 + ,8568 + ,0 + ,37 + ,0 + ,32168 + ,0 + ,1190216 + ,783310 + ,0 + ,14416 + ,0 + ,361 + ,0 + ,49857 + ,0 + ,17998377 + ,467359 + ,1 + ,3369 + ,3369 + ,28 + ,28 + ,87161 + ,87161 + ,2440508 + ,688779 + ,1 + ,11819 + ,11819 + ,85 + ,85 + ,106113 + ,106113 + ,9019605 + ,608419 + ,1 + ,6620 + ,6620 + ,44 + ,44 + ,80570 + ,80570 + ,3545080 + ,696348 + ,1 + ,4519 + ,4519 + ,49 + ,49 + ,102129 + ,102129 + ,5004321 + ,597793 + ,0 + ,2220 + ,0 + ,22 + ,0 + ,301670 + ,0 + ,6636740 + ,821730 + ,0 + ,18562 + ,0 + ,155 + ,0 + ,102313 + ,0 + ,15858515 + ,377934 + ,0 + ,10327 + ,0 + ,91 + ,0 + ,88577 + ,0 + ,8060507 + ,651939 + ,1 + ,5336 + ,5336 + ,81 + ,81 + ,112477 + ,112477 + ,9110637 + ,697458 + ,1 + ,2365 + ,2365 + ,79 + ,79 + ,191778 + ,191778 + ,15150462 + ,700368 + ,0 + ,4069 + ,0 + ,145 + ,0 + ,79804 + ,0 + ,11571580 + ,225986 + ,0 + ,7710 + ,0 + ,816 + ,0 + ,128294 + ,0 + ,104687904 + ,348695 + ,0 + ,13718 + ,0 + ,61 + ,0 + ,96448 + ,0 + ,5883328 + ,373683 + ,0 + ,4525 + ,0 + ,226 + ,0 + ,93811 + ,0 + ,21201286 + ,501709 + ,0 + ,6869 + ,0 + ,105 + ,0 + ,117520 + ,0 + ,12339600 + ,413743 + ,0 + ,4628 + ,0 + ,62 + ,0 + ,69159 + ,0 + ,4287858 + ,379825 + ,1 + ,3653 + ,3653 + ,24 + ,24 + ,101792 + ,101792 + ,2443008 + ,336260 + ,1 + ,1265 + ,1265 + ,26 + ,26 + ,210568 + ,210568 + ,5474768 + ,636765 + ,1 + ,7489 + ,7489 + ,322 + ,322 + ,136996 + ,136996 + ,44112712 + ,481231 + ,0 + ,4901 + ,0 + ,84 + ,0 + ,121920 + ,0 + ,10241280 + ,469107 + ,0 + ,2284 + ,0 + ,33 + ,0 + ,76403 + ,0 + ,2521299 + ,211928 + ,1 + ,3160 + ,3160 + ,108 + ,108 + ,108094 + ,108094 + ,11674152 + ,563925 + ,1 + ,4150 + ,4150 + ,150 + ,150 + ,134759 + ,134759 + ,20213850 + ,511939 + ,1 + ,7285 + ,7285 + ,115 + ,115 + ,188873 + ,188873 + ,21720395 + ,521016 + ,1 + ,1134 + ,1134 + ,162 + ,162 + ,146216 + ,146216 + ,23686992 + ,543856 + ,1 + ,4658 + ,4658 + ,158 + ,158 + ,156608 + ,156608 + ,24744064 + ,329304 + ,0 + ,2384 + ,0 + ,97 + ,0 + ,61348 + ,0 + ,5950756 + ,423262 + ,0 + ,3748 + ,0 + ,9 + ,0 + ,50350 + ,0 + ,453150 + ,509665 + ,0 + ,5371 + ,0 + ,66 + ,0 + ,87720 + ,0 + ,5789520 + ,455881 + ,0 + ,1285 + ,0 + ,107 + ,0 + ,99489 + ,0 + ,10645323 + ,367772 + ,1 + ,9327 + ,9327 + ,101 + ,101 + ,87419 + ,87419 + ,8829319 + ,406339 + ,1 + ,5565 + ,5565 + ,47 + ,47 + ,94355 + ,94355 + ,4434685 + ,493408 + ,0 + ,1528 + ,0 + ,38 + ,0 + ,60326 + ,0 + ,2292388 + ,232942 + ,1 + ,3122 + ,3122 + ,34 + ,34 + ,94670 + ,94670 + ,3218780 + ,416002 + ,1 + ,7317 + ,7317 + ,84 + ,84 + ,82425 + ,82425 + ,6923700 + ,337430 + ,0 + ,2675 + ,0 + ,79 + ,0 + ,59017 + ,0 + ,4662343 + ,361517 + ,0 + ,13253 + ,0 + ,947 + ,0 + ,90829 + ,0 + ,86015063 + ,360962 + ,0 + ,880 + ,0 + ,74 + ,0 + ,80791 + ,0 + ,5978534 + ,235561 + ,1 + ,2053 + ,2053 + ,53 + ,53 + ,100423 + ,100423 + ,5322419 + ,408247 + ,0 + ,1424 + ,0 + ,94 + ,0 + ,131116 + ,0 + ,12324904 + ,450296 + ,1 + ,4036 + ,4036 + ,63 + ,63 + ,100269 + ,100269 + ,6316947 + ,418799 + ,1 + ,3045 + ,3045 + ,58 + ,58 + ,27330 + ,27330 + ,1585140 + ,247405 + ,0 + ,5119 + ,0 + ,49 + ,0 + ,39039 + ,0 + ,1912911 + ,378519 + ,0 + ,1431 + ,0 + ,34 + ,0 + ,106885 + ,0 + ,3634090 + ,326638 + ,0 + ,554 + ,0 + ,11 + ,0 + ,79285 + ,0 + ,872135 + ,328233 + ,0 + ,1975 + ,0 + ,35 + ,0 + ,118881 + ,0 + ,4160835 + ,386225 + ,1 + ,1286 + ,1286 + ,17 + ,17 + ,77623 + ,77623 + ,1319591 + ,283662 + ,0 + ,1012 + ,0 + ,47 + ,0 + ,114768 + ,0 + ,5394096 + ,370225 + ,0 + ,810 + ,0 + ,43 + ,0 + ,74015 + ,0 + ,3182645 + ,269236 + ,0 + ,1280 + ,0 + ,117 + ,0 + ,69465 + ,0 + ,8127405 + ,365732 + ,1 + ,666 + ,666 + ,171 + ,171 + ,117869 + ,117869 + ,20155599 + ,420383 + ,0 + ,1380 + ,0 + ,26 + ,0 + ,60982 + ,0 + ,1585532 + ,345811 + ,1 + ,4608 + ,4608 + ,73 + ,73 + ,90131 + ,90131 + ,6579563 + ,431809 + ,0 + ,876 + ,0 + ,59 + ,0 + ,138971 + ,0 + ,8199289 + ,418876 + ,0 + ,814 + ,0 + ,18 + ,0 + ,39625 + ,0 + ,713250 + ,297476 + ,0 + ,514 + ,0 + ,15 + ,0 + ,102725 + ,0 + ,1540875 + ,416776 + ,1 + ,5692 + ,5692 + ,72 + ,72 + ,64239 + ,64239 + ,4625208 + ,357257 + ,0 + ,3642 + ,0 + ,86 + ,0 + ,90262 + ,0 + ,7762532 + ,458343 + ,0 + ,540 + ,0 + ,14 + ,0 + ,103960 + ,0 + ,1455440 + ,388386 + ,0 + ,2099 + ,0 + ,64 + ,0 + ,106611 + ,0 + ,6823104 + ,358934 + ,0 + ,567 + ,0 + ,11 + ,0 + ,103345 + ,0 + ,1136795 + ,407560 + ,0 + ,2001 + ,0 + ,52 + ,0 + ,95551 + ,0 + ,4968652 + ,392558 + ,1 + ,2949 + ,2949 + ,41 + ,41 + ,82903 + ,82903 + ,3399023 + ,373177 + ,0 + ,2253 + ,0 + ,99 + ,0 + ,63593 + ,0 + ,6295707 + ,428370 + ,1 + ,6533 + ,6533 + ,75 + ,75 + ,126910 + ,126910 + ,9518250 + ,369419 + ,0 + ,1889 + ,0 + ,45 + ,0 + ,37527 + ,0 + ,1688715 + ,358649 + ,1 + ,3055 + ,3055 + ,43 + ,43 + ,60247 + ,60247 + ,2590621 + ,376641 + ,0 + ,272 + ,0 + ,8 + ,0 + ,112995 + ,0 + ,903960 + ,467427 + ,1 + ,1414 + ,1414 + ,198 + ,198 + ,70184 + ,70184 + ,13896432 + ,364885 + ,0 + ,2564 + ,0 + ,22 + ,0 + ,130140 + ,0 + ,2863080 + ,436230 + ,1 + ,1383 + ,1383 + ,11 + ,11 + ,73221 + ,73221 + ,805431 + ,329118) + ,dim=c(9 + ,100) + ,dimnames=list(c('Group' + ,'Costs' + ,'GrCosts' + ,'Trades' + ,'GrTrades' + ,'Dividends' + ,'GrDiv' + ,'TrDiv' + ,'Wealth ') + ,1:100)) > y <- array(NA,dim=c(9,100),dimnames=list(c('Group','Costs','GrCosts','Trades','GrTrades','Dividends','GrDiv','TrDiv','Wealth '),1:100)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'yes' > par3 = '2' > par2 = 'none' > par1 = '6' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. Ian E. Holliday > #To cite this work: Ian E. Holliday, 2009, YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: > #Technical description: > 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 Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric 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 <- data.frame(t(y)) > is.data.frame(x) [1] TRUE > x <- x[!is.na(x[,par1]),] > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "Dividends" > x[,par1] [1] 213118 81767 153198 -26007 126942 157214 129352 234817 60448 47818 [11] 245546 48020 -1710 32648 95350 151352 288170 114337 37884 122844 [21] 82340 79801 165548 116384 134028 63838 74996 31080 32168 49857 [31] 87161 106113 80570 102129 301670 102313 88577 112477 191778 79804 [41] 128294 96448 93811 117520 69159 101792 210568 136996 121920 76403 [51] 108094 134759 188873 146216 156608 61348 50350 87720 99489 87419 [61] 94355 60326 94670 82425 59017 90829 80791 100423 131116 100269 [71] 27330 39039 106885 79285 118881 77623 114768 74015 69465 117869 [81] 60982 90131 138971 39625 102725 64239 90262 103960 106611 103345 [91] 95551 82903 63593 126910 37527 60247 112995 70184 130140 73221 > 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]) -26007 -1710 27330 31080 32168 32648 37527 37884 39039 39625 47818 1 1 1 1 1 1 1 1 1 1 1 48020 49857 50350 59017 60247 60326 60448 60982 61348 63593 63838 1 1 1 1 1 1 1 1 1 1 1 64239 69159 69465 70184 73221 74015 74996 76403 77623 79285 79801 1 1 1 1 1 1 1 1 1 1 1 79804 80570 80791 81767 82340 82425 82903 87161 87419 87720 88577 1 1 1 1 1 1 1 1 1 1 1 90131 90262 90829 93811 94355 94670 95350 95551 96448 99489 100269 1 1 1 1 1 1 1 1 1 1 1 100423 101792 102129 102313 102725 103345 103960 106113 106611 106885 108094 1 1 1 1 1 1 1 1 1 1 1 112477 112995 114337 114768 116384 117520 117869 118881 121920 122844 126910 1 1 1 1 1 1 1 1 1 1 1 126942 128294 129352 130140 131116 134028 134759 136996 138971 146216 151352 1 1 1 1 1 1 1 1 1 1 1 153198 156608 157214 165548 188873 191778 210568 213118 234817 245546 288170 1 1 1 1 1 1 1 1 1 1 1 301670 1 > colnames(x) [1] "Group" "Costs" "GrCosts" "Trades" "GrTrades" "Dividends" [7] "GrDiv" "TrDiv" "Wealth." > colnames(x)[par1] [1] "Dividends" > x[,par1] [1] 213118 81767 153198 -26007 126942 157214 129352 234817 60448 47818 [11] 245546 48020 -1710 32648 95350 151352 288170 114337 37884 122844 [21] 82340 79801 165548 116384 134028 63838 74996 31080 32168 49857 [31] 87161 106113 80570 102129 301670 102313 88577 112477 191778 79804 [41] 128294 96448 93811 117520 69159 101792 210568 136996 121920 76403 [51] 108094 134759 188873 146216 156608 61348 50350 87720 99489 87419 [61] 94355 60326 94670 82425 59017 90829 80791 100423 131116 100269 [71] 27330 39039 106885 79285 118881 77623 114768 74015 69465 117869 [81] 60982 90131 138971 39625 102725 64239 90262 103960 106611 103345 [91] 95551 82903 63593 126910 37527 60247 112995 70184 130140 73221 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/1524c1293218677.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: Dividends Inputs: Group, Costs, GrCosts, Trades, GrTrades, GrDiv, TrDiv, Wealth. Number of observations: 100 1) TrDiv <= 13896432; criterion = 1, statistic = 17.254 2) Trades <= 108; criterion = 0.999, statistic = 13.951 3) Wealth. <= 379825; criterion = 0.982, statistic = 9.303 4) TrDiv <= 4662343; criterion = 0.988, statistic = 10.038 5)* weights = 18 4) TrDiv > 4662343 6)* weights = 7 3) Wealth. > 379825 7)* weights = 34 2) Trades > 108 8)* weights = 11 1) TrDiv > 13896432 9)* weights = 30 > postscript(file="/var/www/html/rcomp/tmp/2gb3x1293218677.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/html/rcomp/tmp/3gb3x1293218677.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 213118 140120.47 72997.533 2 81767 140120.47 -58353.467 3 153198 140120.47 13077.533 4 -26007 42866.00 -68873.000 5 126942 140120.47 -13178.467 6 157214 140120.47 17093.533 7 129352 140120.47 -10768.467 8 234817 140120.47 94696.533 9 60448 140120.47 -79672.467 10 47818 42866.00 4952.000 11 245546 140120.47 105425.533 12 48020 42866.00 5154.000 13 -1710 42866.00 -44576.000 14 32648 42866.00 -10218.000 15 95350 140120.47 -44770.467 16 151352 140120.47 11231.533 17 288170 140120.47 148049.533 18 114337 140120.47 -25783.467 19 37884 42866.00 -4982.000 20 122844 140120.47 -17276.467 21 82340 42866.00 39474.000 22 79801 105024.41 -25223.412 23 165548 140120.47 25427.533 24 116384 140120.47 -23736.467 25 134028 140120.47 -6092.467 26 63838 105024.41 -41186.412 27 74996 140120.47 -65124.467 28 31080 42866.00 -11786.000 29 32168 105024.41 -72856.412 30 49857 140120.47 -90263.467 31 87161 105024.41 -17863.412 32 106113 105024.41 1088.588 33 80570 105024.41 -24454.412 34 102129 105024.41 -2895.412 35 301670 105024.41 196645.588 36 102313 140120.47 -37807.467 37 88577 105024.41 -16447.412 38 112477 105024.41 7452.588 39 191778 140120.47 51657.533 40 79804 42866.00 36938.000 41 128294 140120.47 -11826.467 42 96448 101063.14 -4615.143 43 93811 140120.47 -46309.467 44 117520 105024.41 12495.588 45 69159 66089.89 3069.111 46 101792 66089.89 35702.111 47 210568 105024.41 105543.588 48 136996 140120.47 -3124.467 49 121920 105024.41 16895.588 50 76403 66089.89 10313.111 51 108094 105024.41 3069.588 52 134759 140120.47 -5361.467 53 188873 140120.47 48752.533 54 146216 140120.47 6095.533 55 156608 140120.47 16487.533 56 61348 105024.41 -43676.412 57 50350 105024.41 -54674.412 58 87720 105024.41 -17304.412 59 99489 101063.14 -1574.143 60 87419 105024.41 -17605.412 61 94355 105024.41 -10669.412 62 60326 66089.89 -5763.889 63 94670 105024.41 -10354.412 64 82425 101063.14 -18638.143 65 59017 66089.89 -7072.889 66 90829 140120.47 -49291.467 67 80791 101063.14 -20272.143 68 100423 105024.41 -4601.412 69 131116 105024.41 26091.588 70 100269 105024.41 -4755.412 71 27330 66089.89 -38759.889 72 39039 66089.89 -27050.889 73 106885 66089.89 40795.111 74 79285 66089.89 13195.111 75 118881 105024.41 13856.588 76 77623 66089.89 11533.111 77 114768 101063.14 13704.857 78 74015 66089.89 7925.111 79 69465 42866.00 26599.000 80 117869 140120.47 -22251.467 81 60982 66089.89 -5107.889 82 90131 105024.41 -14893.412 83 138971 105024.41 33946.588 84 39625 66089.89 -26464.889 85 102725 105024.41 -2299.412 86 64239 66089.89 -1850.889 87 90262 105024.41 -14762.412 88 103960 105024.41 -1064.412 89 106611 101063.14 5547.857 90 103345 105024.41 -1679.412 91 95551 105024.41 -9473.412 92 82903 66089.89 16813.111 93 63593 105024.41 -41431.412 94 126910 101063.14 25846.857 95 37527 66089.89 -28562.889 96 60247 66089.89 -5842.889 97 112995 105024.41 7970.588 98 70184 42866.00 27318.000 99 130140 105024.41 25115.588 100 73221 66089.89 7131.111 > 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/html/rcomp/tmp/4922i1293218677.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/html/rcomp/tmp/5u31o1293218677.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/html/rcomp/tmp/6gmzc1293218677.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/html/rcomp/tmp/7j4y01293218677.tab") + } > > try(system("convert tmp/2gb3x1293218677.ps tmp/2gb3x1293218677.png",intern=TRUE)) character(0) > try(system("convert tmp/3gb3x1293218677.ps tmp/3gb3x1293218677.png",intern=TRUE)) character(0) > try(system("convert tmp/4922i1293218677.ps tmp/4922i1293218677.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.725 0.674 16.359