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' + ,'numberofcaracters') + ,1:144)) > y <- array(NA,dim=c(6,144),dimnames=list(c('time','pageviews','logins','compendiumviews','reviewedcompendiums','numberofcaracters'),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' > #'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] "time" > x[,par1] [1] 1407 1072 192 2032 3032 5519 1321 1034 1388 2552 1735 1788 1292 2362 1150 [16] 1374 1503 965 2164 633 837 1991 1450 1765 1612 1173 1602 1046 2176 1767 [31] 1167 1394 1733 2374 1852 1 1677 1505 1813 1648 1560 1301 784 1580 896 [46] 959 567 1519 1625 1817 658 1187 1863 1559 1340 1342 1505 669 814 2189 [61] 1291 1378 978 823 789 1134 1875 2289 817 340 2354 992 976 1357 1958 [76] 933 1600 1821 816 1121 800 1446 750 1171 662 1284 1980 879 869 1000 [91] 1240 1771 917 1042 629 1770 1454 222 1529 1303 552 708 998 872 584 [106] 596 926 576 0 868 736 998 915 782 78 0 782 1159 1646 749 [121] 778 1335 806 1390 680 285 1335 840 1230 256 80 1162 41 1540 42 [136] 528 0 799 1086 81 61 849 970 964 > 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 61 78 80 81 192 222 256 285 340 528 552 567 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 576 584 596 629 633 658 662 669 680 708 736 749 750 778 782 784 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 789 799 800 806 814 816 817 823 837 840 849 868 869 872 879 896 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 915 917 926 933 959 964 965 970 976 978 992 998 1000 1034 1042 1046 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1072 1086 1121 1134 1150 1159 1162 1167 1171 1173 1187 1230 1240 1284 1291 1292 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1301 1303 1321 1335 1340 1342 1357 1374 1378 1388 1390 1394 1407 1446 1450 1454 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1503 1505 1519 1529 1540 1559 1560 1580 1600 1602 1612 1625 1646 1648 1677 1733 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1735 1765 1767 1770 1771 1788 1813 1817 1821 1852 1863 1875 1958 1980 1991 2032 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2164 2176 2189 2289 2354 2362 2374 2552 3032 5519 1 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "time" "pageviews" "logins" [4] "compendiumviews" "reviewedcompendiums" "numberofcaracters" > colnames(x)[par1] [1] "time" > x[,par1] [1] 1407 1072 192 2032 3032 5519 1321 1034 1388 2552 1735 1788 1292 2362 1150 [16] 1374 1503 965 2164 633 837 1991 1450 1765 1612 1173 1602 1046 2176 1767 [31] 1167 1394 1733 2374 1852 1 1677 1505 1813 1648 1560 1301 784 1580 896 [46] 959 567 1519 1625 1817 658 1187 1863 1559 1340 1342 1505 669 814 2189 [61] 1291 1378 978 823 789 1134 1875 2289 817 340 2354 992 976 1357 1958 [76] 933 1600 1821 816 1121 800 1446 750 1171 662 1284 1980 879 869 1000 [91] 1240 1771 917 1042 629 1770 1454 222 1529 1303 552 708 998 872 584 [106] 596 926 576 0 868 736 998 915 782 78 0 782 1159 1646 749 [121] 778 1335 806 1390 680 285 1335 840 1230 256 80 1162 41 1540 42 [136] 528 0 799 1086 81 61 849 970 964 > 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/11xhh1323986049.tab") + } + } > m Conditional inference tree with 9 terminal nodes Response: time Inputs: pageviews, logins, compendiumviews, reviewedcompendiums, numberofcaracters Number of observations: 144 1) compendiumviews <= 347; criterion = 1, statistic = 132.46 2) compendiumviews <= 101; criterion = 1, statistic = 60.904 3)* weights = 15 2) compendiumviews > 101 4) pageviews <= 60368; criterion = 1, statistic = 25.698 5) compendiumviews <= 219; criterion = 0.989, statistic = 9.445 6)* weights = 11 5) compendiumviews > 219 7)* weights = 9 4) pageviews > 60368 8)* weights = 35 1) compendiumviews > 347 9) compendiumviews <= 680; criterion = 1, statistic = 61.351 10) compendiumviews <= 490; criterion = 1, statistic = 31.43 11) logins <= 36; criterion = 0.993, statistic = 10.301 12)* weights = 8 11) logins > 36 13)* weights = 28 10) compendiumviews > 490 14) compendiumviews <= 539; criterion = 0.982, statistic = 8.469 15)* weights = 14 14) compendiumviews > 539 16)* weights = 13 9) compendiumviews > 680 17)* weights = 11 > postscript(file="/var/wessaorg/rcomp/tmp/2thyt1323986049.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/3xot01323986049.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 1407 1410.9286 -3.9285714 2 1072 913.8857 158.1142857 3 192 111.9333 80.0666667 4 2032 1830.3077 201.6923077 5 3032 2571.9091 460.0909091 6 5519 2571.9091 2947.0909091 7 1321 1410.9286 -89.9285714 8 1034 913.8857 120.1142857 9 1388 1187.8750 200.1250000 10 2552 2571.9091 -19.9090909 11 1735 1830.3077 -95.3076923 12 1788 1830.3077 -42.3076923 13 1292 1410.9286 -118.9285714 14 2362 2571.9091 -209.9090909 15 1150 913.8857 236.1142857 16 1374 1410.9286 -36.9285714 17 1503 1410.9286 92.0714286 18 965 777.3333 187.6666667 19 2164 1830.3077 333.6923077 20 633 623.7273 9.2727273 21 837 777.3333 59.6666667 22 1991 1830.3077 160.6923077 23 1450 1588.5000 -138.5000000 24 1765 1588.5000 176.5000000 25 1612 1588.5000 23.5000000 26 1173 1187.8750 -14.8750000 27 1602 1588.5000 13.5000000 28 1046 913.8857 132.1142857 29 2176 2571.9091 -395.9090909 30 1767 2571.9091 -804.9090909 31 1167 1187.8750 -20.8750000 32 1394 1410.9286 -16.9285714 33 1733 1830.3077 -97.3076923 34 2374 2571.9091 -197.9090909 35 1852 1830.3077 21.6923077 36 1 111.9333 -110.9333333 37 1677 2571.9091 -894.9090909 38 1505 1410.9286 94.0714286 39 1813 1410.9286 402.0714286 40 1648 1830.3077 -182.3076923 41 1560 1588.5000 -28.5000000 42 1301 1410.9286 -109.9285714 43 784 913.8857 -129.8857143 44 1580 1830.3077 -250.3076923 45 896 913.8857 -17.8857143 46 959 913.8857 45.1142857 47 567 623.7273 -56.7272727 48 1519 1588.5000 -69.5000000 49 1625 1588.5000 36.5000000 50 1817 1830.3077 -13.3076923 51 658 623.7273 34.2727273 52 1187 913.8857 273.1142857 53 1863 1830.3077 32.6923077 54 1559 1588.5000 -29.5000000 55 1340 1410.9286 -70.9285714 56 1342 1410.9286 -68.9285714 57 1505 1410.9286 94.0714286 58 669 623.7273 45.2727273 59 814 913.8857 -99.8857143 60 2189 2571.9091 -382.9090909 61 1291 1410.9286 -119.9285714 62 1378 1410.9286 -32.9285714 63 978 913.8857 64.1142857 64 823 913.8857 -90.8857143 65 789 913.8857 -124.8857143 66 1134 1187.8750 -53.8750000 67 1875 1410.9286 464.0714286 68 2289 2571.9091 -282.9090909 69 817 913.8857 -96.8857143 70 340 111.9333 228.0666667 71 2354 2571.9091 -217.9090909 72 992 913.8857 78.1142857 73 976 913.8857 62.1142857 74 1357 1410.9286 -53.9285714 75 1958 1588.5000 369.5000000 76 933 777.3333 155.6666667 77 1600 1410.9286 189.0714286 78 1821 1830.3077 -9.3076923 79 816 777.3333 38.6666667 80 1121 1410.9286 -289.9285714 81 800 913.8857 -113.8857143 82 1446 1588.5000 -142.5000000 83 750 777.3333 -27.3333333 84 1171 1187.8750 -16.8750000 85 662 623.7273 38.2727273 86 1284 1410.9286 -126.9285714 87 1980 1410.9286 569.0714286 88 879 913.8857 -34.8857143 89 869 913.8857 -44.8857143 90 1000 1187.8750 -187.8750000 91 1240 1187.8750 52.1250000 92 1771 1588.5000 182.5000000 93 917 913.8857 3.1142857 94 1042 1410.9286 -368.9285714 95 629 777.3333 -148.3333333 96 1770 1830.3077 -60.3076923 97 1454 1410.9286 43.0714286 98 222 111.9333 110.0666667 99 1529 1588.5000 -59.5000000 100 1303 1588.5000 -285.5000000 101 552 777.3333 -225.3333333 102 708 623.7273 84.2727273 103 998 913.8857 84.1142857 104 872 913.8857 -41.8857143 105 584 623.7273 -39.7272727 106 596 623.7273 -27.7272727 107 926 913.8857 12.1142857 108 576 623.7273 -47.7272727 109 0 111.9333 -111.9333333 110 868 913.8857 -45.8857143 111 736 777.3333 -41.3333333 112 998 913.8857 84.1142857 113 915 913.8857 1.1142857 114 782 913.8857 -131.8857143 115 78 111.9333 -33.9333333 116 0 111.9333 -111.9333333 117 782 913.8857 -131.8857143 118 1159 1410.9286 -251.9285714 119 1646 1410.9286 235.0714286 120 749 913.8857 -164.8857143 121 778 777.3333 0.6666667 122 1335 1410.9286 -75.9285714 123 806 913.8857 -107.8857143 124 1390 1410.9286 -20.9285714 125 680 623.7273 56.2727273 126 285 111.9333 173.0666667 127 1335 1410.9286 -75.9285714 128 840 913.8857 -73.8857143 129 1230 1187.8750 42.1250000 130 256 111.9333 144.0666667 131 80 111.9333 -31.9333333 132 1162 1410.9286 -248.9285714 133 41 111.9333 -70.9333333 134 1540 1588.5000 -48.5000000 135 42 111.9333 -69.9333333 136 528 623.7273 -95.7272727 137 0 111.9333 -111.9333333 138 799 913.8857 -114.8857143 139 1086 913.8857 172.1142857 140 81 111.9333 -30.9333333 141 61 111.9333 -50.9333333 142 849 913.8857 -64.8857143 143 970 913.8857 56.1142857 144 964 913.8857 50.1142857 > 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/4ljhz1323986049.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/5wvys1323986049.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/6c94f1323986049.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/719h71323986049.tab") + } > > try(system("convert tmp/2thyt1323986049.ps tmp/2thyt1323986049.png",intern=TRUE)) character(0) > try(system("convert tmp/3xot01323986049.ps tmp/3xot01323986049.png",intern=TRUE)) character(0) > try(system("convert tmp/4ljhz1323986049.ps tmp/4ljhz1323986049.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.410 0.271 3.720