R version 2.13.0 (2011-04-13) Copyright (C) 2011 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 = '2' > 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] "Time_spent" > x[,par1] [1] 158258 186930 7215 129098 230587 508313 180745 185559 154581 290658 [11] 121844 184039 100324 209427 167592 154593 142018 77855 167047 27997 [21] 73019 241082 195820 141899 145433 180241 202232 190230 354924 192399 [31] 182286 181590 133801 233686 219428 0 223044 100129 136733 249965 [41] 242379 145794 96404 195891 117156 157787 81293 224049 223789 160344 [51] 48188 152206 294283 235223 195583 145942 208834 93764 151985 190545 [61] 148922 132856 126107 112718 160930 99184 182022 138708 114408 31970 [71] 225558 137011 113612 108641 162203 100098 174768 158459 80934 84971 [81] 80545 287191 62974 130982 75555 162154 226638 115019 105038 155537 [91] 153133 165577 151517 133686 58128 245196 195576 19349 225371 152796 [101] 59117 91762 127987 113552 85338 27676 147984 122417 0 91529 [111] 107205 144664 136540 76656 3616 0 183065 144636 156889 113273 [121] 43410 175774 95401 118893 60493 19764 164062 132696 155367 11796 [131] 10674 142261 6836 154206 5118 40248 0 122641 88837 7131 [141] 9056 76611 132697 100681 > 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 3616 5118 6836 7131 7215 9056 10674 11796 19349 19764 4 1 1 1 1 1 1 1 1 1 1 27676 27997 31970 40248 43410 48188 58128 59117 60493 62974 73019 1 1 1 1 1 1 1 1 1 1 1 75555 76611 76656 77855 80545 80934 81293 84971 85338 88837 91529 1 1 1 1 1 1 1 1 1 1 1 91762 93764 95401 96404 99184 100098 100129 100324 100681 105038 107205 1 1 1 1 1 1 1 1 1 1 1 108641 112718 113273 113552 113612 114408 115019 117156 118893 121844 122417 1 1 1 1 1 1 1 1 1 1 1 122641 126107 127987 129098 130982 132696 132697 132856 133686 133801 136540 1 1 1 1 1 1 1 1 1 1 1 136733 137011 138708 141899 142018 142261 144636 144664 145433 145794 145942 1 1 1 1 1 1 1 1 1 1 1 147984 148922 151517 151985 152206 152796 153133 154206 154581 154593 155367 1 1 1 1 1 1 1 1 1 1 1 155537 156889 157787 158258 158459 160344 160930 162154 162203 164062 165577 1 1 1 1 1 1 1 1 1 1 1 167047 167592 174768 175774 180241 180745 181590 182022 182286 183065 184039 1 1 1 1 1 1 1 1 1 1 1 185559 186930 190230 190545 192399 195576 195583 195820 195891 202232 208834 1 1 1 1 1 1 1 1 1 1 1 209427 219428 223044 223789 224049 225371 225558 226638 230587 233686 235223 1 1 1 1 1 1 1 1 1 1 1 241082 242379 245196 249965 287191 290658 294283 354924 508313 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "page_views" "Time_spent" "Logins" "Writing" > colnames(x)[par1] [1] "Time_spent" > x[,par1] [1] 158258 186930 7215 129098 230587 508313 180745 185559 154581 290658 [11] 121844 184039 100324 209427 167592 154593 142018 77855 167047 27997 [21] 73019 241082 195820 141899 145433 180241 202232 190230 354924 192399 [31] 182286 181590 133801 233686 219428 0 223044 100129 136733 249965 [41] 242379 145794 96404 195891 117156 157787 81293 224049 223789 160344 [51] 48188 152206 294283 235223 195583 145942 208834 93764 151985 190545 [61] 148922 132856 126107 112718 160930 99184 182022 138708 114408 31970 [71] 225558 137011 113612 108641 162203 100098 174768 158459 80934 84971 [81] 80545 287191 62974 130982 75555 162154 226638 115019 105038 155537 [91] 153133 165577 151517 133686 58128 245196 195576 19349 225371 152796 [101] 59117 91762 127987 113552 85338 27676 147984 122417 0 91529 [111] 107205 144664 136540 76656 3616 0 183065 144636 156889 113273 [121] 43410 175774 95401 118893 60493 19764 164062 132696 155367 11796 [131] 10674 142261 6836 154206 5118 40248 0 122641 88837 7131 [141] 9056 76611 132697 100681 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/1aira1344777200.tab") + } + } > m Conditional inference tree with 7 terminal nodes Response: Time_spent Inputs: page_views, Logins, Writing Number of observations: 144 1) page_views <= 1082; criterion = 1, statistic = 113.384 2) page_views <= 726; criterion = 1, statistic = 33.125 3) page_views <= 261; criterion = 1, statistic = 15.605 4)* weights = 13 3) page_views > 261 5)* weights = 7 2) page_views > 726 6)* weights = 19 1) page_views > 1082 7) page_views <= 2097; criterion = 1, statistic = 62.805 8) page_views <= 1365; criterion = 1, statistic = 16.433 9)* weights = 24 8) page_views > 1365 10)* weights = 47 7) page_views > 2097 11) page_views <= 2649; criterion = 1, statistic = 15.924 12)* weights = 23 11) page_views > 2649 13)* weights = 11 > postscript(file="/var/wessaorg/rcomp/tmp/208e01344777200.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/wessaorg/rcomp/tmp/39oz11344777200.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 158258 156304.319 1953.6809 2 186930 156304.319 30625.6809 3 7215 6214.692 1000.3077 4 129098 201818.826 -72720.8261 5 230587 253685.000 -23098.0000 6 508313 253685.000 254628.0000 7 180745 156304.319 24440.6809 8 185559 156304.319 29254.6809 9 154581 156304.319 -1723.3191 10 290658 253685.000 36973.0000 11 121844 156304.319 -34460.3191 12 184039 201818.826 -17779.8261 13 100324 156304.319 -55980.3191 14 209427 253685.000 -44258.0000 15 167592 156304.319 11287.6809 16 154593 156304.319 -1711.3191 17 142018 156304.319 -14286.3191 18 77855 123104.542 -45249.5417 19 167047 253685.000 -86638.0000 20 27997 36422.857 -8425.8571 21 73019 82091.053 -9072.0526 22 241082 253685.000 -12603.0000 23 195820 156304.319 39515.6809 24 141899 201818.826 -59919.8261 25 145433 156304.319 -10871.3191 26 180241 156304.319 23936.6809 27 202232 156304.319 45927.6809 28 190230 156304.319 33925.6809 29 354924 253685.000 101239.0000 30 192399 201818.826 -9419.8261 31 182286 156304.319 25981.6809 32 181590 156304.319 25285.6809 33 133801 201818.826 -68017.8261 34 233686 253685.000 -19999.0000 35 219428 201818.826 17609.1739 36 0 6214.692 -6214.6923 37 223044 201818.826 21225.1739 38 100129 156304.319 -56175.3191 39 136733 156304.319 -19571.3191 40 249965 201818.826 48146.1739 41 242379 201818.826 40560.1739 42 145794 156304.319 -10510.3191 43 96404 82091.053 14312.9474 44 195891 201818.826 -5927.8261 45 117156 123104.542 -5948.5417 46 157787 123104.542 34682.4583 47 81293 82091.053 -798.0526 48 224049 201818.826 22230.1739 49 223789 201818.826 21970.1739 50 160344 201818.826 -41474.8261 51 48188 36422.857 11765.1429 52 152206 156304.319 -4098.3191 53 294283 201818.826 92464.1739 54 235223 156304.319 78918.6809 55 195583 156304.319 39278.6809 56 145942 156304.319 -10362.3191 57 208834 156304.319 52529.6809 58 93764 82091.053 11672.9474 59 151985 123104.542 28880.4583 60 190545 253685.000 -63140.0000 61 148922 156304.319 -7382.3191 62 132856 156304.319 -23448.3191 63 126107 123104.542 3002.4583 64 112718 123104.542 -10386.5417 65 160930 123104.542 37825.4583 66 99184 123104.542 -23920.5417 67 182022 201818.826 -19796.8261 68 138708 253685.000 -114977.0000 69 114408 123104.542 -8696.5417 70 31970 36422.857 -4452.8571 71 225558 253685.000 -28127.0000 72 137011 123104.542 13906.4583 73 113612 156304.319 -42692.3191 74 108641 156304.319 -47663.3191 75 162203 201818.826 -39615.8261 76 100098 156304.319 -56206.3191 77 174768 201818.826 -27050.8261 78 158459 201818.826 -43359.8261 79 80934 82091.053 -1157.0526 80 84971 123104.542 -38133.5417 81 80545 82091.053 -1546.0526 82 287191 201818.826 85372.1739 83 62974 82091.053 -19117.0526 84 130982 156304.319 -25322.3191 85 75555 82091.053 -6536.0526 86 162154 156304.319 5849.6809 87 226638 201818.826 24819.1739 88 115019 123104.542 -8085.5417 89 105038 123104.542 -18066.5417 90 155537 156304.319 -767.3191 91 153133 156304.319 -3171.3191 92 165577 201818.826 -36241.8261 93 151517 123104.542 28412.4583 94 133686 123104.542 10581.4583 95 58128 82091.053 -23963.0526 96 245196 201818.826 43377.1739 97 195576 156304.319 39271.6809 98 19349 6214.692 13134.3077 99 225371 201818.826 23552.1739 100 152796 156304.319 -3508.3191 101 59117 36422.857 22694.1429 102 91762 82091.053 9670.9474 103 127987 123104.542 4882.4583 104 113552 123104.542 -9552.5417 105 85338 82091.053 3246.9474 106 27676 36422.857 -8746.8571 107 147984 156304.319 -8320.3191 108 122417 123104.542 -687.5417 109 0 6214.692 -6214.6923 110 91529 82091.053 9437.9474 111 107205 123104.542 -15899.5417 112 144664 156304.319 -11640.3191 113 136540 156304.319 -19764.3191 114 76656 82091.053 -5435.0526 115 3616 6214.692 -2598.6923 116 0 6214.692 -6214.6923 117 183065 123104.542 59960.4583 118 144636 156304.319 -11668.3191 119 156889 156304.319 584.6809 120 113273 82091.053 31181.9474 121 43410 82091.053 -38681.0526 122 175774 156304.319 19469.6809 123 95401 82091.053 13309.9474 124 118893 156304.319 -37411.3191 125 60493 82091.053 -21598.0526 126 19764 36422.857 -16658.8571 127 164062 156304.319 7757.6809 128 132696 123104.542 9591.4583 129 155367 156304.319 -937.3191 130 11796 6214.692 5581.3077 131 10674 6214.692 4459.3077 132 142261 156304.319 -14043.3191 133 6836 6214.692 621.3077 134 154206 156304.319 -2098.3191 135 5118 6214.692 -1096.6923 136 40248 36422.857 3825.1429 137 0 6214.692 -6214.6923 138 122641 82091.053 40549.9474 139 88837 123104.542 -34267.5417 140 7131 6214.692 916.3077 141 9056 6214.692 2841.3077 142 76611 82091.053 -5480.0526 143 132697 123104.542 9592.4583 144 100681 123104.542 -22423.5417 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/wessaorg/rcomp/tmp/42f9i1344777200.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/wessaorg/rcomp/tmp/5ad9s1344777200.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/wessaorg/rcomp/tmp/62vtw1344777200.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/wessaorg/rcomp/tmp/70dke1344777200.tab") + } > > try(system("convert tmp/208e01344777200.ps tmp/208e01344777200.png",intern=TRUE)) character(0) > try(system("convert tmp/39oz11344777200.ps tmp/39oz11344777200.png",intern=TRUE)) character(0) > try(system("convert tmp/42f9i1344777200.ps tmp/42f9i1344777200.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.532 0.341 4.867