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 + ,119.992 + ,74.997 + ,0.0037 + ,1 + ,122.4 + ,113.819 + ,0.00465 + ,1 + ,116.682 + ,111.555 + ,0.00544 + ,1 + ,116.676 + ,111.366 + ,0.00502 + ,1 + ,116.014 + ,110.655 + ,0.00655 + ,1 + ,120.552 + ,113.787 + ,0.00463 + ,1 + ,120.267 + ,114.82 + ,0.00155 + ,1 + ,107.332 + ,104.315 + ,0.00144 + ,1 + ,95.73 + ,91.754 + ,0.00293 + ,1 + ,95.056 + ,91.226 + ,0.00268 + ,1 + ,88.333 + ,84.072 + ,0.00254 + ,1 + ,91.904 + ,86.292 + ,0.00281 + ,1 + ,136.926 + ,131.276 + ,0.00118 + ,1 + ,139.173 + ,76.556 + ,0.00165 + ,1 + ,152.845 + ,75.836 + ,0.00121 + ,1 + ,142.167 + ,83.159 + ,0.00157 + ,1 + ,144.188 + ,82.764 + ,0.00211 + ,1 + ,168.778 + ,75.603 + ,0.00284 + ,1 + ,153.046 + ,68.623 + ,0.00364 + ,1 + ,156.405 + ,142.822 + ,0.00372 + ,1 + ,153.848 + ,65.782 + ,0.00428 + ,1 + ,153.88 + ,78.128 + ,0.00232 + ,1 + ,167.93 + ,79.068 + ,0.0022 + ,1 + ,173.917 + ,86.18 + ,0.00221 + ,1 + ,163.656 + ,76.779 + ,0.0038 + ,1 + ,104.4 + ,77.968 + ,0.00316 + ,1 + ,171.041 + ,75.501 + ,0.0025 + ,1 + ,146.845 + ,81.737 + ,0.0025 + ,1 + ,155.358 + ,80.055 + ,0.00159 + ,1 + ,162.568 + ,77.63 + ,0.0028 + ,0 + ,197.076 + ,192.055 + ,0.00166 + ,0 + ,199.228 + ,192.091 + ,0.00134 + ,0 + ,198.383 + ,193.104 + ,0.00113 + ,0 + ,202.266 + ,197.079 + ,0.00093 + ,0 + ,203.184 + ,196.16 + ,0.00094 + ,0 + ,201.464 + ,195.708 + ,0.00105 + ,1 + ,177.876 + ,168.013 + ,0.00233 + ,1 + ,176.17 + ,163.564 + ,0.00205 + ,1 + ,180.198 + ,175.456 + ,0.00153 + ,1 + ,187.733 + ,173.015 + ,0.00168 + ,1 + ,186.163 + ,177.584 + ,0.00165 + ,1 + ,184.055 + ,166.977 + ,0.00134 + ,0 + ,237.226 + ,225.227 + ,0.00169 + ,0 + ,241.404 + ,232.483 + ,0.00157 + ,0 + ,243.439 + ,232.435 + ,0.00109 + ,0 + ,242.852 + ,227.911 + ,0.00117 + ,0 + ,245.51 + ,231.848 + ,0.00127 + ,0 + ,252.455 + ,182.786 + ,0.00092 + ,0 + ,122.188 + ,115.765 + ,0.00169 + ,0 + ,122.964 + ,114.676 + ,0.00124 + ,0 + ,124.445 + ,117.495 + ,0.00141 + ,0 + ,126.344 + ,112.773 + ,0.00131 + ,0 + ,128.001 + ,122.08 + ,0.00137 + ,0 + ,129.336 + ,118.604 + ,0.00165 + ,1 + ,108.807 + ,102.874 + ,0.00349 + ,1 + ,109.86 + ,104.437 + ,0.00398 + ,1 + ,110.417 + ,103.37 + ,0.00352 + ,1 + ,117.274 + ,110.402 + ,0.00299 + ,1 + ,116.879 + ,108.153 + ,0.00334 + ,1 + ,114.847 + ,104.68 + ,0.00373 + ,0 + ,209.144 + ,109.379 + ,0.00147 + ,0 + ,223.365 + ,98.664 + ,0.00154 + ,0 + ,222.236 + ,205.495 + ,0.00152 + ,0 + ,228.832 + ,223.634 + ,0.00175 + ,0 + ,229.401 + ,221.156 + ,0.00114 + ,0 + ,228.969 + ,113.201 + ,0.00136 + ,1 + ,140.341 + ,67.021 + ,0.0043 + ,1 + ,136.969 + ,66.004 + ,0.00507 + ,1 + ,143.533 + ,65.809 + ,0.00647 + ,1 + ,148.09 + ,67.343 + ,0.00467 + ,1 + ,142.729 + ,65.476 + ,0.00469 + ,1 + ,136.358 + ,65.75 + ,0.00534 + ,1 + ,120.08 + ,111.208 + ,0.0018 + ,1 + ,112.014 + ,107.024 + ,0.00268 + ,1 + ,110.793 + ,107.316 + ,0.0026 + ,1 + ,110.707 + ,105.007 + ,0.00277 + ,1 + ,112.876 + ,106.981 + ,0.0027 + ,1 + ,110.568 + ,106.821 + ,0.00226 + ,1 + ,95.385 + ,90.264 + ,0.00331 + ,1 + ,100.77 + ,85.545 + ,0.00622 + ,1 + ,96.106 + ,84.51 + ,0.00389 + ,1 + ,95.605 + ,87.549 + ,0.00428 + ,1 + ,100.96 + ,95.628 + ,0.00351 + ,1 + ,98.804 + ,87.804 + ,0.00247 + ,1 + ,176.858 + ,75.344 + ,0.00418 + ,1 + ,180.978 + ,155.495 + ,0.0022 + ,1 + ,178.222 + ,141.047 + ,0.00163 + ,1 + ,176.281 + ,125.61 + ,0.00287 + ,1 + ,173.898 + ,74.677 + ,0.00237 + ,1 + ,179.711 + ,144.878 + ,0.00391 + ,1 + ,166.605 + ,78.032 + ,0.00387 + ,1 + ,151.955 + ,147.226 + ,0.00224 + ,1 + ,148.272 + ,142.299 + ,0.0025 + ,1 + ,152.125 + ,76.596 + ,0.00191 + ,1 + ,157.821 + ,68.401 + ,0.00196 + ,1 + ,157.447 + ,149.605 + ,0.00201 + ,1 + ,159.116 + ,144.811 + ,0.00178 + ,1 + ,125.036 + ,116.187 + ,0.00743 + ,1 + ,125.791 + ,96.206 + ,0.00826 + ,1 + ,126.512 + ,99.77 + ,0.01159 + ,1 + ,125.641 + ,116.346 + ,0.02144 + ,1 + ,128.451 + ,75.632 + ,0.00905 + ,1 + ,139.224 + ,66.157 + ,0.01854 + ,1 + ,150.258 + ,75.349 + ,0.00105 + ,1 + ,154.003 + ,128.621 + ,0.00076 + ,1 + ,149.689 + ,133.608 + ,0.00116 + ,1 + ,155.078 + ,144.148 + ,0.00068 + ,1 + ,151.884 + ,133.751 + ,0.00115 + ,1 + ,151.989 + ,132.857 + ,0.00075 + ,1 + ,193.03 + ,80.297 + ,0.0045 + ,1 + ,200.714 + ,89.686 + ,0.00371 + ,1 + ,208.519 + ,199.02 + ,0.00368 + ,1 + ,204.664 + ,189.621 + ,0.00502 + ,1 + ,210.141 + ,185.258 + ,0.00321 + ,1 + ,206.327 + ,92.02 + ,0.00302 + ,1 + ,151.872 + ,69.085 + ,0.00404 + ,1 + ,158.219 + ,71.948 + ,0.00214 + ,1 + ,170.756 + ,79.032 + ,0.00244 + ,1 + ,178.285 + ,82.063 + ,0.00157 + ,1 + ,217.116 + ,93.978 + ,0.00127 + ,1 + ,128.94 + ,88.251 + ,0.00241 + ,1 + ,176.824 + ,83.961 + ,0.00209 + ,1 + ,138.19 + ,83.34 + ,0.00406 + ,1 + ,182.018 + ,79.187 + ,0.00506 + ,1 + ,156.239 + ,79.82 + ,0.00403 + ,1 + ,145.174 + ,80.637 + ,0.00414 + ,1 + ,138.145 + ,81.114 + ,0.00294 + ,1 + ,166.888 + ,79.512 + ,0.00368 + ,1 + ,119.031 + ,109.216 + ,0.00214 + ,1 + ,120.078 + ,105.667 + ,0.00116 + ,1 + ,120.289 + ,100.209 + ,0.00269 + ,1 + ,120.256 + ,104.773 + ,0.00224 + ,1 + ,119.056 + ,86.795 + ,0.00169 + ,1 + ,118.747 + ,109.836 + ,0.00168 + ,1 + ,106.516 + ,93.105 + ,0.00291 + ,1 + ,110.453 + ,105.554 + ,0.00244 + ,1 + ,113.4 + ,107.816 + ,0.00219 + ,1 + ,113.166 + ,100.673 + ,0.00257 + ,1 + ,112.239 + ,104.095 + ,0.00238 + ,1 + ,116.15 + ,109.815 + ,0.00181 + ,1 + ,170.368 + ,79.543 + ,0.00232 + ,1 + ,208.083 + ,91.802 + ,0.00428 + ,1 + ,198.458 + ,148.691 + ,0.00182 + ,1 + ,202.805 + ,86.232 + ,0.00189 + ,1 + ,202.544 + ,164.168 + ,0.001 + ,1 + ,223.361 + ,87.638 + ,0.00169 + ,1 + ,169.774 + ,151.451 + ,0.00863 + ,1 + ,183.52 + ,161.34 + ,0.00849 + ,1 + ,188.62 + ,165.982 + ,0.00996 + ,1 + ,202.632 + ,177.258 + ,0.00919 + ,1 + ,186.695 + ,149.442 + ,0.01075 + ,1 + ,192.818 + ,168.793 + ,0.018 + ,1 + ,198.116 + ,174.478 + ,0.01568 + ,1 + ,121.345 + ,98.25 + ,0.00388 + ,1 + ,119.1 + ,88.833 + ,0.00393 + ,1 + ,117.87 + ,95.654 + ,0.00356 + ,1 + ,122.336 + ,94.794 + ,0.00415 + ,1 + ,117.963 + ,100.757 + ,0.01117 + ,1 + ,126.144 + ,97.543 + ,0.00593 + ,1 + ,127.93 + ,112.173 + ,0.00321 + ,1 + ,114.238 + ,77.022 + ,0.00299 + ,1 + ,115.322 + ,107.802 + ,0.00352 + ,1 + ,114.554 + ,91.121 + ,0.00366 + ,1 + ,112.15 + ,97.527 + ,0.00291 + ,1 + ,102.273 + ,85.902 + ,0.00493 + ,0 + ,236.2 + ,102.137 + ,0.00154 + ,0 + ,237.323 + ,229.256 + ,0.00173 + ,0 + ,260.105 + ,237.303 + ,0.00205 + ,0 + ,197.569 + ,90.794 + ,0.0049 + ,0 + ,240.301 + ,219.783 + ,0.00316 + ,0 + ,244.99 + ,239.17 + ,0.00279 + ,0 + ,112.547 + ,105.715 + ,0.00166 + ,0 + ,110.739 + ,100.139 + ,0.0017 + ,0 + ,113.715 + ,96.913 + ,0.00171 + ,0 + ,117.004 + ,99.923 + ,0.00176 + ,0 + ,115.38 + ,108.634 + ,0.0016 + ,0 + ,116.388 + ,108.97 + ,0.00169 + ,1 + ,151.737 + ,129.859 + ,0.00135 + ,1 + ,148.79 + ,138.99 + ,0.00152 + ,1 + ,148.143 + ,135.041 + ,0.00204 + ,1 + ,150.44 + ,144.736 + ,0.00206 + ,1 + ,148.462 + ,141.998 + ,0.00202 + ,1 + ,149.818 + ,144.786 + ,0.00174 + ,0 + ,117.226 + ,106.656 + ,0.00186 + ,0 + ,116.848 + ,99.503 + ,0.0026 + ,0 + ,116.286 + ,96.983 + ,0.00134 + ,0 + ,116.556 + ,86.228 + ,0.00254 + ,0 + ,116.342 + ,94.246 + ,0.00115 + ,0 + ,114.563 + ,86.647 + ,0.00146 + ,0 + ,201.774 + ,78.228 + ,0.00412 + ,0 + ,174.188 + ,94.261 + ,0.00263 + ,0 + ,209.516 + ,89.488 + ,0.00331 + ,0 + ,174.688 + ,74.287 + ,0.00624 + ,0 + ,198.764 + ,74.904 + ,0.0037 + ,0 + ,214.289 + ,77.973 + ,0.00295) + ,dim=c(4 + ,195) + ,dimnames=list(c('status' + ,'MDVP:Fo(Hz)' + ,'MDVP:Flo(Hz)' + ,'MDVP:RAP') + ,1:195)) > y <- array(NA,dim=c(4,195),dimnames=list(c('status','MDVP:Fo(Hz)','MDVP:Flo(Hz)','MDVP:RAP'),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 = '4' > par2 = 'none' > par1 = '1' > par4 <- 'no' > par3 <- '4' > 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" "MDVP.Fo.Hz." "MDVP.Flo.Hz." "MDVP.RAP" > 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/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/1m4yy1386350971.tab") + } + } > m Conditional inference tree with 5 terminal nodes Response: status Inputs: MDVP.Fo.Hz., MDVP.Flo.Hz., MDVP.RAP Number of observations: 195 1) MDVP.Fo.Hz. <= 193.03; criterion = 1, statistic = 28.537 2) MDVP.RAP <= 0.00186; criterion = 0.957, statistic = 5.96 3) MDVP.Fo.Hz. <= 129.336; criterion = 1, statistic = 16.198 4)* weights = 23 3) MDVP.Fo.Hz. > 129.336 5)* weights = 21 2) MDVP.RAP > 0.00186 6)* weights = 110 1) MDVP.Fo.Hz. > 193.03 7) MDVP.Fo.Hz. <= 223.361; criterion = 0.978, statistic = 7.199 8)* weights = 26 7) MDVP.Fo.Hz. > 223.361 9)* weights = 15 > postscript(file="/var/wessaorg/rcomp/tmp/2o66n1386350971.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/3m31e1386350971.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.9636364 0.03636364 2 1 0.9636364 0.03636364 3 1 0.9636364 0.03636364 4 1 0.9636364 0.03636364 5 1 0.9636364 0.03636364 6 1 0.9636364 0.03636364 7 1 0.3043478 0.69565217 8 1 0.3043478 0.69565217 9 1 0.9636364 0.03636364 10 1 0.9636364 0.03636364 11 1 0.9636364 0.03636364 12 1 0.9636364 0.03636364 13 1 1.0000000 0.00000000 14 1 1.0000000 0.00000000 15 1 1.0000000 0.00000000 16 1 1.0000000 0.00000000 17 1 0.9636364 0.03636364 18 1 0.9636364 0.03636364 19 1 0.9636364 0.03636364 20 1 0.9636364 0.03636364 21 1 0.9636364 0.03636364 22 1 0.9636364 0.03636364 23 1 0.9636364 0.03636364 24 1 0.9636364 0.03636364 25 1 0.9636364 0.03636364 26 1 0.9636364 0.03636364 27 1 0.9636364 0.03636364 28 1 0.9636364 0.03636364 29 1 1.0000000 0.00000000 30 1 0.9636364 0.03636364 31 0 0.5000000 -0.50000000 32 0 0.5000000 -0.50000000 33 0 0.5000000 -0.50000000 34 0 0.5000000 -0.50000000 35 0 0.5000000 -0.50000000 36 0 0.5000000 -0.50000000 37 1 0.9636364 0.03636364 38 1 0.9636364 0.03636364 39 1 1.0000000 0.00000000 40 1 1.0000000 0.00000000 41 1 1.0000000 0.00000000 42 1 1.0000000 0.00000000 43 0 0.0000000 0.00000000 44 0 0.0000000 0.00000000 45 0 0.0000000 0.00000000 46 0 0.0000000 0.00000000 47 0 0.0000000 0.00000000 48 0 0.0000000 0.00000000 49 0 0.3043478 -0.30434783 50 0 0.3043478 -0.30434783 51 0 0.3043478 -0.30434783 52 0 0.3043478 -0.30434783 53 0 0.3043478 -0.30434783 54 0 0.3043478 -0.30434783 55 1 0.9636364 0.03636364 56 1 0.9636364 0.03636364 57 1 0.9636364 0.03636364 58 1 0.9636364 0.03636364 59 1 0.9636364 0.03636364 60 1 0.9636364 0.03636364 61 0 0.5000000 -0.50000000 62 0 0.0000000 0.00000000 63 0 0.5000000 -0.50000000 64 0 0.0000000 0.00000000 65 0 0.0000000 0.00000000 66 0 0.0000000 0.00000000 67 1 0.9636364 0.03636364 68 1 0.9636364 0.03636364 69 1 0.9636364 0.03636364 70 1 0.9636364 0.03636364 71 1 0.9636364 0.03636364 72 1 0.9636364 0.03636364 73 1 0.3043478 0.69565217 74 1 0.9636364 0.03636364 75 1 0.9636364 0.03636364 76 1 0.9636364 0.03636364 77 1 0.9636364 0.03636364 78 1 0.9636364 0.03636364 79 1 0.9636364 0.03636364 80 1 0.9636364 0.03636364 81 1 0.9636364 0.03636364 82 1 0.9636364 0.03636364 83 1 0.9636364 0.03636364 84 1 0.9636364 0.03636364 85 1 0.9636364 0.03636364 86 1 0.9636364 0.03636364 87 1 1.0000000 0.00000000 88 1 0.9636364 0.03636364 89 1 0.9636364 0.03636364 90 1 0.9636364 0.03636364 91 1 0.9636364 0.03636364 92 1 0.9636364 0.03636364 93 1 0.9636364 0.03636364 94 1 0.9636364 0.03636364 95 1 0.9636364 0.03636364 96 1 0.9636364 0.03636364 97 1 1.0000000 0.00000000 98 1 0.9636364 0.03636364 99 1 0.9636364 0.03636364 100 1 0.9636364 0.03636364 101 1 0.9636364 0.03636364 102 1 0.9636364 0.03636364 103 1 0.9636364 0.03636364 104 1 1.0000000 0.00000000 105 1 1.0000000 0.00000000 106 1 1.0000000 0.00000000 107 1 1.0000000 0.00000000 108 1 1.0000000 0.00000000 109 1 1.0000000 0.00000000 110 1 0.9636364 0.03636364 111 1 0.5000000 0.50000000 112 1 0.5000000 0.50000000 113 1 0.5000000 0.50000000 114 1 0.5000000 0.50000000 115 1 0.5000000 0.50000000 116 1 0.9636364 0.03636364 117 1 0.9636364 0.03636364 118 1 0.9636364 0.03636364 119 1 1.0000000 0.00000000 120 1 0.5000000 0.50000000 121 1 0.9636364 0.03636364 122 1 0.9636364 0.03636364 123 1 0.9636364 0.03636364 124 1 0.9636364 0.03636364 125 1 0.9636364 0.03636364 126 1 0.9636364 0.03636364 127 1 0.9636364 0.03636364 128 1 0.9636364 0.03636364 129 1 0.9636364 0.03636364 130 1 0.3043478 0.69565217 131 1 0.9636364 0.03636364 132 1 0.9636364 0.03636364 133 1 0.3043478 0.69565217 134 1 0.3043478 0.69565217 135 1 0.9636364 0.03636364 136 1 0.9636364 0.03636364 137 1 0.9636364 0.03636364 138 1 0.9636364 0.03636364 139 1 0.9636364 0.03636364 140 1 0.3043478 0.69565217 141 1 0.9636364 0.03636364 142 1 0.5000000 0.50000000 143 1 0.5000000 0.50000000 144 1 0.5000000 0.50000000 145 1 0.5000000 0.50000000 146 1 0.5000000 0.50000000 147 1 0.9636364 0.03636364 148 1 0.9636364 0.03636364 149 1 0.9636364 0.03636364 150 1 0.5000000 0.50000000 151 1 0.9636364 0.03636364 152 1 0.9636364 0.03636364 153 1 0.5000000 0.50000000 154 1 0.9636364 0.03636364 155 1 0.9636364 0.03636364 156 1 0.9636364 0.03636364 157 1 0.9636364 0.03636364 158 1 0.9636364 0.03636364 159 1 0.9636364 0.03636364 160 1 0.9636364 0.03636364 161 1 0.9636364 0.03636364 162 1 0.9636364 0.03636364 163 1 0.9636364 0.03636364 164 1 0.9636364 0.03636364 165 1 0.9636364 0.03636364 166 0 0.0000000 0.00000000 167 0 0.0000000 0.00000000 168 0 0.0000000 0.00000000 169 0 0.5000000 -0.50000000 170 0 0.0000000 0.00000000 171 0 0.0000000 0.00000000 172 0 0.3043478 -0.30434783 173 0 0.3043478 -0.30434783 174 0 0.3043478 -0.30434783 175 0 0.3043478 -0.30434783 176 0 0.3043478 -0.30434783 177 0 0.3043478 -0.30434783 178 1 1.0000000 0.00000000 179 1 1.0000000 0.00000000 180 1 0.9636364 0.03636364 181 1 0.9636364 0.03636364 182 1 0.9636364 0.03636364 183 1 1.0000000 0.00000000 184 0 0.3043478 -0.30434783 185 0 0.9636364 -0.96363636 186 0 0.3043478 -0.30434783 187 0 0.9636364 -0.96363636 188 0 0.3043478 -0.30434783 189 0 0.3043478 -0.30434783 190 0 0.5000000 -0.50000000 191 0 0.9636364 -0.96363636 192 0 0.5000000 -0.50000000 193 0 0.9636364 -0.96363636 194 0 0.5000000 -0.50000000 195 0 0.5000000 -0.50000000 > 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/41czr1386350971.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/5bwhw1386350971.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/6vm7r1386350971.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/7wq771386350971.tab") + } > > try(system("convert tmp/2o66n1386350971.ps tmp/2o66n1386350971.png",intern=TRUE)) character(0) > try(system("convert tmp/3m31e1386350971.ps tmp/3m31e1386350971.png",intern=TRUE)) character(0) > try(system("convert tmp/41czr1386350971.ps tmp/41czr1386350971.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 9.058 1.458 10.441