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(38 + ,1724 + ,270018 + ,90 + ,476 + ,140824 + ,165 + ,3 + ,34 + ,1209 + ,179444 + ,63 + ,429 + ,110459 + ,135 + ,4 + ,42 + ,1844 + ,222373 + ,59 + ,673 + ,105079 + ,121 + ,16 + ,38 + ,2683 + ,218443 + ,135 + ,1137 + ,112098 + ,148 + ,2 + ,27 + ,1149 + ,162874 + ,48 + ,348 + ,43929 + ,73 + ,1 + ,35 + ,631 + ,70849 + ,46 + ,179 + ,76173 + ,49 + ,3 + ,33 + ,4513 + ,498732 + ,109 + ,2201 + ,187326 + ,185 + ,0 + ,18 + ,381 + ,33186 + ,46 + ,111 + ,22807 + ,5 + ,0 + ,34 + ,1997 + ,207822 + ,75 + ,735 + ,144408 + ,125 + ,7 + ,33 + ,1758 + ,213274 + ,72 + ,595 + ,66485 + ,93 + ,0 + ,44 + ,2079 + ,298841 + ,80 + ,780 + ,79089 + ,154 + ,0 + ,55 + ,2128 + ,237633 + ,61 + ,660 + ,81625 + ,98 + ,7 + ,37 + ,1659 + ,164107 + ,60 + ,633 + ,68788 + ,70 + ,8 + ,52 + ,2934 + ,358752 + ,114 + ,1163 + ,103297 + ,148 + ,4 + ,43 + ,1944 + ,222781 + ,46 + ,622 + ,69446 + ,100 + ,10 + ,59 + ,4764 + ,369889 + ,127 + ,1650 + ,114948 + ,150 + ,0 + ,36 + ,2122 + ,305704 + ,58 + ,746 + ,167949 + ,197 + ,6 + ,39 + ,2956 + ,322896 + ,90 + ,1157 + ,125081 + ,114 + ,4 + ,29 + ,1438 + ,176082 + ,41 + ,507 + ,125818 + ,169 + ,3 + ,49 + ,2320 + ,263411 + ,62 + ,683 + ,136588 + ,200 + ,8 + ,45 + ,2471 + ,271965 + ,99 + ,828 + ,112431 + ,148 + ,0 + ,39 + ,2769 + ,425544 + ,101 + ,1203 + ,103037 + ,140 + ,1 + ,25 + ,1442 + ,179306 + ,62 + ,461 + ,82317 + ,74 + ,5 + ,52 + ,1717 + ,189897 + ,65 + ,601 + ,118906 + ,128 + ,9 + ,41 + ,3220 + ,220665 + ,150 + ,1201 + ,83515 + ,140 + ,1 + ,38 + ,2733 + ,214779 + ,72 + ,990 + ,104581 + ,116 + ,0 + ,41 + ,2824 + ,267198 + ,91 + ,1061 + ,103129 + ,147 + ,5 + ,43 + ,1968 + ,270750 + ,73 + ,617 + ,83243 + ,132 + ,0 + ,32 + ,1495 + ,155915 + ,53 + ,559 + ,37110 + ,70 + ,0 + ,41 + ,2745 + ,330118 + ,140 + ,1031 + ,113344 + ,144 + ,0 + ,46 + ,2290 + ,281588 + ,50 + ,911 + ,139165 + ,155 + ,3 + ,49 + ,1830 + ,204039 + ,83 + ,615 + ,86652 + ,165 + ,6 + ,48 + ,2090 + ,318563 + ,53 + ,779 + ,112302 + ,161 + ,1 + ,37 + ,945 + ,97717 + ,40 + ,310 + ,69652 + ,31 + ,4 + ,39 + ,3092 + ,369331 + ,72 + ,1198 + ,119442 + ,199 + ,4 + ,42 + ,2764 + ,273950 + ,87 + ,1186 + ,69867 + ,78 + ,0 + ,43 + ,3658 + ,422946 + ,74 + ,1317 + ,101629 + ,121 + ,0 + ,36 + ,1842 + ,215710 + ,67 + ,611 + ,70168 + ,112 + ,2 + ,17 + ,934 + ,115469 + ,36 + ,276 + ,31081 + ,41 + ,1 + ,39 + ,3342 + ,343095 + ,45 + ,1185 + ,103925 + ,158 + ,2 + ,39 + ,3246 + ,324178 + ,42 + ,1490 + ,92622 + ,123 + ,10 + ,41 + ,1629 + ,170369 + ,75 + ,646 + ,79011 + ,104 + ,9 + ,36 + ,1735 + ,195153 + ,82 + ,635 + ,93487 + ,94 + ,5 + ,42 + ,1714 + ,173510 + ,85 + ,470 + ,64520 + ,73 + ,6 + ,45 + ,2496 + ,153778 + ,82 + ,1022 + ,93473 + ,52 + ,1 + ,41 + ,5501 + ,455168 + ,848 + ,2068 + ,114360 + ,71 + ,2 + ,26 + ,918 + ,78800 + ,57 + ,330 + ,33032 + ,21 + ,2 + ,52 + ,2228 + ,208051 + ,80 + ,648 + ,96125 + ,155 + ,0 + ,47 + ,3942 + ,334657 + ,116 + ,1342 + ,151911 + ,174 + ,10 + ,45 + ,2081 + ,175523 + ,68 + ,868 + ,89256 + ,136 + ,3 + ,40 + ,1816 + ,213060 + ,48 + ,559 + ,95671 + ,128 + ,0 + ,4 + ,496 + ,24188 + ,20 + ,218 + ,5950 + ,7 + ,0 + ,44 + ,2533 + ,372238 + ,81 + ,833 + ,149695 + ,165 + ,8 + ,18 + ,744 + ,65029 + ,21 + ,255 + ,32551 + ,21 + ,5 + ,14 + ,1161 + ,101097 + ,70 + ,454 + ,31701 + ,35 + ,3 + ,37 + ,3027 + ,279012 + ,125 + ,1108 + ,100087 + ,137 + ,1 + ,56 + ,2433 + ,302218 + ,80 + ,642 + ,169707 + ,174 + ,5 + ,39 + ,3576 + ,323514 + ,220 + ,1079 + ,150491 + ,257 + ,5 + ,42 + ,2606 + ,339837 + ,63 + ,1046 + ,120192 + ,207 + ,0 + ,36 + ,2175 + ,252529 + ,77 + ,822 + ,95893 + ,103 + ,12 + ,46 + ,3937 + ,370483 + ,65 + ,1298 + ,151715 + ,171 + ,10 + ,28 + ,3161 + ,303406 + ,146 + ,1143 + ,176225 + ,279 + ,12 + ,43 + ,2790 + ,250858 + ,72 + ,1124 + ,59900 + ,83 + ,11 + ,42 + ,2610 + ,264889 + ,59 + ,931 + ,104767 + ,130 + ,8 + ,37 + ,1426 + ,228595 + ,58 + ,557 + ,114799 + ,131 + ,2 + ,30 + ,1646 + ,216027 + ,58 + ,436 + ,72128 + ,126 + ,0 + ,35 + ,1867 + ,188780 + ,54 + ,566 + ,143592 + ,158 + ,6 + ,44 + ,2736 + ,237856 + ,89 + ,832 + ,89626 + ,138 + ,9 + ,36 + ,2277 + ,232765 + ,78 + ,834 + ,131072 + ,200 + ,2 + ,28 + ,1675 + ,175699 + ,62 + ,621 + ,126817 + ,104 + ,5 + ,45 + ,2537 + ,239314 + ,64 + ,865 + ,81351 + ,111 + ,13 + ,23 + ,893 + ,73566 + ,39 + ,385 + ,22618 + ,26 + ,6 + ,45 + ,2190 + ,242585 + ,58 + ,716 + ,88977 + ,115 + ,7 + ,38 + ,1694 + ,187167 + ,94 + ,705 + ,92059 + ,127 + ,2 + ,38 + ,1948 + ,191920 + ,61 + ,683 + ,81897 + ,140 + ,1 + ,45 + ,2314 + ,359644 + ,95 + ,982 + ,108146 + ,121 + ,4 + ,36 + ,2645 + ,341637 + ,48 + ,1056 + ,126372 + ,183 + ,3 + ,41 + ,1804 + ,206059 + ,50 + ,522 + ,249771 + ,68 + ,6 + ,38 + ,2250 + ,201783 + ,58 + ,690 + ,71154 + ,112 + ,2 + ,37 + ,1787 + ,182231 + ,67 + ,644 + ,71571 + ,103 + ,0 + ,28 + ,1678 + ,153613 + ,41 + ,622 + ,55918 + ,63 + ,1 + ,45 + ,4009 + ,454794 + ,114 + ,1226 + ,160141 + ,166 + ,0 + ,26 + ,1369 + ,145943 + ,45 + ,653 + ,38692 + ,38 + ,5 + ,44 + ,2306 + ,280343 + ,57 + ,656 + ,102812 + ,163 + ,2 + ,8 + ,870 + ,80953 + ,31 + ,437 + ,56622 + ,59 + ,0 + ,27 + ,1966 + ,150216 + ,175 + ,822 + ,15986 + ,27 + ,0 + ,36 + ,1338 + ,156923 + ,68 + ,390 + ,123534 + ,108 + ,6 + ,37 + ,3731 + ,365448 + ,278 + ,1467 + ,108535 + ,88 + ,1 + ,57 + ,2617 + ,318651 + ,91 + ,907 + ,93879 + ,92 + ,0 + ,45 + ,3085 + ,179797 + ,72 + ,1044 + ,144551 + ,170 + ,1 + ,37 + ,2312 + ,251466 + ,58 + ,786 + ,56750 + ,98 + ,1 + ,38 + ,2136 + ,254506 + ,71 + ,655 + ,127654 + ,205 + ,3 + ,31 + ,1808 + ,185890 + ,86 + ,590 + ,65594 + ,96 + ,9 + ,36 + ,2992 + ,263577 + ,89 + ,1072 + ,59938 + ,107 + ,1 + ,36 + ,2474 + ,314255 + ,134 + ,947 + ,146975 + ,150 + ,4 + ,36 + ,1624 + ,189252 + ,64 + ,555 + ,143372 + ,123 + ,3 + ,35 + ,1606 + ,222504 + ,72 + ,552 + ,168553 + ,176 + ,5 + ,39 + ,2091 + ,285198 + ,61 + ,771 + ,183500 + ,213 + ,0 + ,65 + ,3930 + ,376927 + ,130 + ,1291 + ,165986 + ,208 + ,12 + ,30 + ,3705 + ,397681 + ,73 + ,1415 + ,184923 + ,307 + ,13 + ,51 + ,2676 + ,287015 + ,83 + ,846 + ,140358 + ,125 + ,8 + ,41 + ,2296 + ,285330 + ,85 + ,838 + ,149959 + ,208 + ,0 + ,36 + ,1997 + ,186856 + ,116 + ,640 + ,57224 + ,73 + ,0 + ,19 + ,602 + ,43287 + ,43 + ,214 + ,43750 + ,49 + ,4 + ,23 + ,2146 + ,185468 + ,85 + ,716 + ,48029 + ,82 + ,4 + ,40 + ,2157 + ,222268 + ,72 + ,755 + ,104978 + ,206 + ,0 + ,40 + ,2549 + ,259692 + ,110 + ,1140 + ,100046 + ,112 + ,0 + ,40 + ,2649 + ,301614 + ,55 + ,1030 + ,101047 + ,139 + ,0 + ,30 + ,1110 + ,121726 + ,44 + ,356 + ,197426 + ,60 + ,0 + ,41 + ,3102 + ,154165 + ,79 + ,906 + ,160902 + ,70 + ,0 + ,40 + ,1861 + ,306952 + ,58 + ,606 + ,147172 + ,112 + ,4 + ,45 + ,2295 + ,297982 + ,70 + ,684 + ,109432 + ,142 + ,0 + ,1 + ,398 + ,23623 + ,9 + ,156 + ,1168 + ,11 + ,0 + ,40 + ,2205 + ,195817 + ,54 + ,779 + ,83248 + ,130 + ,0 + ,11 + ,530 + ,61857 + ,25 + ,192 + ,25162 + ,31 + ,4 + ,45 + ,1596 + ,163766 + ,107 + ,457 + ,45724 + ,132 + ,0 + ,38 + ,2949 + ,384053 + ,63 + ,1162 + ,110529 + ,219 + ,1 + ,0 + ,387 + ,21054 + ,2 + ,146 + ,855 + ,4 + ,0 + ,30 + ,2137 + ,252805 + ,67 + ,866 + ,101382 + ,102 + ,5 + ,8 + ,492 + ,31961 + ,22 + ,200 + ,14116 + ,39 + ,0 + ,39 + ,3397 + ,311281 + ,153 + ,1211 + ,89506 + ,125 + ,3 + ,48 + ,2089 + ,240153 + ,79 + ,696 + ,135356 + ,121 + ,7 + ,48 + ,1638 + ,174892 + ,112 + ,485 + ,116066 + ,42 + ,13 + ,29 + ,1685 + ,152043 + ,47 + ,670 + ,144244 + ,111 + ,3 + ,8 + ,568 + ,38214 + ,52 + ,276 + ,8773 + ,16 + ,0 + ,43 + ,1917 + ,199336 + ,113 + ,662 + ,102153 + ,70 + ,2 + ,52 + ,2759 + ,353021 + ,115 + ,1010 + ,117440 + ,162 + ,0 + ,53 + ,1288 + ,196269 + ,64 + ,445 + ,104128 + ,173 + ,0 + ,48 + ,3554 + ,403932 + ,134 + ,1564 + ,134238 + ,171 + ,4 + ,48 + ,2387 + ,316105 + ,120 + ,820 + ,134047 + ,172 + ,0 + ,50 + ,3328 + ,396725 + ,111 + ,1151 + ,279488 + ,254 + ,3 + ,40 + ,1250 + ,187992 + ,49 + ,473 + ,79756 + ,90 + ,0 + ,36 + ,1121 + ,102424 + ,55 + ,401 + ,66089 + ,50 + ,0 + ,40 + ,2867 + ,284271 + ,149 + ,949 + ,102070 + ,113 + ,4 + ,46 + ,4024 + ,401260 + ,155 + ,1429 + ,146760 + ,187 + ,4 + ,40 + ,1721 + ,137843 + ,104 + ,534 + ,154771 + ,16 + ,15 + ,46 + ,4061 + ,383703 + ,146 + ,1698 + ,165933 + ,175 + ,0 + ,39 + ,1830 + ,157429 + ,76 + ,689 + ,64593 + ,90 + ,4 + ,41 + ,1627 + ,236370 + ,83 + ,528 + ,92280 + ,140 + ,1 + ,46 + ,2535 + ,282399 + ,192 + ,897 + ,67150 + ,145 + ,1 + ,32 + ,1808 + ,217478 + ,69 + ,610 + ,128692 + ,141 + ,0 + ,39 + ,3873 + ,366774 + ,117 + ,1548 + ,124089 + ,125 + ,9 + ,39 + ,2181 + ,236660 + ,67 + ,759 + ,125386 + ,241 + ,1 + ,21 + ,2035 + ,173260 + ,37 + ,716 + ,37238 + ,16 + ,3 + ,45 + ,2960 + ,323545 + ,56 + ,955 + ,140015 + ,175 + ,11 + ,50 + ,1915 + ,168994 + ,122 + ,720 + ,150047 + ,132 + ,5 + ,36 + ,2604 + ,246745 + ,52 + ,1011 + ,154451 + ,154 + ,2 + ,44 + ,2633 + ,301703 + ,64 + ,818 + ,156349 + ,198 + ,1 + ,0 + ,2 + ,1 + ,0 + ,0 + ,0 + ,0 + ,9 + ,0 + ,207 + ,14688 + ,0 + ,85 + ,6023 + ,5 + ,0 + ,0 + ,5 + ,98 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,8 + ,455 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,37 + ,2030 + ,233143 + ,58 + ,699 + ,84601 + ,125 + ,2 + ,47 + ,3179 + ,372078 + ,118 + ,1052 + ,68946 + ,174 + ,3 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,4 + ,203 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,151 + ,7199 + ,0 + ,74 + ,1644 + ,6 + ,0 + ,5 + ,474 + ,46660 + ,7 + ,259 + ,6179 + ,13 + ,0 + ,1 + ,141 + ,17547 + ,3 + ,69 + ,3926 + ,3 + ,0 + ,43 + ,1047 + ,116678 + ,89 + ,285 + ,52789 + ,35 + ,0 + ,0 + ,29 + ,969 + ,0 + ,0 + ,0 + ,0 + ,0 + ,32 + ,1767 + ,201582 + ,48 + ,582 + ,100350 + ,80 + ,2) + ,dim=c(8 + ,164) + ,dimnames=list(c('Revieuw' + ,'Pagevieuws' + ,'Time' + ,'Compendiumvieuws_pr' + ,'Coursecompendium' + ,'CompendiumCharacters' + ,'Hyperlinks' + ,'shared') + ,1:164)) > y <- array(NA,dim=c(8,164),dimnames=list(c('Revieuw','Pagevieuws','Time','Compendiumvieuws_pr','Coursecompendium','CompendiumCharacters','Hyperlinks','shared'),1:164)) > 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] "Revieuw" > x[,par1] [1] 38 34 42 38 27 35 33 18 34 33 44 55 37 52 43 59 36 39 29 49 45 39 25 52 41 [26] 38 41 43 32 41 46 49 48 37 39 42 43 36 17 39 39 41 36 42 45 41 26 52 47 45 [51] 40 4 44 18 14 37 56 39 42 36 46 28 43 42 37 30 35 44 36 28 45 23 45 38 38 [76] 45 36 41 38 37 28 45 26 44 8 27 36 37 57 45 37 38 31 36 36 36 35 39 65 30 [101] 51 41 36 19 23 40 40 40 30 41 40 45 1 40 11 45 38 0 30 8 39 48 48 29 8 [126] 43 52 53 48 48 50 40 36 40 46 40 46 39 41 46 32 39 39 21 45 50 36 44 0 0 [151] 0 0 0 0 37 47 0 0 0 5 1 43 0 32 > 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 4 5 8 11 14 17 18 19 21 23 25 26 27 28 29 30 31 32 33 34 35 36 37 38 11 2 1 1 3 1 1 1 2 1 1 2 1 2 2 3 2 4 1 3 2 2 3 13 8 8 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 55 56 57 59 65 11 9 9 5 6 5 11 5 2 5 2 2 1 4 1 1 1 1 1 1 > colnames(x) [1] "Revieuw" "Pagevieuws" "Time" [4] "Compendiumvieuws_pr" "Coursecompendium" "CompendiumCharacters" [7] "Hyperlinks" "shared" > colnames(x)[par1] [1] "Revieuw" > x[,par1] [1] 38 34 42 38 27 35 33 18 34 33 44 55 37 52 43 59 36 39 29 49 45 39 25 52 41 [26] 38 41 43 32 41 46 49 48 37 39 42 43 36 17 39 39 41 36 42 45 41 26 52 47 45 [51] 40 4 44 18 14 37 56 39 42 36 46 28 43 42 37 30 35 44 36 28 45 23 45 38 38 [76] 45 36 41 38 37 28 45 26 44 8 27 36 37 57 45 37 38 31 36 36 36 35 39 65 30 [101] 51 41 36 19 23 40 40 40 30 41 40 45 1 40 11 45 38 0 30 8 39 48 48 29 8 [126] 43 52 53 48 48 50 40 36 40 46 40 46 39 41 46 32 39 39 21 45 50 36 44 0 0 [151] 0 0 0 0 37 47 0 0 0 5 1 43 0 32 > 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/1o8z01324154451.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: Revieuw Inputs: Pagevieuws, Time, Compendiumvieuws_pr, Coursecompendium, CompendiumCharacters, Hyperlinks, shared Number of observations: 164 1) Time <= 65029; criterion = 1, statistic = 92.038 2) CompendiumCharacters <= 6023; criterion = 1, statistic = 18.096 3)* weights = 14 2) CompendiumCharacters > 6023 4)* weights = 7 1) Time > 65029 5) Time <= 153613; criterion = 1, statistic = 30.138 6)* weights = 15 5) Time > 153613 7) Time <= 236660; criterion = 0.995, statistic = 11.455 8)* weights = 56 7) Time > 236660 9)* weights = 72 > postscript(file="/var/wessaorg/rcomp/tmp/2qmda1324154451.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/3nw5t1324154451.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 38 42.9027778 -4.90277778 2 34 38.0714286 -4.07142857 3 42 38.0714286 3.92857143 4 38 38.0714286 -0.07142857 5 27 38.0714286 -11.07142857 6 35 27.9333333 7.06666667 7 33 42.9027778 -9.90277778 8 18 12.4285714 5.57142857 9 34 38.0714286 -4.07142857 10 33 38.0714286 -5.07142857 11 44 42.9027778 1.09722222 12 55 42.9027778 12.09722222 13 37 38.0714286 -1.07142857 14 52 42.9027778 9.09722222 15 43 38.0714286 4.92857143 16 59 42.9027778 16.09722222 17 36 42.9027778 -6.90277778 18 39 42.9027778 -3.90277778 19 29 38.0714286 -9.07142857 20 49 42.9027778 6.09722222 21 45 42.9027778 2.09722222 22 39 42.9027778 -3.90277778 23 25 38.0714286 -13.07142857 24 52 38.0714286 13.92857143 25 41 38.0714286 2.92857143 26 38 38.0714286 -0.07142857 27 41 42.9027778 -1.90277778 28 43 42.9027778 0.09722222 29 32 38.0714286 -6.07142857 30 41 42.9027778 -1.90277778 31 46 42.9027778 3.09722222 32 49 38.0714286 10.92857143 33 48 42.9027778 5.09722222 34 37 27.9333333 9.06666667 35 39 42.9027778 -3.90277778 36 42 42.9027778 -0.90277778 37 43 42.9027778 0.09722222 38 36 38.0714286 -2.07142857 39 17 27.9333333 -10.93333333 40 39 42.9027778 -3.90277778 41 39 42.9027778 -3.90277778 42 41 38.0714286 2.92857143 43 36 38.0714286 -2.07142857 44 42 38.0714286 3.92857143 45 45 38.0714286 6.92857143 46 41 42.9027778 -1.90277778 47 26 27.9333333 -1.93333333 48 52 38.0714286 13.92857143 49 47 42.9027778 4.09722222 50 45 38.0714286 6.92857143 51 40 38.0714286 1.92857143 52 4 0.4285714 3.57142857 53 44 42.9027778 1.09722222 54 18 12.4285714 5.57142857 55 14 27.9333333 -13.93333333 56 37 42.9027778 -5.90277778 57 56 42.9027778 13.09722222 58 39 42.9027778 -3.90277778 59 42 42.9027778 -0.90277778 60 36 42.9027778 -6.90277778 61 46 42.9027778 3.09722222 62 28 42.9027778 -14.90277778 63 43 42.9027778 0.09722222 64 42 42.9027778 -0.90277778 65 37 38.0714286 -1.07142857 66 30 38.0714286 -8.07142857 67 35 38.0714286 -3.07142857 68 44 42.9027778 1.09722222 69 36 38.0714286 -2.07142857 70 28 38.0714286 -10.07142857 71 45 42.9027778 2.09722222 72 23 27.9333333 -4.93333333 73 45 42.9027778 2.09722222 74 38 38.0714286 -0.07142857 75 38 38.0714286 -0.07142857 76 45 42.9027778 2.09722222 77 36 42.9027778 -6.90277778 78 41 38.0714286 2.92857143 79 38 38.0714286 -0.07142857 80 37 38.0714286 -1.07142857 81 28 27.9333333 0.06666667 82 45 42.9027778 2.09722222 83 26 27.9333333 -1.93333333 84 44 42.9027778 1.09722222 85 8 27.9333333 -19.93333333 86 27 27.9333333 -0.93333333 87 36 38.0714286 -2.07142857 88 37 42.9027778 -5.90277778 89 57 42.9027778 14.09722222 90 45 38.0714286 6.92857143 91 37 42.9027778 -5.90277778 92 38 42.9027778 -4.90277778 93 31 38.0714286 -7.07142857 94 36 42.9027778 -6.90277778 95 36 42.9027778 -6.90277778 96 36 38.0714286 -2.07142857 97 35 38.0714286 -3.07142857 98 39 42.9027778 -3.90277778 99 65 42.9027778 22.09722222 100 30 42.9027778 -12.90277778 101 51 42.9027778 8.09722222 102 41 42.9027778 -1.90277778 103 36 38.0714286 -2.07142857 104 19 12.4285714 6.57142857 105 23 38.0714286 -15.07142857 106 40 38.0714286 1.92857143 107 40 42.9027778 -2.90277778 108 40 42.9027778 -2.90277778 109 30 27.9333333 2.06666667 110 41 38.0714286 2.92857143 111 40 42.9027778 -2.90277778 112 45 42.9027778 2.09722222 113 1 0.4285714 0.57142857 114 40 38.0714286 1.92857143 115 11 12.4285714 -1.42857143 116 45 38.0714286 6.92857143 117 38 42.9027778 -4.90277778 118 0 0.4285714 -0.42857143 119 30 42.9027778 -12.90277778 120 8 12.4285714 -4.42857143 121 39 42.9027778 -3.90277778 122 48 42.9027778 5.09722222 123 48 38.0714286 9.92857143 124 29 27.9333333 1.06666667 125 8 12.4285714 -4.42857143 126 43 38.0714286 4.92857143 127 52 42.9027778 9.09722222 128 53 38.0714286 14.92857143 129 48 42.9027778 5.09722222 130 48 42.9027778 5.09722222 131 50 42.9027778 7.09722222 132 40 38.0714286 1.92857143 133 36 27.9333333 8.06666667 134 40 42.9027778 -2.90277778 135 46 42.9027778 3.09722222 136 40 27.9333333 12.06666667 137 46 42.9027778 3.09722222 138 39 38.0714286 0.92857143 139 41 38.0714286 2.92857143 140 46 42.9027778 3.09722222 141 32 38.0714286 -6.07142857 142 39 42.9027778 -3.90277778 143 39 38.0714286 0.92857143 144 21 38.0714286 -17.07142857 145 45 42.9027778 2.09722222 146 50 38.0714286 11.92857143 147 36 42.9027778 -6.90277778 148 44 42.9027778 1.09722222 149 0 0.4285714 -0.42857143 150 0 0.4285714 -0.42857143 151 0 0.4285714 -0.42857143 152 0 0.4285714 -0.42857143 153 0 0.4285714 -0.42857143 154 0 0.4285714 -0.42857143 155 37 38.0714286 -1.07142857 156 47 42.9027778 4.09722222 157 0 0.4285714 -0.42857143 158 0 0.4285714 -0.42857143 159 0 0.4285714 -0.42857143 160 5 12.4285714 -7.42857143 161 1 0.4285714 0.57142857 162 43 27.9333333 15.06666667 163 0 0.4285714 -0.42857143 164 32 38.0714286 -6.07142857 > 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/4gkkj1324154451.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/5qji61324154451.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/6yds71324154451.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/7wih71324154451.tab") + } > > try(system("convert tmp/2qmda1324154451.ps tmp/2qmda1324154451.png",intern=TRUE)) character(0) > try(system("convert tmp/3nw5t1324154451.ps tmp/3nw5t1324154451.png",intern=TRUE)) character(0) > try(system("convert tmp/4gkkj1324154451.ps tmp/4gkkj1324154451.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.435 0.266 3.822