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 + ,-4.813031 + ,0.266482 + ,119.992 + ,157.302 + ,74.997 + ,1 + ,-4.075192 + ,0.33559 + ,122.4 + ,148.65 + ,113.819 + ,1 + ,-4.443179 + ,0.311173 + ,116.682 + ,131.111 + ,111.555 + ,1 + ,-4.117501 + ,0.334147 + ,116.676 + ,137.871 + ,111.366 + ,1 + ,-3.747787 + ,0.234513 + ,116.014 + ,141.781 + ,110.655 + ,1 + ,-4.242867 + ,0.299111 + ,120.552 + ,131.162 + ,113.787 + ,1 + ,-5.634322 + ,0.257682 + ,120.267 + ,137.244 + ,114.82 + ,1 + ,-6.167603 + ,0.183721 + ,107.332 + ,113.84 + ,104.315 + ,1 + ,-5.498678 + ,0.327769 + ,95.73 + ,132.068 + ,91.754 + ,1 + ,-5.011879 + ,0.325996 + ,95.056 + ,120.103 + ,91.226 + ,1 + ,-5.24977 + ,0.391002 + ,88.333 + ,112.24 + ,84.072 + ,1 + ,-4.960234 + ,0.363566 + ,91.904 + ,115.871 + ,86.292 + ,1 + ,-6.547148 + ,0.152813 + ,136.926 + ,159.866 + ,131.276 + ,1 + ,-5.660217 + ,0.254989 + ,139.173 + ,179.139 + ,76.556 + ,1 + ,-6.105098 + ,0.203653 + ,152.845 + ,163.305 + ,75.836 + ,1 + ,-5.340115 + ,0.210185 + ,142.167 + ,217.455 + ,83.159 + ,1 + ,-5.44004 + ,0.239764 + ,144.188 + ,349.259 + ,82.764 + ,1 + ,-2.93107 + ,0.434326 + ,168.778 + ,232.181 + ,75.603 + ,1 + ,-3.949079 + ,0.35787 + ,153.046 + ,175.829 + ,68.623 + ,1 + ,-4.554466 + ,0.340176 + ,156.405 + ,189.398 + ,142.822 + ,1 + ,-4.095442 + ,0.262564 + ,153.848 + ,165.738 + ,65.782 + ,1 + ,-5.18696 + ,0.237622 + ,153.88 + ,172.86 + ,78.128 + ,1 + ,-4.330956 + ,0.262384 + ,167.93 + ,193.221 + ,79.068 + ,1 + ,-5.248776 + ,0.210279 + ,173.917 + ,192.735 + ,86.18 + ,1 + ,-5.557447 + ,0.22089 + ,163.656 + ,200.841 + ,76.779 + ,1 + ,-5.571843 + ,0.236853 + ,104.4 + ,206.002 + ,77.968 + ,1 + ,-6.18359 + ,0.226278 + ,171.041 + ,208.313 + ,75.501 + ,1 + ,-6.27169 + ,0.196102 + ,146.845 + ,208.701 + ,81.737 + ,1 + ,-7.120925 + ,0.279789 + ,155.358 + ,227.383 + ,80.055 + ,1 + ,-6.635729 + ,0.209866 + ,162.568 + ,198.346 + ,77.63 + ,0 + ,-7.3483 + ,0.177551 + ,197.076 + ,206.896 + ,192.055 + ,0 + ,-7.682587 + ,0.173319 + ,199.228 + ,209.512 + ,192.091 + ,0 + ,-7.067931 + ,0.175181 + ,198.383 + ,215.203 + ,193.104 + ,0 + ,-7.695734 + ,0.17854 + ,202.266 + ,211.604 + ,197.079 + ,0 + ,-7.964984 + ,0.163519 + ,203.184 + ,211.526 + ,196.16 + ,0 + ,-7.777685 + ,0.170183 + ,201.464 + ,210.565 + ,195.708 + ,1 + ,-6.149653 + ,0.218037 + ,177.876 + ,192.921 + ,168.013 + ,1 + ,-6.006414 + ,0.196371 + ,176.17 + ,185.604 + ,163.564 + ,1 + ,-6.452058 + ,0.212294 + ,180.198 + ,201.249 + ,175.456 + ,1 + ,-6.006647 + ,0.266892 + ,187.733 + ,202.324 + ,173.015 + ,1 + ,-6.647379 + ,0.201095 + ,186.163 + ,197.724 + ,177.584 + ,1 + ,-7.044105 + ,0.063412 + ,184.055 + ,196.537 + ,166.977 + ,0 + ,-7.31055 + ,0.098648 + ,237.226 + ,247.326 + ,225.227 + ,0 + ,-6.793547 + ,0.158266 + ,241.404 + ,248.834 + ,232.483 + ,0 + ,-7.057869 + ,0.091608 + ,243.439 + ,250.912 + ,232.435 + ,0 + ,-6.99582 + ,0.102083 + ,242.852 + ,255.034 + ,227.911 + ,0 + ,-7.156076 + ,0.127642 + ,245.51 + ,262.09 + ,231.848 + ,0 + ,-7.31951 + ,0.200873 + ,252.455 + ,261.487 + ,182.786 + ,0 + ,-6.439398 + ,0.266392 + ,122.188 + ,128.611 + ,115.765 + ,0 + ,-6.482096 + ,0.264967 + ,122.964 + ,130.049 + ,114.676 + ,0 + ,-6.650471 + ,0.254498 + ,124.445 + ,135.069 + ,117.495 + ,0 + ,-6.689151 + ,0.291954 + ,126.344 + ,134.231 + ,112.773 + ,0 + ,-7.072419 + ,0.220434 + ,128.001 + ,138.052 + ,122.08 + ,0 + ,-6.836811 + ,0.269866 + ,129.336 + ,139.867 + ,118.604 + ,1 + ,-4.649573 + ,0.205558 + ,108.807 + ,134.656 + ,102.874 + ,1 + ,-4.333543 + ,0.221727 + ,109.86 + ,126.358 + ,104.437 + ,1 + ,-4.438453 + ,0.238298 + ,110.417 + ,131.067 + ,103.37 + ,1 + ,-4.60826 + ,0.290024 + ,117.274 + ,129.916 + ,110.402 + ,1 + ,-4.476755 + ,0.262633 + ,116.879 + ,131.897 + ,108.153 + ,1 + ,-4.609161 + ,0.221711 + ,114.847 + ,271.314 + ,104.68 + ,0 + ,-7.040508 + ,0.066994 + ,209.144 + ,237.494 + ,109.379 + ,0 + ,-7.293801 + ,0.086372 + ,223.365 + ,238.987 + ,98.664 + ,0 + ,-6.966321 + ,0.095882 + ,222.236 + ,231.345 + ,205.495 + ,0 + ,-7.24562 + ,0.018689 + ,228.832 + ,234.619 + ,223.634 + ,0 + ,-7.496264 + ,0.056844 + ,229.401 + ,252.221 + ,221.156 + ,0 + ,-7.314237 + ,0.006274 + ,228.969 + ,239.541 + ,113.201 + ,1 + ,-5.409423 + ,0.22685 + ,140.341 + ,159.774 + ,67.021 + ,1 + ,-5.324574 + ,0.20566 + ,136.969 + ,166.607 + ,66.004 + ,1 + ,-5.86975 + ,0.151814 + ,143.533 + ,162.215 + ,65.809 + ,1 + ,-6.261141 + ,0.120956 + ,148.09 + ,162.824 + ,67.343 + ,1 + ,-5.720868 + ,0.15883 + ,142.729 + ,162.408 + ,65.476 + ,1 + ,-5.207985 + ,0.224852 + ,136.358 + ,176.595 + ,65.75 + ,1 + ,-5.79182 + ,0.329066 + ,120.08 + ,139.71 + ,111.208 + ,1 + ,-5.389129 + ,0.306636 + ,112.014 + ,588.518 + ,107.024 + ,1 + ,-5.31336 + ,0.201861 + ,110.793 + ,128.101 + ,107.316 + ,1 + ,-5.477592 + ,0.315074 + ,110.707 + ,122.611 + ,105.007 + ,1 + ,-5.775966 + ,0.341169 + ,112.876 + ,148.826 + ,106.981 + ,1 + ,-5.391029 + ,0.250572 + ,110.568 + ,125.394 + ,106.821 + ,1 + ,-5.115212 + ,0.249494 + ,95.385 + ,102.145 + ,90.264 + ,1 + ,-4.913885 + ,0.265699 + ,100.77 + ,115.697 + ,85.545 + ,1 + ,-4.441519 + ,0.155097 + ,96.106 + ,108.664 + ,84.51 + ,1 + ,-5.132032 + ,0.210458 + ,95.605 + ,107.715 + ,87.549 + ,1 + ,-5.022288 + ,0.146948 + ,100.96 + ,110.019 + ,95.628 + ,1 + ,-6.025367 + ,0.078202 + ,98.804 + ,102.305 + ,87.804 + ,1 + ,-5.288912 + ,0.343073 + ,176.858 + ,205.56 + ,75.344 + ,1 + ,-5.657899 + ,0.315903 + ,180.978 + ,200.125 + ,155.495 + ,1 + ,-6.366916 + ,0.335753 + ,178.222 + ,202.45 + ,141.047 + ,1 + ,-5.515071 + ,0.299549 + ,176.281 + ,227.381 + ,125.61 + ,1 + ,-5.783272 + ,0.299793 + ,173.898 + ,211.35 + ,74.677 + ,1 + ,-4.379411 + ,0.375531 + ,179.711 + ,225.93 + ,144.878 + ,1 + ,-4.508984 + ,0.389232 + ,166.605 + ,206.008 + ,78.032 + ,1 + ,-6.411497 + ,0.207156 + ,151.955 + ,163.335 + ,147.226 + ,1 + ,-5.952058 + ,0.08784 + ,148.272 + ,164.989 + ,142.299 + ,1 + ,-6.152551 + ,0.17352 + ,152.125 + ,161.469 + ,76.596 + ,1 + ,-6.251425 + ,0.188056 + ,157.821 + ,172.975 + ,68.401 + ,1 + ,-6.247076 + ,0.180528 + ,157.447 + ,163.267 + ,149.605 + ,1 + ,-6.41744 + ,0.194627 + ,159.116 + ,168.913 + ,144.811 + ,1 + ,-4.020042 + ,0.265315 + ,125.036 + ,143.946 + ,116.187 + ,1 + ,-5.159169 + ,0.202146 + ,125.791 + ,140.557 + ,96.206 + ,1 + ,-3.760348 + ,0.242861 + ,126.512 + ,141.756 + ,99.77 + ,1 + ,-3.700544 + ,0.260481 + ,125.641 + ,141.068 + ,116.346 + ,1 + ,-4.20273 + ,0.310163 + ,128.451 + ,150.449 + ,75.632 + ,1 + ,-3.269487 + ,0.270641 + ,139.224 + ,586.567 + ,66.157 + ,1 + ,-6.878393 + ,0.089267 + ,150.258 + ,154.609 + ,75.349 + ,1 + ,-7.111576 + ,0.14478 + ,154.003 + ,160.267 + ,128.621 + ,1 + ,-6.997403 + ,0.210279 + ,149.689 + ,160.368 + ,133.608 + ,1 + ,-6.981201 + ,0.18455 + ,155.078 + ,163.736 + ,144.148 + ,1 + ,-6.600023 + ,0.249172 + ,151.884 + ,157.765 + ,133.751 + ,1 + ,-6.739151 + ,0.160686 + ,151.989 + ,157.339 + ,132.857 + ,1 + ,-5.845099 + ,0.278679 + ,193.03 + ,208.9 + ,80.297 + ,1 + ,-5.25832 + ,0.256454 + ,200.714 + ,223.982 + ,89.686 + ,1 + ,-6.471427 + ,0.184378 + ,208.519 + ,220.315 + ,199.02 + ,1 + ,-4.876336 + ,0.212054 + ,204.664 + ,221.3 + ,189.621 + ,1 + ,-5.96304 + ,0.250283 + ,210.141 + ,232.706 + ,185.258 + ,1 + ,-6.729713 + ,0.181701 + ,206.327 + ,226.355 + ,92.02 + ,1 + ,-4.673241 + ,0.261549 + ,151.872 + ,492.892 + ,69.085 + ,1 + ,-6.051233 + ,0.27328 + ,158.219 + ,442.557 + ,71.948 + ,1 + ,-4.597834 + ,0.372114 + ,170.756 + ,450.247 + ,79.032 + ,1 + ,-4.913137 + ,0.393056 + ,178.285 + ,442.824 + ,82.063 + ,1 + ,-5.517173 + ,0.389295 + ,217.116 + ,233.481 + ,93.978 + ,1 + ,-6.186128 + ,0.279933 + ,128.94 + ,479.697 + ,88.251 + ,1 + ,-4.711007 + ,0.281618 + ,176.824 + ,215.293 + ,83.961 + ,1 + ,-5.418787 + ,0.160267 + ,138.19 + ,203.522 + ,83.34 + ,1 + ,-5.44514 + ,0.142466 + ,182.018 + ,197.173 + ,79.187 + ,1 + ,-5.944191 + ,0.143359 + ,156.239 + ,195.107 + ,79.82 + ,1 + ,-5.594275 + ,0.12795 + ,145.174 + ,198.109 + ,80.637 + ,1 + ,-5.540351 + ,0.087165 + ,138.145 + ,197.238 + ,81.114 + ,1 + ,-5.825257 + ,0.115697 + ,166.888 + ,198.966 + ,79.512 + ,1 + ,-6.890021 + ,0.152941 + ,119.031 + ,127.533 + ,109.216 + ,1 + ,-5.892061 + ,0.195976 + ,120.078 + ,126.632 + ,105.667 + ,1 + ,-6.135296 + ,0.20363 + ,120.289 + ,128.143 + ,100.209 + ,1 + ,-6.112667 + ,0.217013 + ,120.256 + ,125.306 + ,104.773 + ,1 + ,-5.436135 + ,0.254909 + ,119.056 + ,125.213 + ,86.795 + ,1 + ,-6.448134 + ,0.178713 + ,118.747 + ,123.723 + ,109.836 + ,1 + ,-5.301321 + ,0.320385 + ,106.516 + ,112.777 + ,93.105 + ,1 + ,-5.333619 + ,0.322044 + ,110.453 + ,127.611 + ,105.554 + ,1 + ,-4.378916 + ,0.300067 + ,113.4 + ,133.344 + ,107.816 + ,1 + ,-4.654894 + ,0.304107 + ,113.166 + ,130.27 + ,100.673 + ,1 + ,-5.634576 + ,0.306014 + ,112.239 + ,126.609 + ,104.095 + ,1 + ,-5.866357 + ,0.23307 + ,116.15 + ,131.731 + ,109.815 + ,1 + ,-4.796845 + ,0.397749 + ,170.368 + ,268.796 + ,79.543 + ,1 + ,-5.410336 + ,0.288917 + ,208.083 + ,253.792 + ,91.802 + ,1 + ,-5.585259 + ,0.310746 + ,198.458 + ,219.29 + ,148.691 + ,1 + ,-5.898673 + ,0.213353 + ,202.805 + ,231.508 + ,86.232 + ,1 + ,-6.132663 + ,0.220617 + ,202.544 + ,241.35 + ,164.168 + ,1 + ,-5.456811 + ,0.345238 + ,223.361 + ,263.872 + ,87.638 + ,1 + ,-3.297668 + ,0.414758 + ,169.774 + ,191.759 + ,151.451 + ,1 + ,-4.276605 + ,0.355736 + ,183.52 + ,216.814 + ,161.34 + ,1 + ,-3.377325 + ,0.335357 + ,188.62 + ,216.302 + ,165.982 + ,1 + ,-4.892495 + ,0.262281 + ,202.632 + ,565.74 + ,177.258 + ,1 + ,-4.484303 + ,0.340256 + ,186.695 + ,211.961 + ,149.442 + ,1 + ,-2.434031 + ,0.450493 + ,192.818 + ,224.429 + ,168.793 + ,1 + ,-2.839756 + ,0.356224 + ,198.116 + ,233.099 + ,174.478 + ,1 + ,-4.865194 + ,0.246404 + ,121.345 + ,139.644 + ,98.25 + ,1 + ,-4.239028 + ,0.175691 + ,119.1 + ,128.442 + ,88.833 + ,1 + ,-3.583722 + ,0.207914 + ,117.87 + ,127.349 + ,95.654 + ,1 + ,-5.4351 + ,0.230532 + ,122.336 + ,142.369 + ,94.794 + ,1 + ,-3.444478 + ,0.303214 + ,117.963 + ,134.209 + ,100.757 + ,1 + ,-5.070096 + ,0.280091 + ,126.144 + ,154.284 + ,97.543 + ,1 + ,-5.498456 + ,0.234196 + ,127.93 + ,138.752 + ,112.173 + ,1 + ,-5.185987 + ,0.259229 + ,114.238 + ,124.393 + ,77.022 + ,1 + ,-5.283009 + ,0.226528 + ,115.322 + ,135.738 + ,107.802 + ,1 + ,-5.529833 + ,0.24275 + ,114.554 + ,126.778 + ,91.121 + ,1 + ,-5.617124 + ,0.184896 + ,112.15 + ,131.669 + ,97.527 + ,1 + ,-2.929379 + ,0.396746 + ,102.273 + ,142.83 + ,85.902 + ,0 + ,-6.816086 + ,0.17227 + ,236.2 + ,244.663 + ,102.137 + ,0 + ,-7.018057 + ,0.176316 + ,237.323 + ,243.709 + ,229.256 + ,0 + ,-7.517934 + ,0.160414 + ,260.105 + ,264.919 + ,237.303 + ,0 + ,-5.736781 + ,0.164529 + ,197.569 + ,217.627 + ,90.794 + ,0 + ,-7.169701 + ,0.073298 + ,240.301 + ,245.135 + ,219.783 + ,0 + ,-7.3045 + ,0.171088 + ,244.99 + ,272.21 + ,239.17 + ,0 + ,-6.323531 + ,0.218885 + ,112.547 + ,133.374 + ,105.715 + ,0 + ,-6.085567 + ,0.192375 + ,110.739 + ,113.597 + ,100.139 + ,0 + ,-5.943501 + ,0.19215 + ,113.715 + ,116.443 + ,96.913 + ,0 + ,-6.012559 + ,0.229298 + ,117.004 + ,144.466 + ,99.923 + ,0 + ,-5.966779 + ,0.197938 + ,115.38 + ,123.109 + ,108.634 + ,0 + ,-6.016891 + ,0.109256 + ,116.388 + ,129.038 + ,108.97 + ,1 + ,-6.486822 + ,0.197919 + ,151.737 + ,190.204 + ,129.859 + ,1 + ,-6.311987 + ,0.182459 + ,148.79 + ,158.359 + ,138.99 + ,1 + ,-5.711205 + ,0.240875 + ,148.143 + ,155.982 + ,135.041 + ,1 + ,-6.261446 + ,0.183218 + ,150.44 + ,163.441 + ,144.736 + ,1 + ,-5.704053 + ,0.216204 + ,148.462 + ,161.078 + ,141.998 + ,1 + ,-6.27717 + ,0.109397 + ,149.818 + ,163.417 + ,144.786 + ,0 + ,-5.61907 + ,0.191576 + ,117.226 + ,123.925 + ,106.656 + ,0 + ,-5.198864 + ,0.206768 + ,116.848 + ,217.552 + ,99.503 + ,0 + ,-5.592584 + ,0.133917 + ,116.286 + ,177.291 + ,96.983 + ,0 + ,-6.431119 + ,0.15331 + ,116.556 + ,592.03 + ,86.228 + ,0 + ,-6.359018 + ,0.116636 + ,116.342 + ,581.289 + ,94.246 + ,0 + ,-6.710219 + ,0.149694 + ,114.563 + ,119.167 + ,86.647 + ,0 + ,-6.934474 + ,0.15989 + ,201.774 + ,262.707 + ,78.228 + ,0 + ,-6.538586 + ,0.121952 + ,174.188 + ,230.978 + ,94.261 + ,0 + ,-6.195325 + ,0.129303 + ,209.516 + ,253.017 + ,89.488 + ,0 + ,-6.787197 + ,0.158453 + ,174.688 + ,240.005 + ,74.287 + ,0 + ,-6.744577 + ,0.207454 + ,198.764 + ,396.961 + ,74.904 + ,0 + ,-5.724056 + ,0.190667 + ,214.289 + ,260.277 + ,77.973) + ,dim=c(6 + ,195) + ,dimnames=list(c('status' + ,'spread1' + ,'spread2' + ,'MDVP:Fo(Hz)' + ,'MDVP:Fhi(Hz)' + ,'MDVP:Flo(Hz)') + ,1:195)) > y <- array(NA,dim=c(6,195),dimnames=list(c('status','spread1','spread2','MDVP:Fo(Hz)','MDVP:Fhi(Hz)','MDVP:Flo(Hz)'),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 = '2' > par2 = 'equal' > par1 = '1' > par4 <- 'no' > par3 <- '2' > par2 <- 'equal' > 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]) C1 C2 48 147 > colnames(x) [1] "status" "spread1" "spread2" "MDVP.Fo.Hz." "MDVP.Fhi.Hz." [6] "MDVP.Flo.Hz." > colnames(x)[par1] [1] "status" > x[,par1] [1] C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 [26] C2 C2 C2 C2 C2 C1 C1 C1 C1 C1 C1 C2 C2 C2 C2 C2 C2 C1 C1 C1 C1 C1 C1 C1 C1 [51] C1 C1 C1 C1 C2 C2 C2 C2 C2 C2 C1 C1 C1 C1 C1 C1 C2 C2 C2 C2 C2 C2 C2 C2 C2 [76] C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 [101] C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 [126] C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 [151] C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C2 C1 C1 C1 C1 C1 C1 C1 C1 C1 C1 [176] C1 C1 C2 C2 C2 C2 C2 C2 C1 C1 C1 C1 C1 C1 C1 C1 C1 C1 C1 C1 Levels: C1 C2 > 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/136mj1386789748.tab") + } + } > m Conditional inference tree with 4 terminal nodes Response: as.factor(status) Inputs: spread1, spread2, MDVP.Fo.Hz., MDVP.Fhi.Hz., MDVP.Flo.Hz. Number of observations: 195 1) spread1 <= -6.650471; criterion = 1, statistic = 61.894 2) MDVP.Fo.Hz. <= 184.055; criterion = 0.984, statistic = 8.715 3)* weights = 14 2) MDVP.Fo.Hz. > 184.055 4)* weights = 26 1) spread1 > -6.650471 5) spread2 <= 0.192375; criterion = 0.999, statistic = 13.619 6)* weights = 36 5) spread2 > 0.192375 7)* weights = 119 > postscript(file="/var/wessaorg/rcomp/tmp/2591a1386789748.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/3nhs91386789748.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) + } > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } [,1] [,2] [1,] 2 2 [2,] 2 2 [3,] 2 2 [4,] 2 2 [5,] 2 2 [6,] 2 2 [7,] 2 2 [8,] 2 2 [9,] 2 2 [10,] 2 2 [11,] 2 2 [12,] 2 2 [13,] 2 2 [14,] 2 2 [15,] 2 2 [16,] 2 2 [17,] 2 2 [18,] 2 2 [19,] 2 2 [20,] 2 2 [21,] 2 2 [22,] 2 2 [23,] 2 2 [24,] 2 2 [25,] 2 2 [26,] 2 2 [27,] 2 2 [28,] 2 2 [29,] 2 2 [30,] 2 2 [31,] 1 1 [32,] 1 1 [33,] 1 1 [34,] 1 1 [35,] 1 1 [36,] 1 1 [37,] 2 2 [38,] 2 2 [39,] 2 2 [40,] 2 2 [41,] 2 2 [42,] 2 2 [43,] 1 1 [44,] 1 1 [45,] 1 1 [46,] 1 1 [47,] 1 1 [48,] 1 1 [49,] 1 2 [50,] 1 2 [51,] 1 2 [52,] 1 2 [53,] 1 2 [54,] 1 2 [55,] 2 2 [56,] 2 2 [57,] 2 2 [58,] 2 2 [59,] 2 2 [60,] 2 2 [61,] 1 1 [62,] 1 1 [63,] 1 1 [64,] 1 1 [65,] 1 1 [66,] 1 1 [67,] 2 2 [68,] 2 2 [69,] 2 2 [70,] 2 2 [71,] 2 2 [72,] 2 2 [73,] 2 2 [74,] 2 2 [75,] 2 2 [76,] 2 2 [77,] 2 2 [78,] 2 2 [79,] 2 2 [80,] 2 2 [81,] 2 2 [82,] 2 2 [83,] 2 2 [84,] 2 2 [85,] 2 2 [86,] 2 2 [87,] 2 2 [88,] 2 2 [89,] 2 2 [90,] 2 2 [91,] 2 2 [92,] 2 2 [93,] 2 2 [94,] 2 2 [95,] 2 2 [96,] 2 2 [97,] 2 2 [98,] 2 2 [99,] 2 2 [100,] 2 2 [101,] 2 2 [102,] 2 2 [103,] 2 2 [104,] 2 2 [105,] 2 2 [106,] 2 2 [107,] 2 2 [108,] 2 2 [109,] 2 2 [110,] 2 2 [111,] 2 2 [112,] 2 2 [113,] 2 2 [114,] 2 2 [115,] 2 1 [116,] 2 2 [117,] 2 2 [118,] 2 2 [119,] 2 2 [120,] 2 2 [121,] 2 2 [122,] 2 2 [123,] 2 2 [124,] 2 2 [125,] 2 2 [126,] 2 2 [127,] 2 2 [128,] 2 2 [129,] 2 2 [130,] 2 2 [131,] 2 2 [132,] 2 2 [133,] 2 2 [134,] 2 2 [135,] 2 2 [136,] 2 2 [137,] 2 2 [138,] 2 2 [139,] 2 2 [140,] 2 2 [141,] 2 2 [142,] 2 2 [143,] 2 2 [144,] 2 2 [145,] 2 2 [146,] 2 2 [147,] 2 2 [148,] 2 2 [149,] 2 2 [150,] 2 2 [151,] 2 2 [152,] 2 2 [153,] 2 2 [154,] 2 2 [155,] 2 2 [156,] 2 2 [157,] 2 2 [158,] 2 2 [159,] 2 2 [160,] 2 2 [161,] 2 2 [162,] 2 2 [163,] 2 2 [164,] 2 2 [165,] 2 2 [166,] 1 1 [167,] 1 1 [168,] 1 1 [169,] 1 2 [170,] 1 1 [171,] 1 1 [172,] 1 2 [173,] 1 2 [174,] 1 2 [175,] 1 2 [176,] 1 2 [177,] 1 2 [178,] 2 2 [179,] 2 2 [180,] 2 2 [181,] 2 2 [182,] 2 2 [183,] 2 2 [184,] 1 2 [185,] 1 2 [186,] 1 2 [187,] 1 2 [188,] 1 2 [189,] 1 2 [190,] 1 1 [191,] 1 2 [192,] 1 2 [193,] 1 2 [194,] 1 1 [195,] 1 2 C1 C2 C1 25 23 C2 1 146 > postscript(file="/var/wessaorg/rcomp/tmp/4r2w51386789748.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/5pm7y1386789748.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/6ejzb1386789748.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/7u88h1386789748.tab") + } > > try(system("convert tmp/2591a1386789748.ps tmp/2591a1386789748.png",intern=TRUE)) character(0) > try(system("convert tmp/3nhs91386789748.ps tmp/3nhs91386789748.png",intern=TRUE)) character(0) > try(system("convert tmp/4r2w51386789748.ps tmp/4r2w51386789748.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.533 1.691 9.185