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(1407 + ,118540 + ,74 + ,440 + ,15 + ,18158 + ,1072 + ,127145 + ,44 + ,306 + ,16 + ,30461 + ,192 + ,7215 + ,18 + ,72 + ,0 + ,1423 + ,2032 + ,112861 + ,84 + ,584 + ,22 + ,25629 + ,3032 + ,197581 + ,120 + ,1013 + ,25 + ,48758 + ,5519 + ,377410 + ,209 + ,1506 + ,26 + ,129230 + ,1321 + ,117604 + ,49 + ,442 + ,19 + ,27376 + ,1034 + ,120102 + ,44 + ,274 + ,25 + ,26706 + ,1388 + ,96175 + ,36 + ,382 + ,25 + ,26505 + ,2552 + ,253517 + ,85 + ,812 + ,26 + ,49801 + ,1735 + ,108994 + ,65 + ,546 + ,20 + ,46580 + ,1788 + ,156212 + ,58 + ,551 + ,25 + ,48352 + ,1292 + ,68810 + ,84 + ,477 + ,15 + ,13899 + ,2362 + ,149246 + ,83 + ,799 + ,21 + ,39342 + ,1150 + ,125503 + ,42 + ,330 + ,12 + ,27465 + ,1374 + ,125769 + ,67 + ,419 + ,19 + ,55211 + ,1503 + ,123467 + ,49 + ,364 + ,28 + ,74098 + ,965 + ,56088 + ,45 + ,277 + ,12 + ,13497 + ,2164 + ,108128 + ,73 + ,658 + ,28 + ,38338 + ,633 + ,22762 + ,20 + ,188 + ,13 + ,52505 + ,837 + ,48554 + ,48 + ,286 + ,14 + ,10663 + ,1991 + ,159102 + ,78 + ,575 + ,23 + ,74484 + ,1450 + ,139108 + ,57 + ,514 + ,25 + ,28895 + ,1765 + ,92058 + ,43 + ,525 + ,30 + ,32827 + ,1612 + ,126311 + ,69 + ,516 + ,17 + ,36188 + ,1173 + ,113807 + ,21 + ,426 + ,17 + ,28173 + ,1602 + ,133994 + ,132 + ,509 + ,21 + ,54926 + ,1046 + ,131810 + ,71 + ,248 + ,24 + ,38900 + ,2176 + ,279065 + ,96 + ,724 + ,22 + ,88530 + ,1767 + ,158146 + ,35 + ,733 + ,16 + ,35482 + ,1167 + ,107352 + ,36 + ,374 + ,23 + ,26730 + ,1394 + ,149827 + ,37 + ,471 + ,18 + ,29806 + ,1733 + ,90912 + ,83 + ,549 + ,11 + ,41799 + ,2374 + ,169510 + ,96 + ,721 + ,20 + ,54289 + ,1852 + ,162204 + ,40 + ,596 + ,20 + ,36805 + ,1 + ,0 + ,1 + ,0 + ,0 + ,0 + ,1677 + ,163310 + ,53 + ,778 + ,24 + ,33146 + ,1505 + ,92342 + ,46 + ,464 + ,14 + ,23333 + ,1813 + ,98357 + ,40 + ,417 + ,29 + ,47686 + ,1648 + ,178277 + ,49 + ,607 + ,31 + ,77783 + ,1560 + ,134927 + ,53 + ,495 + ,15 + ,36042 + ,1301 + ,104577 + ,46 + ,489 + ,30 + ,34541 + ,784 + ,81614 + ,23 + ,281 + ,20 + ,75620 + ,1580 + ,119111 + ,60 + ,603 + ,20 + ,60610 + ,896 + ,83923 + ,39 + ,278 + ,18 + ,55041 + ,959 + ,109885 + ,71 + ,246 + ,19 + ,32087 + ,567 + ,52851 + ,24 + ,162 + ,28 + ,16356 + ,1519 + ,153621 + ,73 + ,525 + ,18 + ,40161 + ,1625 + ,152572 + ,74 + ,506 + ,26 + ,55459 + ,1817 + ,114073 + ,44 + ,677 + ,23 + ,36679 + ,658 + ,48188 + ,28 + ,205 + ,22 + ,22346 + ,1187 + ,90994 + ,52 + ,306 + ,19 + ,27377 + ,1863 + ,215588 + ,61 + ,680 + ,20 + ,50273 + ,1559 + ,176489 + ,64 + ,533 + ,25 + ,32104 + ,1340 + ,138871 + ,46 + ,487 + ,27 + ,27016 + ,1342 + ,104416 + ,44 + ,418 + ,10 + ,19715 + ,1505 + ,156186 + ,54 + ,401 + ,26 + ,33629 + ,669 + ,60368 + ,16 + ,189 + ,21 + ,27084 + ,814 + ,95391 + ,53 + ,275 + ,19 + ,32352 + ,2189 + ,126048 + ,65 + ,738 + ,32 + ,51845 + ,1291 + ,96388 + ,44 + ,369 + ,28 + ,26591 + ,1378 + ,77353 + ,58 + ,490 + ,16 + ,29677 + ,978 + ,79872 + ,41 + ,298 + ,16 + ,54237 + ,823 + ,79772 + ,27 + ,259 + ,20 + ,20284 + ,789 + ,96945 + ,22 + ,268 + ,20 + ,22741 + ,1134 + ,88300 + ,34 + ,364 + ,24 + ,34178 + ,1875 + ,126203 + ,59 + ,426 + ,31 + ,69551 + ,2289 + ,110681 + ,56 + ,689 + ,21 + ,29653 + ,817 + ,81299 + ,29 + ,208 + ,21 + ,38071 + ,340 + ,31970 + ,15 + ,101 + ,21 + ,4157 + ,2354 + ,185321 + ,101 + ,809 + ,15 + ,28321 + ,992 + ,87611 + ,51 + ,293 + ,9 + ,40195 + ,976 + ,73021 + ,50 + ,327 + ,21 + ,48158 + ,1357 + ,82167 + ,56 + ,405 + ,18 + ,13310 + ,1958 + ,101152 + ,42 + ,508 + ,27 + ,78474 + ,933 + ,49164 + ,29 + ,248 + ,24 + ,6386 + ,1600 + ,105181 + ,48 + ,424 + ,22 + ,31588 + ,1821 + ,105922 + ,71 + ,628 + ,21 + ,61254 + ,816 + ,60138 + ,23 + ,253 + ,21 + ,21152 + ,1121 + ,73422 + ,66 + ,366 + ,26 + ,41272 + ,800 + ,67727 + ,54 + ,190 + ,22 + ,34165 + ,1446 + ,188098 + ,45 + ,515 + ,22 + ,37054 + ,750 + ,51185 + ,23 + ,221 + ,20 + ,12368 + ,1171 + ,84448 + ,28 + ,404 + ,21 + ,23168 + ,662 + ,41956 + ,35 + ,219 + ,19 + ,16380 + ,1284 + ,110827 + ,40 + ,377 + ,19 + ,41242 + ,1980 + ,167055 + ,175 + ,427 + ,25 + ,48259 + ,879 + ,63603 + ,78 + ,209 + ,19 + ,20790 + ,869 + ,64995 + ,42 + ,276 + ,21 + ,34585 + ,1000 + ,93424 + ,36 + ,382 + ,18 + ,35672 + ,1240 + ,97229 + ,32 + ,446 + ,23 + ,52168 + ,1771 + ,112819 + ,60 + ,521 + ,18 + ,53933 + ,917 + ,106460 + ,49 + ,295 + ,19 + ,34474 + ,1042 + ,102220 + ,50 + ,382 + ,12 + ,43753 + ,629 + ,38721 + ,30 + ,253 + ,9 + ,36456 + ,1770 + ,168764 + ,85 + ,569 + ,26 + ,51183 + ,1454 + ,151588 + ,46 + ,441 + ,21 + ,52742 + ,222 + ,19349 + ,11 + ,67 + ,1 + ,3895 + ,1529 + ,125440 + ,77 + ,504 + ,24 + ,37076 + ,1303 + ,101954 + ,48 + ,523 + ,18 + ,24079 + ,552 + ,43803 + ,24 + ,240 + ,4 + ,2325 + ,708 + ,47062 + ,19 + ,219 + ,15 + ,29354 + ,998 + ,104220 + ,43 + ,329 + ,19 + ,30341 + ,872 + ,85939 + ,50 + ,217 + ,20 + ,18992 + ,584 + ,58660 + ,35 + ,136 + ,12 + ,15292 + ,596 + ,27676 + ,22 + ,194 + ,16 + ,5842 + ,926 + ,93448 + ,31 + ,209 + ,21 + ,28918 + ,576 + ,43284 + ,22 + ,151 + ,9 + ,3738 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,868 + ,64333 + ,23 + ,237 + ,21 + ,95352 + ,736 + ,57050 + ,46 + ,236 + ,17 + ,37478 + ,998 + ,96933 + ,34 + ,323 + ,18 + ,26839 + ,915 + ,70088 + ,46 + ,296 + ,21 + ,26783 + ,782 + ,65494 + ,55 + ,267 + ,17 + ,33392 + ,78 + ,3616 + ,5 + ,14 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,782 + ,135104 + ,33 + ,261 + ,19 + ,25446 + ,1159 + ,95554 + ,60 + ,391 + ,26 + ,60038 + ,1646 + ,120307 + ,77 + ,469 + ,25 + ,28162 + ,749 + ,84336 + ,32 + ,243 + ,20 + ,33298 + ,778 + ,43410 + ,19 + ,292 + ,1 + ,2781 + ,1335 + ,131452 + ,55 + ,400 + ,21 + ,37121 + ,806 + ,79015 + ,33 + ,217 + ,14 + ,22698 + ,1390 + ,88043 + ,40 + ,392 + ,24 + ,27615 + ,680 + ,57578 + ,36 + ,160 + ,12 + ,32689 + ,285 + ,19764 + ,12 + ,75 + ,2 + ,5752 + ,1335 + ,105757 + ,41 + ,412 + ,16 + ,23164 + ,840 + ,96410 + ,22 + ,293 + ,22 + ,20304 + ,1230 + ,105056 + ,30 + ,401 + ,28 + ,34409 + ,256 + ,11796 + ,9 + ,79 + ,2 + ,0 + ,80 + ,7627 + ,8 + ,25 + ,0 + ,0 + ,1162 + ,117413 + ,47 + ,412 + ,17 + ,92538 + ,41 + ,6836 + ,3 + ,11 + ,1 + ,0 + ,1540 + ,131955 + ,37 + ,539 + ,17 + ,46037 + ,42 + ,5118 + ,3 + ,6 + ,0 + ,0 + ,528 + ,40248 + ,16 + ,183 + ,4 + ,5444 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,799 + ,77813 + ,38 + ,281 + ,21 + ,23924 + ,1086 + ,67140 + ,28 + ,196 + ,24 + ,52230 + ,81 + ,7131 + ,4 + ,27 + ,0 + ,0 + ,61 + ,4194 + ,11 + ,14 + ,0 + ,0 + ,849 + ,60378 + ,20 + ,240 + ,15 + ,8019 + ,970 + ,96971 + ,40 + ,233 + ,18 + ,34542 + ,964 + ,83484 + ,16 + ,347 + ,19 + ,21157) + ,dim=c(6 + ,144) + ,dimnames=list(c('Time' + ,'pageviews' + ,'logins' + ,'compendiumviews' + ,'reviewedcompendiums' + ,'caracters') + ,1:144)) > y <- array(NA,dim=c(6,144),dimnames=list(c('Time','pageviews','logins','compendiumviews','reviewedcompendiums','caracters'),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 = '7' > par2 = 'none' > par1 = '2' > #'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 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] "pageviews" > x[,par1] [1] 118540 127145 7215 112861 197581 377410 117604 120102 96175 253517 [11] 108994 156212 68810 149246 125503 125769 123467 56088 108128 22762 [21] 48554 159102 139108 92058 126311 113807 133994 131810 279065 158146 [31] 107352 149827 90912 169510 162204 0 163310 92342 98357 178277 [41] 134927 104577 81614 119111 83923 109885 52851 153621 152572 114073 [51] 48188 90994 215588 176489 138871 104416 156186 60368 95391 126048 [61] 96388 77353 79872 79772 96945 88300 126203 110681 81299 31970 [71] 185321 87611 73021 82167 101152 49164 105181 105922 60138 73422 [81] 67727 188098 51185 84448 41956 110827 167055 63603 64995 93424 [91] 97229 112819 106460 102220 38721 168764 151588 19349 125440 101954 [101] 43803 47062 104220 85939 58660 27676 93448 43284 0 64333 [111] 57050 96933 70088 65494 3616 0 135104 95554 120307 84336 [121] 43410 131452 79015 88043 57578 19764 105757 96410 105056 11796 [131] 7627 117413 6836 131955 5118 40248 0 77813 67140 7131 [141] 4194 60378 96971 83484 > 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 4194 5118 6836 7131 7215 7627 11796 19349 19764 4 1 1 1 1 1 1 1 1 1 1 22762 27676 31970 38721 40248 41956 43284 43410 43803 47062 48188 1 1 1 1 1 1 1 1 1 1 1 48554 49164 51185 52851 56088 57050 57578 58660 60138 60368 60378 1 1 1 1 1 1 1 1 1 1 1 63603 64333 64995 65494 67140 67727 68810 70088 73021 73422 77353 1 1 1 1 1 1 1 1 1 1 1 77813 79015 79772 79872 81299 81614 82167 83484 83923 84336 84448 1 1 1 1 1 1 1 1 1 1 1 85939 87611 88043 88300 90912 90994 92058 92342 93424 93448 95391 1 1 1 1 1 1 1 1 1 1 1 95554 96175 96388 96410 96933 96945 96971 97229 98357 101152 101954 1 1 1 1 1 1 1 1 1 1 1 102220 104220 104416 104577 105056 105181 105757 105922 106460 107352 108128 1 1 1 1 1 1 1 1 1 1 1 108994 109885 110681 110827 112819 112861 113807 114073 117413 117604 118540 1 1 1 1 1 1 1 1 1 1 1 119111 120102 120307 123467 125440 125503 125769 126048 126203 126311 127145 1 1 1 1 1 1 1 1 1 1 1 131452 131810 131955 133994 134927 135104 138871 139108 149246 149827 151588 1 1 1 1 1 1 1 1 1 1 1 152572 153621 156186 156212 158146 159102 162204 163310 167055 168764 169510 1 1 1 1 1 1 1 1 1 1 1 176489 178277 185321 188098 197581 215588 253517 279065 377410 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "Time" "pageviews" "logins" [4] "compendiumviews" "reviewedcompendiums" "caracters" > colnames(x)[par1] [1] "pageviews" > x[,par1] [1] 118540 127145 7215 112861 197581 377410 117604 120102 96175 253517 [11] 108994 156212 68810 149246 125503 125769 123467 56088 108128 22762 [21] 48554 159102 139108 92058 126311 113807 133994 131810 279065 158146 [31] 107352 149827 90912 169510 162204 0 163310 92342 98357 178277 [41] 134927 104577 81614 119111 83923 109885 52851 153621 152572 114073 [51] 48188 90994 215588 176489 138871 104416 156186 60368 95391 126048 [61] 96388 77353 79872 79772 96945 88300 126203 110681 81299 31970 [71] 185321 87611 73021 82167 101152 49164 105181 105922 60138 73422 [81] 67727 188098 51185 84448 41956 110827 167055 63603 64995 93424 [91] 97229 112819 106460 102220 38721 168764 151588 19349 125440 101954 [101] 43803 47062 104220 85939 58660 27676 93448 43284 0 64333 [111] 57050 96933 70088 65494 3616 0 135104 95554 120307 84336 [121] 43410 131452 79015 88043 57578 19764 105757 96410 105056 11796 [131] 7627 117413 6836 131955 5118 40248 0 77813 67140 7131 [141] 4194 60378 96971 83484 > 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/15jn31323870528.tab") + } + } > m Conditional inference tree with 6 terminal nodes Response: pageviews Inputs: Time, logins, compendiumviews, reviewedcompendiums, caracters Number of observations: 144 1) Time <= 992; criterion = 1, statistic = 110.37 2) Time <= 662; criterion = 1, statistic = 46.233 3) Time <= 285; criterion = 1, statistic = 20.158 4)* weights = 14 3) Time > 285 5)* weights = 11 2) Time > 662 6)* weights = 37 1) Time > 992 7) Time <= 2164; criterion = 1, statistic = 45.4 8) compendiumviews <= 490; criterion = 1, statistic = 16.544 9)* weights = 44 8) compendiumviews > 490 10)* weights = 29 7) Time > 2164 11)* weights = 9 > postscript(file="/var/wessaorg/rcomp/tmp/2emb21323870528.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/3uxoz1323870528.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 118540 109075.773 9464.2273 2 127145 109075.773 18069.2273 3 7215 6617.571 597.4286 4 112861 137658.690 -24797.6897 5 197581 205375.444 -7794.4444 6 377410 205375.444 172034.5556 7 117604 109075.773 8528.2273 8 120102 109075.773 11026.2273 9 96175 109075.773 -12900.7727 10 253517 205375.444 48141.5556 11 108994 137658.690 -28664.6897 12 156212 137658.690 18553.3103 13 68810 109075.773 -40265.7727 14 149246 205375.444 -56129.4444 15 125503 109075.773 16427.2273 16 125769 109075.773 16693.2273 17 123467 109075.773 14391.2273 18 56088 75554.811 -19466.8108 19 108128 137658.690 -29530.6897 20 22762 40919.909 -18157.9091 21 48554 75554.811 -27000.8108 22 159102 137658.690 21443.3103 23 139108 137658.690 1449.3103 24 92058 137658.690 -45600.6897 25 126311 137658.690 -11347.6897 26 113807 109075.773 4731.2273 27 133994 137658.690 -3664.6897 28 131810 109075.773 22734.2273 29 279065 205375.444 73689.5556 30 158146 137658.690 20487.3103 31 107352 109075.773 -1723.7727 32 149827 109075.773 40751.2273 33 90912 137658.690 -46746.6897 34 169510 205375.444 -35865.4444 35 162204 137658.690 24545.3103 36 0 6617.571 -6617.5714 37 163310 137658.690 25651.3103 38 92342 109075.773 -16733.7727 39 98357 109075.773 -10718.7727 40 178277 137658.690 40618.3103 41 134927 137658.690 -2731.6897 42 104577 109075.773 -4498.7727 43 81614 75554.811 6059.1892 44 119111 137658.690 -18547.6897 45 83923 75554.811 8368.1892 46 109885 75554.811 34330.1892 47 52851 40919.909 11931.0909 48 153621 137658.690 15962.3103 49 152572 137658.690 14913.3103 50 114073 137658.690 -23585.6897 51 48188 40919.909 7268.0909 52 90994 109075.773 -18081.7727 53 215588 137658.690 77929.3103 54 176489 137658.690 38830.3103 55 138871 109075.773 29795.2273 56 104416 109075.773 -4659.7727 57 156186 109075.773 47110.2273 58 60368 75554.811 -15186.8108 59 95391 75554.811 19836.1892 60 126048 205375.444 -79327.4444 61 96388 109075.773 -12687.7727 62 77353 109075.773 -31722.7727 63 79872 75554.811 4317.1892 64 79772 75554.811 4217.1892 65 96945 75554.811 21390.1892 66 88300 109075.773 -20775.7727 67 126203 109075.773 17127.2273 68 110681 205375.444 -94694.4444 69 81299 75554.811 5744.1892 70 31970 40919.909 -8949.9091 71 185321 205375.444 -20054.4444 72 87611 75554.811 12056.1892 73 73021 75554.811 -2533.8108 74 82167 109075.773 -26908.7727 75 101152 137658.690 -36506.6897 76 49164 75554.811 -26390.8108 77 105181 109075.773 -3894.7727 78 105922 137658.690 -31736.6897 79 60138 75554.811 -15416.8108 80 73422 109075.773 -35653.7727 81 67727 75554.811 -7827.8108 82 188098 137658.690 50439.3103 83 51185 75554.811 -24369.8108 84 84448 109075.773 -24627.7727 85 41956 40919.909 1036.0909 86 110827 109075.773 1751.2273 87 167055 109075.773 57979.2273 88 63603 75554.811 -11951.8108 89 64995 75554.811 -10559.8108 90 93424 109075.773 -15651.7727 91 97229 109075.773 -11846.7727 92 112819 137658.690 -24839.6897 93 106460 75554.811 30905.1892 94 102220 109075.773 -6855.7727 95 38721 40919.909 -2198.9091 96 168764 137658.690 31105.3103 97 151588 109075.773 42512.2273 98 19349 6617.571 12731.4286 99 125440 137658.690 -12218.6897 100 101954 137658.690 -35704.6897 101 43803 40919.909 2883.0909 102 47062 75554.811 -28492.8108 103 104220 109075.773 -4855.7727 104 85939 75554.811 10384.1892 105 58660 40919.909 17740.0909 106 27676 40919.909 -13243.9091 107 93448 75554.811 17893.1892 108 43284 40919.909 2364.0909 109 0 6617.571 -6617.5714 110 64333 75554.811 -11221.8108 111 57050 75554.811 -18504.8108 112 96933 109075.773 -12142.7727 113 70088 75554.811 -5466.8108 114 65494 75554.811 -10060.8108 115 3616 6617.571 -3001.5714 116 0 6617.571 -6617.5714 117 135104 75554.811 59549.1892 118 95554 109075.773 -13521.7727 119 120307 109075.773 11231.2273 120 84336 75554.811 8781.1892 121 43410 75554.811 -32144.8108 122 131452 109075.773 22376.2273 123 79015 75554.811 3460.1892 124 88043 109075.773 -21032.7727 125 57578 75554.811 -17976.8108 126 19764 6617.571 13146.4286 127 105757 109075.773 -3318.7727 128 96410 75554.811 20855.1892 129 105056 109075.773 -4019.7727 130 11796 6617.571 5178.4286 131 7627 6617.571 1009.4286 132 117413 109075.773 8337.2273 133 6836 6617.571 218.4286 134 131955 137658.690 -5703.6897 135 5118 6617.571 -1499.5714 136 40248 40919.909 -671.9091 137 0 6617.571 -6617.5714 138 77813 75554.811 2258.1892 139 67140 109075.773 -41935.7727 140 7131 6617.571 513.4286 141 4194 6617.571 -2423.5714 142 60378 75554.811 -15176.8108 143 96971 75554.811 21416.1892 144 83484 75554.811 7929.1892 > 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/44g3a1323870528.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/5lv581323870528.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/6532n1323870528.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/7zdj01323870528.tab") + } > > try(system("convert tmp/2emb21323870528.ps tmp/2emb21323870528.png",intern=TRUE)) character(0) > try(system("convert tmp/3uxoz1323870528.ps tmp/3uxoz1323870528.png",intern=TRUE)) character(0) > try(system("convert tmp/44g3a1323870528.ps tmp/44g3a1323870528.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.676 0.235 3.906