R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-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(1 + ,21.033 + ,0.02211 + ,0.414783 + ,0.815285 + ,1 + ,19.085 + ,0.01929 + ,0.458359 + ,0.819521 + ,1 + ,20.651 + ,0.01309 + ,0.429895 + ,0.825288 + ,1 + ,20.644 + ,0.01353 + ,0.434969 + ,0.819235 + ,1 + ,19.649 + ,0.01767 + ,0.417356 + ,0.823484 + ,1 + ,21.378 + ,0.01222 + ,0.415564 + ,0.825069 + ,1 + ,24.886 + ,0.00607 + ,0.59604 + ,0.764112 + ,1 + ,26.892 + ,0.00344 + ,0.63742 + ,0.763262 + ,1 + ,21.812 + ,0.0107 + ,0.615551 + ,0.773587 + ,1 + ,21.862 + ,0.01022 + ,0.547037 + ,0.798463 + ,1 + ,21.118 + ,0.01166 + ,0.611137 + ,0.776156 + ,1 + ,21.414 + ,0.01141 + ,0.58339 + ,0.79252 + ,1 + ,25.703 + ,0.00581 + ,0.4606 + ,0.646846 + ,1 + ,24.889 + ,0.01041 + ,0.430166 + ,0.665833 + ,1 + ,24.922 + ,0.00609 + ,0.474791 + ,0.654027 + ,1 + ,25.175 + ,0.00839 + ,0.565924 + ,0.658245 + ,1 + ,22.333 + ,0.01859 + ,0.56738 + ,0.644692 + ,1 + ,20.376 + ,0.02919 + ,0.631099 + ,0.605417 + ,1 + ,17.28 + ,0.0316 + ,0.665318 + ,0.719467 + ,1 + ,17.153 + ,0.03365 + ,0.649554 + ,0.68608 + ,1 + ,17.536 + ,0.03871 + ,0.660125 + ,0.704087 + ,1 + ,19.493 + ,0.01849 + ,0.629017 + ,0.698951 + ,1 + ,22.468 + ,0.0128 + ,0.61906 + ,0.679834 + ,1 + ,20.422 + ,0.0184 + ,0.537264 + ,0.686894 + ,1 + ,23.831 + ,0.01778 + ,0.397937 + ,0.732479 + ,1 + ,22.066 + ,0.02887 + ,0.522746 + ,0.737948 + ,1 + ,25.908 + ,0.01095 + ,0.418622 + ,0.720916 + ,1 + ,25.119 + ,0.01328 + ,0.358773 + ,0.726652 + ,1 + ,25.97 + ,0.00677 + ,0.470478 + ,0.676258 + ,1 + ,25.678 + ,0.0117 + ,0.427785 + ,0.723797 + ,0 + ,26.775 + ,0.00339 + ,0.422229 + ,0.741367 + ,0 + ,30.94 + ,0.00167 + ,0.432439 + ,0.742055 + ,0 + ,30.775 + ,0.00119 + ,0.465946 + ,0.738703 + ,0 + ,32.684 + ,0.00072 + ,0.368535 + ,0.742133 + ,0 + ,33.047 + ,0.00065 + ,0.340068 + ,0.741899 + ,0 + ,31.732 + ,0.00135 + ,0.344252 + ,0.742737 + ,1 + ,23.216 + ,0.00586 + ,0.360148 + ,0.778834 + ,1 + ,24.951 + ,0.0034 + ,0.341435 + ,0.783626 + ,1 + ,26.738 + ,0.00231 + ,0.403884 + ,0.766209 + ,1 + ,26.31 + ,0.00265 + ,0.396793 + ,0.758324 + ,1 + ,26.822 + ,0.00231 + ,0.32648 + ,0.765623 + ,1 + ,26.453 + ,0.00257 + ,0.306443 + ,0.759203 + ,0 + ,22.736 + ,0.0074 + ,0.305062 + ,0.654172 + ,0 + ,23.145 + ,0.00675 + ,0.457702 + ,0.634267 + ,0 + ,25.368 + ,0.00454 + ,0.438296 + ,0.635285 + ,0 + ,25.032 + ,0.00476 + ,0.431285 + ,0.638928 + ,0 + ,24.602 + ,0.00476 + ,0.467489 + ,0.631653 + ,0 + ,26.805 + ,0.00432 + ,0.610367 + ,0.635204 + ,0 + ,23.162 + ,0.00839 + ,0.579597 + ,0.733659 + ,0 + ,24.971 + ,0.00462 + ,0.538688 + ,0.754073 + ,0 + ,25.135 + ,0.00479 + ,0.553134 + ,0.775933 + ,0 + ,25.03 + ,0.00474 + ,0.507504 + ,0.760361 + ,0 + ,24.692 + ,0.00481 + ,0.459766 + ,0.766204 + ,0 + ,25.429 + ,0.00484 + ,0.420383 + ,0.785714 + ,1 + ,21.028 + ,0.01036 + ,0.536009 + ,0.819032 + ,1 + ,20.767 + ,0.0118 + ,0.558586 + ,0.811843 + ,1 + ,21.422 + ,0.00969 + ,0.541781 + ,0.821364 + ,1 + ,22.817 + ,0.00681 + ,0.530529 + ,0.817756 + ,1 + ,22.603 + ,0.00786 + ,0.540049 + ,0.813432 + ,1 + ,21.66 + ,0.01143 + ,0.547975 + ,0.817396 + ,0 + ,25.554 + ,0.00871 + ,0.341788 + ,0.678874 + ,0 + ,26.138 + ,0.00301 + ,0.447979 + ,0.686264 + ,0 + ,25.856 + ,0.0034 + ,0.364867 + ,0.694399 + ,0 + ,25.964 + ,0.00351 + ,0.25657 + ,0.683296 + ,0 + ,26.415 + ,0.003 + ,0.27685 + ,0.673636 + ,0 + ,24.547 + ,0.0042 + ,0.305429 + ,0.681811 + ,1 + ,19.56 + ,0.02183 + ,0.460139 + ,0.720908 + ,1 + ,19.979 + ,0.02659 + ,0.498133 + ,0.729067 + ,1 + ,20.338 + ,0.04882 + ,0.513237 + ,0.731444 + ,1 + ,21.718 + ,0.02431 + ,0.487407 + ,0.727313 + ,1 + ,20.264 + ,0.02599 + ,0.489345 + ,0.730387 + ,1 + ,18.57 + ,0.03361 + ,0.543299 + ,0.733232 + ,1 + ,25.742 + ,0.00442 + ,0.495954 + ,0.762959 + ,1 + ,24.178 + ,0.00623 + ,0.509127 + ,0.789532 + ,1 + ,25.438 + ,0.00479 + ,0.437031 + ,0.815908 + ,1 + ,25.197 + ,0.00472 + ,0.463514 + ,0.807217 + ,1 + ,23.37 + ,0.00905 + ,0.489538 + ,0.789977 + ,1 + ,25.82 + ,0.0042 + ,0.429484 + ,0.81634 + ,1 + ,21.875 + ,0.01062 + ,0.644954 + ,0.779612 + ,1 + ,19.2 + ,0.0222 + ,0.594387 + ,0.790117 + ,1 + ,19.055 + ,0.01823 + ,0.544805 + ,0.770466 + ,1 + ,19.659 + ,0.01825 + ,0.576084 + ,0.778747 + ,1 + ,20.536 + ,0.01237 + ,0.55461 + ,0.787896 + ,1 + ,22.244 + ,0.00882 + ,0.576644 + ,0.772416 + ,1 + ,13.893 + ,0.0547 + ,0.556494 + ,0.729586 + ,1 + ,16.176 + ,0.02782 + ,0.583574 + ,0.727747 + ,1 + ,15.924 + ,0.03151 + ,0.598714 + ,0.712199 + ,1 + ,13.922 + ,0.04824 + ,0.602874 + ,0.740837 + ,1 + ,14.739 + ,0.04214 + ,0.599371 + ,0.743937 + ,1 + ,11.866 + ,0.07223 + ,0.590951 + ,0.745526 + ,1 + ,11.744 + ,0.08725 + ,0.65341 + ,0.733165 + ,1 + ,19.664 + ,0.01658 + ,0.501037 + ,0.71436 + ,1 + ,18.78 + ,0.01914 + ,0.454444 + ,0.734504 + ,1 + ,20.969 + ,0.01211 + ,0.447456 + ,0.69779 + ,1 + ,22.219 + ,0.0085 + ,0.50238 + ,0.71217 + ,1 + ,21.693 + ,0.01018 + ,0.447285 + ,0.705658 + ,1 + ,22.663 + ,0.00852 + ,0.366329 + ,0.693429 + ,1 + ,15.338 + ,0.08151 + ,0.629574 + ,0.714485 + ,1 + ,15.433 + ,0.10323 + ,0.57101 + ,0.690892 + ,1 + ,12.435 + ,0.16744 + ,0.638545 + ,0.674953 + ,1 + ,8.867 + ,0.31482 + ,0.671299 + ,0.656846 + ,1 + ,15.06 + ,0.11843 + ,0.639808 + ,0.643327 + ,1 + ,10.489 + ,0.2593 + ,0.596362 + ,0.641418 + ,1 + ,26.759 + ,0.00495 + ,0.296888 + ,0.722356 + ,1 + ,28.409 + ,0.00243 + ,0.263654 + ,0.691483 + ,1 + ,27.421 + ,0.00578 + ,0.365488 + ,0.719974 + ,1 + ,29.746 + ,0.00233 + ,0.334171 + ,0.67793 + ,1 + ,26.833 + ,0.00659 + ,0.393563 + ,0.700246 + ,1 + ,29.928 + ,0.00238 + ,0.311369 + ,0.676066 + ,1 + ,21.934 + ,0.00947 + ,0.497554 + ,0.740539 + ,1 + ,23.239 + ,0.00704 + ,0.436084 + ,0.727863 + ,1 + ,22.407 + ,0.0083 + ,0.338097 + ,0.712466 + ,1 + ,21.305 + ,0.01316 + ,0.498877 + ,0.722085 + ,1 + ,23.671 + ,0.0062 + ,0.441097 + ,0.722254 + ,1 + ,21.864 + ,0.01048 + ,0.331508 + ,0.715121 + ,1 + ,23.693 + ,0.06051 + ,0.407701 + ,0.662668 + ,1 + ,26.356 + ,0.01554 + ,0.450798 + ,0.653823 + ,1 + ,25.69 + ,0.01802 + ,0.486738 + ,0.676023 + ,1 + ,25.02 + ,0.00856 + ,0.470422 + ,0.655239 + ,1 + ,24.581 + ,0.00681 + ,0.462516 + ,0.58271 + ,1 + ,24.743 + ,0.0235 + ,0.487756 + ,0.68413 + ,1 + ,27.166 + ,0.01161 + ,0.400088 + ,0.656182 + ,1 + ,18.305 + ,0.01968 + ,0.538016 + ,0.74148 + ,1 + ,18.784 + ,0.01813 + ,0.589956 + ,0.732903 + ,1 + ,19.196 + ,0.0202 + ,0.618663 + ,0.728421 + ,1 + ,18.857 + ,0.01874 + ,0.637518 + ,0.735546 + ,1 + ,18.178 + ,0.01794 + ,0.623209 + ,0.738245 + ,1 + ,18.33 + ,0.01796 + ,0.585169 + ,0.736964 + ,1 + ,26.842 + ,0.01724 + ,0.457541 + ,0.699787 + ,1 + ,26.369 + ,0.00487 + ,0.491345 + ,0.718839 + ,1 + ,23.949 + ,0.0161 + ,0.46716 + ,0.724045 + ,1 + ,26.017 + ,0.01015 + ,0.468621 + ,0.735136 + ,1 + ,23.389 + ,0.00903 + ,0.470972 + ,0.721308 + ,1 + ,25.619 + ,0.00504 + ,0.482296 + ,0.723096 + ,1 + ,17.06 + ,0.03031 + ,0.637814 + ,0.744064 + ,1 + ,17.707 + ,0.02529 + ,0.653427 + ,0.706687 + ,1 + ,19.013 + ,0.02278 + ,0.6479 + ,0.708144 + ,1 + ,16.747 + ,0.0369 + ,0.625362 + ,0.708617 + ,1 + ,17.366 + ,0.02629 + ,0.640945 + ,0.701404 + ,1 + ,18.801 + ,0.01827 + ,0.624811 + ,0.696049 + ,1 + ,18.54 + ,0.02485 + ,0.677131 + ,0.685057 + ,1 + ,15.648 + ,0.04238 + ,0.606344 + ,0.665945 + ,1 + ,18.702 + ,0.01728 + ,0.606273 + ,0.661735 + ,1 + ,18.687 + ,0.0201 + ,0.536102 + ,0.632631 + ,1 + ,20.68 + ,0.01049 + ,0.49748 + ,0.630409 + ,1 + ,20.366 + ,0.01493 + ,0.566849 + ,0.574282 + ,1 + ,12.359 + ,0.0753 + ,0.56161 + ,0.793509 + ,1 + ,14.367 + ,0.06057 + ,0.478024 + ,0.768974 + ,1 + ,12.298 + ,0.08069 + ,0.55287 + ,0.764036 + ,1 + ,14.989 + ,0.07889 + ,0.427627 + ,0.775708 + ,1 + ,12.529 + ,0.10952 + ,0.507826 + ,0.762726 + ,1 + ,8.441 + ,0.21713 + ,0.625866 + ,0.76832 + ,1 + ,9.449 + ,0.16265 + ,0.584164 + ,0.754449 + ,1 + ,21.52 + ,0.04179 + ,0.566867 + ,0.670475 + ,1 + ,21.824 + ,0.04611 + ,0.65168 + ,0.659333 + ,1 + ,22.431 + ,0.02631 + ,0.6283 + ,0.652025 + ,1 + ,22.953 + ,0.03191 + ,0.611679 + ,0.623731 + ,1 + ,19.075 + ,0.10748 + ,0.630547 + ,0.646786 + ,1 + ,21.534 + ,0.03828 + ,0.635015 + ,0.627337 + ,1 + ,19.651 + ,0.02663 + ,0.654945 + ,0.675865 + ,1 + ,20.437 + ,0.02073 + ,0.653139 + ,0.694571 + ,1 + ,19.388 + ,0.0281 + ,0.577802 + ,0.684373 + ,1 + ,18.954 + ,0.02707 + ,0.685151 + ,0.719576 + ,1 + ,21.219 + ,0.01435 + ,0.557045 + ,0.673086 + ,1 + ,18.447 + ,0.03882 + ,0.671378 + ,0.674562 + ,0 + ,24.078 + ,0.0062 + ,0.469928 + ,0.628232 + ,0 + ,24.679 + ,0.00533 + ,0.384868 + ,0.62671 + ,0 + ,21.083 + ,0.0091 + ,0.440988 + ,0.628058 + ,0 + ,19.269 + ,0.01337 + ,0.372222 + ,0.725216 + ,0 + ,21.02 + ,0.00965 + ,0.371837 + ,0.646167 + ,0 + ,21.528 + ,0.01049 + ,0.522812 + ,0.646818 + ,0 + ,26.436 + ,0.00435 + ,0.413295 + ,0.7567 + ,0 + ,26.55 + ,0.0043 + ,0.36909 + ,0.776158 + ,0 + ,26.547 + ,0.00478 + ,0.380253 + ,0.7667 + ,0 + ,25.445 + ,0.0059 + ,0.387482 + ,0.756482 + ,0 + ,26.005 + ,0.00401 + ,0.405991 + ,0.761255 + ,0 + ,26.143 + ,0.00415 + ,0.361232 + ,0.763242 + ,1 + ,24.151 + ,0.0057 + ,0.39661 + ,0.745957 + ,1 + ,24.412 + ,0.00488 + ,0.402591 + ,0.762508 + ,1 + ,23.683 + ,0.0054 + ,0.398499 + ,0.778349 + ,1 + ,23.133 + ,0.00611 + ,0.352396 + ,0.75932 + ,1 + ,22.866 + ,0.00639 + ,0.408598 + ,0.768845 + ,1 + ,23.008 + ,0.00595 + ,0.329577 + ,0.75718 + ,0 + ,23.079 + ,0.00955 + ,0.603515 + ,0.669565 + ,0 + ,22.085 + ,0.01179 + ,0.663842 + ,0.656516 + ,0 + ,24.199 + ,0.00737 + ,0.598515 + ,0.654331 + ,0 + ,23.958 + ,0.01397 + ,0.566424 + ,0.667654 + ,0 + ,25.023 + ,0.0068 + ,0.528485 + ,0.663884 + ,0 + ,24.775 + ,0.00703 + ,0.555303 + ,0.659132 + ,0 + ,19.368 + ,0.04441 + ,0.508479 + ,0.683761 + ,0 + ,19.517 + ,0.02764 + ,0.448439 + ,0.657899 + ,0 + ,19.147 + ,0.0181 + ,0.431674 + ,0.683244 + ,0 + ,17.883 + ,0.10715 + ,0.407567 + ,0.655683 + ,0 + ,19.02 + ,0.07223 + ,0.451221 + ,0.643956 + ,0 + ,21.209 + ,0.04398 + ,0.462803 + ,0.664357) + ,dim=c(5 + ,195) + ,dimnames=list(c('status' + ,'HNR' + ,'NHR' + ,'RPDE' + ,'DFA') + ,1:195)) > y <- array(NA,dim=c(5,195),dimnames=list(c('status','HNR','NHR','RPDE','DFA'),1:195)) > 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' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '1' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., 2012, Recursive Partitioning (Regression Trees) (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_regression_trees.wasp/ > #Source of accompanying publication: > # > 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 Attaching package: 'zoo' The following objects are masked from 'package:base': as.Date, as.Date.numeric Loading required package: sandwich Loading required package: strucchange Loading required package: vcd Loading required package: MASS Loading required package: colorspace > library(Hmisc) Hmisc library by Frank E Harrell Jr Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview') to see overall documentation. NOTE:Hmisc no longer redefines [.factor to drop unused levels when subsetting. To get the old behavior of Hmisc type dropUnusedLevels(). Attaching package: 'Hmisc' The following object is masked from 'package:survival': untangle.specials The following objects 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] "status" > x[,par1] [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 [38] 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [149] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 [186] 0 0 0 0 0 0 0 0 0 0 > 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 48 147 > colnames(x) [1] "status" "HNR" "NHR" "RPDE" "DFA" > colnames(x)[par1] [1] "status" > x[,par1] [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 [38] 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [149] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 [186] 0 0 0 0 0 0 0 0 0 0 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/1zu5j1386320251.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: status Inputs: HNR, NHR, RPDE, DFA Number of observations: 195 1) HNR <= 23.949; criterion = 1, statistic = 25.354 2) DFA <= 0.683761; criterion = 1, statistic = 16.073 3) RPDE <= 0.522812; criterion = 1, statistic = 14.873 4)* weights = 13 3) RPDE > 0.522812 5)* weights = 22 2) DFA > 0.683761 6)* weights = 89 1) HNR > 23.949 7) NHR <= 0.00484; criterion = 0.972, statistic = 7.284 8)* weights = 38 7) NHR > 0.00484 9)* weights = 33 > postscript(file="/var/fisher/rcomp/tmp/2yzkk1386320251.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/fisher/rcomp/tmp/3eycd1386320251.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 1 0.9775281 0.02247191 2 1 0.9775281 0.02247191 3 1 0.9775281 0.02247191 4 1 0.9775281 0.02247191 5 1 0.9775281 0.02247191 6 1 0.9775281 0.02247191 7 1 0.7575758 0.24242424 8 1 0.3421053 0.65789474 9 1 0.9775281 0.02247191 10 1 0.9775281 0.02247191 11 1 0.9775281 0.02247191 12 1 0.9775281 0.02247191 13 1 0.7575758 0.24242424 14 1 0.7575758 0.24242424 15 1 0.7575758 0.24242424 16 1 0.7575758 0.24242424 17 1 0.9090909 0.09090909 18 1 0.9090909 0.09090909 19 1 0.9775281 0.02247191 20 1 0.9775281 0.02247191 21 1 0.9775281 0.02247191 22 1 0.9775281 0.02247191 23 1 0.9090909 0.09090909 24 1 0.9775281 0.02247191 25 1 0.9775281 0.02247191 26 1 0.9775281 0.02247191 27 1 0.7575758 0.24242424 28 1 0.7575758 0.24242424 29 1 0.7575758 0.24242424 30 1 0.7575758 0.24242424 31 0 0.3421053 -0.34210526 32 0 0.3421053 -0.34210526 33 0 0.3421053 -0.34210526 34 0 0.3421053 -0.34210526 35 0 0.3421053 -0.34210526 36 0 0.3421053 -0.34210526 37 1 0.9775281 0.02247191 38 1 0.3421053 0.65789474 39 1 0.3421053 0.65789474 40 1 0.3421053 0.65789474 41 1 0.3421053 0.65789474 42 1 0.3421053 0.65789474 43 0 0.1538462 -0.15384615 44 0 0.1538462 -0.15384615 45 0 0.3421053 -0.34210526 46 0 0.3421053 -0.34210526 47 0 0.3421053 -0.34210526 48 0 0.3421053 -0.34210526 49 0 0.9775281 -0.97752809 50 0 0.3421053 -0.34210526 51 0 0.3421053 -0.34210526 52 0 0.3421053 -0.34210526 53 0 0.3421053 -0.34210526 54 0 0.3421053 -0.34210526 55 1 0.9775281 0.02247191 56 1 0.9775281 0.02247191 57 1 0.9775281 0.02247191 58 1 0.9775281 0.02247191 59 1 0.9775281 0.02247191 60 1 0.9775281 0.02247191 61 0 0.7575758 -0.75757576 62 0 0.3421053 -0.34210526 63 0 0.3421053 -0.34210526 64 0 0.3421053 -0.34210526 65 0 0.3421053 -0.34210526 66 0 0.3421053 -0.34210526 67 1 0.9775281 0.02247191 68 1 0.9775281 0.02247191 69 1 0.9775281 0.02247191 70 1 0.9775281 0.02247191 71 1 0.9775281 0.02247191 72 1 0.9775281 0.02247191 73 1 0.3421053 0.65789474 74 1 0.7575758 0.24242424 75 1 0.3421053 0.65789474 76 1 0.3421053 0.65789474 77 1 0.9775281 0.02247191 78 1 0.3421053 0.65789474 79 1 0.9775281 0.02247191 80 1 0.9775281 0.02247191 81 1 0.9775281 0.02247191 82 1 0.9775281 0.02247191 83 1 0.9775281 0.02247191 84 1 0.9775281 0.02247191 85 1 0.9775281 0.02247191 86 1 0.9775281 0.02247191 87 1 0.9775281 0.02247191 88 1 0.9775281 0.02247191 89 1 0.9775281 0.02247191 90 1 0.9775281 0.02247191 91 1 0.9775281 0.02247191 92 1 0.9775281 0.02247191 93 1 0.9775281 0.02247191 94 1 0.9775281 0.02247191 95 1 0.9775281 0.02247191 96 1 0.9775281 0.02247191 97 1 0.9775281 0.02247191 98 1 0.9775281 0.02247191 99 1 0.9775281 0.02247191 100 1 0.9090909 0.09090909 101 1 0.9090909 0.09090909 102 1 0.9090909 0.09090909 103 1 0.9090909 0.09090909 104 1 0.7575758 0.24242424 105 1 0.3421053 0.65789474 106 1 0.7575758 0.24242424 107 1 0.3421053 0.65789474 108 1 0.7575758 0.24242424 109 1 0.3421053 0.65789474 110 1 0.9775281 0.02247191 111 1 0.9775281 0.02247191 112 1 0.9775281 0.02247191 113 1 0.9775281 0.02247191 114 1 0.9775281 0.02247191 115 1 0.9775281 0.02247191 116 1 0.1538462 0.84615385 117 1 0.7575758 0.24242424 118 1 0.7575758 0.24242424 119 1 0.7575758 0.24242424 120 1 0.7575758 0.24242424 121 1 0.7575758 0.24242424 122 1 0.7575758 0.24242424 123 1 0.9775281 0.02247191 124 1 0.9775281 0.02247191 125 1 0.9775281 0.02247191 126 1 0.9775281 0.02247191 127 1 0.9775281 0.02247191 128 1 0.9775281 0.02247191 129 1 0.7575758 0.24242424 130 1 0.7575758 0.24242424 131 1 0.9775281 0.02247191 132 1 0.7575758 0.24242424 133 1 0.9775281 0.02247191 134 1 0.7575758 0.24242424 135 1 0.9775281 0.02247191 136 1 0.9775281 0.02247191 137 1 0.9775281 0.02247191 138 1 0.9775281 0.02247191 139 1 0.9775281 0.02247191 140 1 0.9775281 0.02247191 141 1 0.9775281 0.02247191 142 1 0.9090909 0.09090909 143 1 0.9090909 0.09090909 144 1 0.9090909 0.09090909 145 1 0.1538462 0.84615385 146 1 0.9090909 0.09090909 147 1 0.9775281 0.02247191 148 1 0.9775281 0.02247191 149 1 0.9775281 0.02247191 150 1 0.9775281 0.02247191 151 1 0.9775281 0.02247191 152 1 0.9775281 0.02247191 153 1 0.9775281 0.02247191 154 1 0.9090909 0.09090909 155 1 0.9090909 0.09090909 156 1 0.9090909 0.09090909 157 1 0.9090909 0.09090909 158 1 0.9090909 0.09090909 159 1 0.9090909 0.09090909 160 1 0.9090909 0.09090909 161 1 0.9775281 0.02247191 162 1 0.9775281 0.02247191 163 1 0.9775281 0.02247191 164 1 0.9090909 0.09090909 165 1 0.9090909 0.09090909 166 0 0.7575758 -0.75757576 167 0 0.7575758 -0.75757576 168 0 0.1538462 -0.15384615 169 0 0.9775281 -0.97752809 170 0 0.1538462 -0.15384615 171 0 0.1538462 -0.15384615 172 0 0.3421053 -0.34210526 173 0 0.3421053 -0.34210526 174 0 0.3421053 -0.34210526 175 0 0.7575758 -0.75757576 176 0 0.3421053 -0.34210526 177 0 0.3421053 -0.34210526 178 1 0.7575758 0.24242424 179 1 0.7575758 0.24242424 180 1 0.9775281 0.02247191 181 1 0.9775281 0.02247191 182 1 0.9775281 0.02247191 183 1 0.9775281 0.02247191 184 0 0.9090909 -0.90909091 185 0 0.9090909 -0.90909091 186 0 0.7575758 -0.75757576 187 0 0.7575758 -0.75757576 188 0 0.7575758 -0.75757576 189 0 0.7575758 -0.75757576 190 0 0.1538462 -0.15384615 191 0 0.1538462 -0.15384615 192 0 0.1538462 -0.15384615 193 0 0.1538462 -0.15384615 194 0 0.1538462 -0.15384615 195 0 0.1538462 -0.15384615 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/fisher/rcomp/tmp/4jpp01386320251.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/fisher/rcomp/tmp/563jx1386320251.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/fisher/rcomp/tmp/6zrnk1386320251.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/fisher/rcomp/tmp/7bwh41386320251.tab") + } > > try(system("convert tmp/2yzkk1386320251.ps tmp/2yzkk1386320251.png",intern=TRUE)) character(0) > try(system("convert tmp/3eycd1386320251.ps tmp/3eycd1386320251.png",intern=TRUE)) character(0) > try(system("convert tmp/4jpp01386320251.ps tmp/4jpp01386320251.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 9.418 1.295 10.668