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. > x <- array(list(1772 + ,158258 + ,89 + ,20465 + ,1703 + ,186930 + ,57 + ,33629 + ,192 + ,7215 + ,18 + ,1423 + ,2294 + ,129098 + ,94 + ,25629 + ,3448 + ,230587 + ,134 + ,54002 + ,6813 + ,508313 + ,261 + ,151036 + ,1795 + ,180745 + ,56 + ,33287 + ,1680 + ,185559 + ,58 + ,31172 + ,1896 + ,154581 + ,43 + ,28113 + ,2917 + ,290658 + ,95 + ,57803 + ,1946 + ,121844 + ,75 + ,49830 + ,2148 + ,184039 + ,69 + ,52143 + ,1832 + ,100324 + ,98 + ,21055 + ,3059 + ,209427 + ,114 + ,47007 + ,1469 + ,167592 + ,57 + ,28735 + ,1565 + ,154593 + ,86 + ,59147 + ,1755 + ,142018 + ,56 + ,78950 + ,1234 + ,77855 + ,59 + ,13497 + ,2779 + ,167047 + ,87 + ,46154 + ,726 + ,27997 + ,24 + ,53249 + ,1048 + ,73019 + ,59 + ,10726 + ,2804 + ,241082 + ,99 + ,83700 + ,1760 + ,195820 + ,72 + ,40400 + ,2261 + ,141899 + ,53 + ,33797 + ,1848 + ,145433 + ,86 + ,36205 + ,1647 + ,180241 + ,31 + ,30165 + ,2081 + ,202232 + ,160 + ,58534 + ,1393 + ,190230 + ,91 + ,44663 + ,2741 + ,354924 + ,118 + ,92556 + ,2112 + ,192399 + ,44 + ,40078 + ,1684 + ,182286 + ,44 + ,34711 + ,1616 + ,181590 + ,45 + ,31076 + ,2227 + ,133801 + ,105 + ,74608 + ,3088 + ,233686 + ,123 + ,58092 + ,2388 + ,219428 + ,52 + ,42009 + ,1 + ,0 + ,1 + ,0 + ,2099 + ,223044 + ,63 + ,36022 + ,1669 + ,100129 + ,51 + ,23333 + ,2094 + ,136733 + ,47 + ,53349 + ,2153 + ,249965 + ,64 + ,92596 + ,2390 + ,242379 + ,71 + ,49598 + ,1701 + ,145794 + ,59 + ,44093 + ,983 + ,96404 + ,32 + ,84205 + ,2161 + ,195891 + ,78 + ,63369 + ,1276 + ,117156 + ,50 + ,60132 + ,1189 + ,157787 + ,94 + ,37403 + ,744 + ,81293 + ,31 + ,24460 + ,2231 + ,224049 + ,100 + ,46456 + ,2242 + ,223789 + ,87 + ,66616 + ,2638 + ,160344 + ,58 + ,41554 + ,658 + ,48188 + ,28 + ,22346 + ,1859 + ,152206 + ,68 + ,30874 + ,2489 + ,294283 + ,73 + ,68701 + ,2025 + ,235223 + ,78 + ,35728 + ,1911 + ,195583 + ,59 + ,29010 + ,1714 + ,145942 + ,54 + ,23110 + ,1851 + ,208834 + ,66 + ,38844 + ,980 + ,93764 + ,23 + ,27084 + ,1177 + ,151985 + ,66 + ,35139 + ,2809 + ,190545 + ,95 + ,57476 + ,1688 + ,148922 + ,60 + ,33277 + ,2097 + ,132856 + ,80 + ,31141 + ,1309 + ,126107 + ,60 + ,61281 + ,1243 + ,112718 + ,36 + ,25820 + ,1255 + ,160930 + ,34 + ,23284 + ,1293 + ,99184 + ,40 + ,35378 + ,2259 + ,182022 + ,69 + ,74990 + ,2897 + ,138708 + ,65 + ,29653 + ,1103 + ,114408 + ,38 + ,64622 + ,340 + ,31970 + ,15 + ,4157 + ,2791 + ,225558 + ,112 + ,29245 + ,1333 + ,137011 + ,71 + ,50008 + ,1441 + ,113612 + ,68 + ,52338 + ,1622 + ,108641 + ,70 + ,13310 + ,2649 + ,162203 + ,66 + ,92901 + ,1499 + ,100098 + ,44 + ,10956 + ,2302 + ,174768 + ,60 + ,34241 + ,2540 + ,158459 + ,97 + ,75043 + ,1000 + ,80934 + ,30 + ,21152 + ,1234 + ,84971 + ,71 + ,42249 + ,927 + ,80545 + ,68 + ,42005 + ,2176 + ,287191 + ,64 + ,41152 + ,956 + ,62974 + ,27 + ,14399 + ,1531 + ,130982 + ,38 + ,28263 + ,1013 + ,75555 + ,45 + ,17215 + ,1771 + ,162154 + ,54 + ,48140 + ,2613 + ,226638 + ,227 + ,62897 + ,1203 + ,115019 + ,110 + ,22883 + ,1303 + ,105038 + ,60 + ,41622 + ,1524 + ,155537 + ,52 + ,40715 + ,1829 + ,153133 + ,41 + ,65897 + ,2227 + ,165577 + ,76 + ,76542 + ,1233 + ,151517 + ,57 + ,37477 + ,1365 + ,133686 + ,58 + ,53216 + ,901 + ,58128 + ,38 + ,40911 + ,2319 + ,245196 + ,117 + ,57021 + ,1857 + ,195576 + ,70 + ,73116 + ,223 + ,19349 + ,12 + ,3895 + ,2390 + ,225371 + ,105 + ,46609 + ,1973 + ,152796 + ,76 + ,29351 + ,699 + ,59117 + ,28 + ,2325 + ,1062 + ,91762 + ,24 + ,31747 + ,1252 + ,127987 + ,52 + ,32665 + ,1154 + ,113552 + ,58 + ,19249 + ,823 + ,85338 + ,40 + ,15292 + ,596 + ,27676 + ,22 + ,5842 + ,1471 + ,147984 + ,47 + ,33994 + ,1130 + ,122417 + ,37 + ,13018 + ,0 + ,0 + ,0 + ,0 + ,1082 + ,91529 + ,32 + ,98177 + ,1134 + ,107205 + ,66 + ,37941 + ,1366 + ,144664 + ,44 + ,31032 + ,1452 + ,136540 + ,62 + ,32683 + ,869 + ,76656 + ,59 + ,34545 + ,78 + ,3616 + ,5 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1127 + ,183065 + ,43 + ,27525 + ,1578 + ,144636 + ,83 + ,66856 + ,2018 + ,156889 + ,97 + ,28549 + ,919 + ,113273 + ,38 + ,38610 + ,778 + ,43410 + ,19 + ,2781 + ,1751 + ,175774 + ,72 + ,41211 + ,956 + ,95401 + ,41 + ,22698 + ,1875 + ,118893 + ,54 + ,41194 + ,731 + ,60493 + ,40 + ,32689 + ,285 + ,19764 + ,12 + ,5752 + ,1833 + ,164062 + ,55 + ,26757 + ,1147 + ,132696 + ,32 + ,22527 + ,1646 + ,155367 + ,54 + ,44810 + ,256 + ,11796 + ,9 + ,0 + ,98 + ,10674 + ,9 + ,0 + ,1403 + ,142261 + ,56 + ,100674 + ,41 + ,6836 + ,3 + ,0 + ,1786 + ,154206 + ,61 + ,57786 + ,42 + ,5118 + ,3 + ,0 + ,528 + ,40248 + ,16 + ,5444 + ,0 + ,0 + ,0 + ,0 + ,1072 + ,122641 + ,46 + ,28470 + ,1305 + ,88837 + ,38 + ,61849 + ,81 + ,7131 + ,4 + ,0 + ,261 + ,9056 + ,14 + ,2179 + ,934 + ,76611 + ,24 + ,8019 + ,1179 + ,132697 + ,50 + ,39644 + ,1147 + ,100681 + ,19 + ,23494) + ,dim=c(4 + ,144) + ,dimnames=list(c('page_views' + ,'Time_spent' + ,'Logins' + ,'Writing') + ,1:144)) > y <- array(NA,dim=c(4,144),dimnames=list(c('page_views','Time_spent','Logins','Writing'),1:144)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '1' > 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 <- 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] "page_views" > x[,par1] [1] 1772 1703 192 2294 3448 6813 1795 1680 1896 2917 1946 2148 1832 3059 1469 [16] 1565 1755 1234 2779 726 1048 2804 1760 2261 1848 1647 2081 1393 2741 2112 [31] 1684 1616 2227 3088 2388 1 2099 1669 2094 2153 2390 1701 983 2161 1276 [46] 1189 744 2231 2242 2638 658 1859 2489 2025 1911 1714 1851 980 1177 2809 [61] 1688 2097 1309 1243 1255 1293 2259 2897 1103 340 2791 1333 1441 1622 2649 [76] 1499 2302 2540 1000 1234 927 2176 956 1531 1013 1771 2613 1203 1303 1524 [91] 1829 2227 1233 1365 901 2319 1857 223 2390 1973 699 1062 1252 1154 823 [106] 596 1471 1130 0 1082 1134 1366 1452 869 78 0 1127 1578 2018 919 [121] 778 1751 956 1875 731 285 1833 1147 1646 256 98 1403 41 1786 42 [136] 528 0 1072 1305 81 261 934 1179 1147 > 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]) 0 1 41 42 78 81 98 192 223 256 261 285 340 528 596 658 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 699 726 731 744 778 823 869 901 919 927 934 956 980 983 1000 1013 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1048 1062 1072 1082 1103 1127 1130 1134 1147 1154 1177 1179 1189 1203 1233 1234 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1243 1252 1255 1276 1293 1303 1305 1309 1333 1365 1366 1393 1403 1441 1452 1469 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1471 1499 1524 1531 1565 1578 1616 1622 1646 1647 1669 1680 1684 1688 1701 1703 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1714 1751 1755 1760 1771 1772 1786 1795 1829 1832 1833 1848 1851 1857 1859 1875 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1896 1911 1946 1973 2018 2025 2081 2094 2097 2099 2112 2148 2153 2161 2176 2227 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2231 2242 2259 2261 2294 2302 2319 2388 2390 2489 2540 2613 2638 2649 2741 2779 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2791 2804 2809 2897 2917 3059 3088 3448 6813 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "page_views" "Time_spent" "Logins" "Writing" > colnames(x)[par1] [1] "page_views" > x[,par1] [1] 1772 1703 192 2294 3448 6813 1795 1680 1896 2917 1946 2148 1832 3059 1469 [16] 1565 1755 1234 2779 726 1048 2804 1760 2261 1848 1647 2081 1393 2741 2112 [31] 1684 1616 2227 3088 2388 1 2099 1669 2094 2153 2390 1701 983 2161 1276 [46] 1189 744 2231 2242 2638 658 1859 2489 2025 1911 1714 1851 980 1177 2809 [61] 1688 2097 1309 1243 1255 1293 2259 2897 1103 340 2791 1333 1441 1622 2649 [76] 1499 2302 2540 1000 1234 927 2176 956 1531 1013 1771 2613 1203 1303 1524 [91] 1829 2227 1233 1365 901 2319 1857 223 2390 1973 699 1062 1252 1154 823 [106] 596 1471 1130 0 1082 1134 1366 1452 869 78 0 1127 1578 2018 919 [121] 778 1751 956 1875 731 285 1833 1147 1646 256 98 1403 41 1786 42 [136] 528 0 1072 1305 81 261 934 1179 1147 > 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/1wbjk1344777087.tab") + } + } > m Conditional inference tree with 8 terminal nodes Response: page_views Inputs: Time_spent, Logins, Writing Number of observations: 144 1) Time_spent <= 127987; criterion = 1, statistic = 113.384 2) Time_spent <= 40248; criterion = 1, statistic = 49.617 3)* weights = 18 2) Time_spent > 40248 4) Time_spent <= 96404; criterion = 1, statistic = 16.704 5) Time_spent <= 73019; criterion = 0.978, statistic = 7.204 6)* weights = 7 5) Time_spent > 73019 7)* weights = 15 4) Time_spent > 96404 8)* weights = 21 1) Time_spent > 127987 9) Time_spent <= 208834; criterion = 1, statistic = 45.865 10) Logins <= 57; criterion = 0.989, statistic = 8.437 11)* weights = 26 10) Logins > 57 12)* weights = 37 9) Time_spent > 208834 13) Time_spent <= 242379; criterion = 0.999, statistic = 12.289 14)* weights = 13 13) Time_spent > 242379 15)* weights = 7 > postscript(file="/var/www/rcomp/tmp/24q421344777087.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/3qp0a1344777087.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 1772 1962.5676 -190.567568 2 1703 1617.7308 85.269231 3 192 208.2222 -16.222222 4 2294 1962.5676 331.432432 5 3448 2582.1538 865.846154 6 6813 3086.8571 3726.142857 7 1795 1617.7308 177.269231 8 1680 1962.5676 -282.567568 9 1896 1617.7308 278.269231 10 2917 3086.8571 -169.857143 11 1946 1353.4286 592.571429 12 2148 1962.5676 185.432432 13 1832 1353.4286 478.571429 14 3059 2582.1538 476.846154 15 1469 1617.7308 -148.730769 16 1565 1962.5676 -397.567568 17 1755 1617.7308 137.269231 18 1234 1009.7333 224.266667 19 2779 1962.5676 816.432432 20 726 208.2222 517.777778 21 1048 824.4286 223.571429 22 2804 2582.1538 221.846154 23 1760 1962.5676 -202.567568 24 2261 1617.7308 643.269231 25 1848 1962.5676 -114.567568 26 1647 1617.7308 29.269231 27 2081 1962.5676 118.432432 28 1393 1962.5676 -569.567568 29 2741 3086.8571 -345.857143 30 2112 1617.7308 494.269231 31 1684 1617.7308 66.269231 32 1616 1617.7308 -1.730769 33 2227 1962.5676 264.432432 34 3088 2582.1538 505.846154 35 2388 2582.1538 -194.153846 36 1 208.2222 -207.222222 37 2099 2582.1538 -483.153846 38 1669 1353.4286 315.571429 39 2094 1617.7308 476.269231 40 2153 3086.8571 -933.857143 41 2390 2582.1538 -192.153846 42 1701 1962.5676 -261.567568 43 983 1009.7333 -26.733333 44 2161 1962.5676 198.432432 45 1276 1353.4286 -77.428571 46 1189 1962.5676 -773.567568 47 744 1009.7333 -265.733333 48 2231 2582.1538 -351.153846 49 2242 2582.1538 -340.153846 50 2638 1962.5676 675.432432 51 658 824.4286 -166.428571 52 1859 1962.5676 -103.567568 53 2489 3086.8571 -597.857143 54 2025 2582.1538 -557.153846 55 1911 1962.5676 -51.567568 56 1714 1617.7308 96.269231 57 1851 1962.5676 -111.567568 58 980 1009.7333 -29.733333 59 1177 1962.5676 -785.567568 60 2809 1962.5676 846.432432 61 1688 1962.5676 -274.567568 62 2097 1962.5676 134.432432 63 1309 1353.4286 -44.428571 64 1243 1353.4286 -110.428571 65 1255 1617.7308 -362.730769 66 1293 1353.4286 -60.428571 67 2259 1962.5676 296.432432 68 2897 1962.5676 934.432432 69 1103 1353.4286 -250.428571 70 340 208.2222 131.777778 71 2791 2582.1538 208.846154 72 1333 1962.5676 -629.567568 73 1441 1353.4286 87.571429 74 1622 1353.4286 268.571429 75 2649 1962.5676 686.432432 76 1499 1353.4286 145.571429 77 2302 1962.5676 339.432432 78 2540 1962.5676 577.432432 79 1000 1009.7333 -9.733333 80 1234 1009.7333 224.266667 81 927 1009.7333 -82.733333 82 2176 3086.8571 -910.857143 83 956 824.4286 131.571429 84 1531 1617.7308 -86.730769 85 1013 1009.7333 3.266667 86 1771 1617.7308 153.269231 87 2613 2582.1538 30.846154 88 1203 1353.4286 -150.428571 89 1303 1353.4286 -50.428571 90 1524 1617.7308 -93.730769 91 1829 1617.7308 211.269231 92 2227 1962.5676 264.432432 93 1233 1617.7308 -384.730769 94 1365 1962.5676 -597.567568 95 901 824.4286 76.571429 96 2319 3086.8571 -767.857143 97 1857 1962.5676 -105.567568 98 223 208.2222 14.777778 99 2390 2582.1538 -192.153846 100 1973 1962.5676 10.432432 101 699 824.4286 -125.428571 102 1062 1009.7333 52.266667 103 1252 1353.4286 -101.428571 104 1154 1353.4286 -199.428571 105 823 1009.7333 -186.733333 106 596 208.2222 387.777778 107 1471 1617.7308 -146.730769 108 1130 1353.4286 -223.428571 109 0 208.2222 -208.222222 110 1082 1009.7333 72.266667 111 1134 1353.4286 -219.428571 112 1366 1617.7308 -251.730769 113 1452 1962.5676 -510.567568 114 869 1009.7333 -140.733333 115 78 208.2222 -130.222222 116 0 208.2222 -208.222222 117 1127 1617.7308 -490.730769 118 1578 1962.5676 -384.567568 119 2018 1962.5676 55.432432 120 919 1353.4286 -434.428571 121 778 824.4286 -46.428571 122 1751 1962.5676 -211.567568 123 956 1009.7333 -53.733333 124 1875 1353.4286 521.571429 125 731 824.4286 -93.428571 126 285 208.2222 76.777778 127 1833 1617.7308 215.269231 128 1147 1617.7308 -470.730769 129 1646 1617.7308 28.269231 130 256 208.2222 47.777778 131 98 208.2222 -110.222222 132 1403 1617.7308 -214.730769 133 41 208.2222 -167.222222 134 1786 1962.5676 -176.567568 135 42 208.2222 -166.222222 136 528 208.2222 319.777778 137 0 208.2222 -208.222222 138 1072 1353.4286 -281.428571 139 1305 1009.7333 295.266667 140 81 208.2222 -127.222222 141 261 208.2222 52.777778 142 934 1009.7333 -75.733333 143 1179 1617.7308 -438.730769 144 1147 1353.4286 -206.428571 > 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/4oyna1344777087.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/5ht971344777087.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/6uaxk1344777087.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/78gw41344777087.tab") + } > > try(system("convert tmp/24q421344777087.ps tmp/24q421344777087.png",intern=TRUE)) character(0) > try(system("convert tmp/3qp0a1344777087.ps tmp/3qp0a1344777087.png",intern=TRUE)) character(0) > try(system("convert tmp/4oyna1344777087.ps tmp/4oyna1344777087.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.840 0.500 3.343