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(18 + ,1760 + ,89 + ,20465 + ,70 + ,20 + ,1609 + ,56 + ,33629 + ,80 + ,0 + ,192 + ,18 + ,1423 + ,0 + ,26 + ,2182 + ,92 + ,25629 + ,81 + ,31 + ,3367 + ,131 + ,54002 + ,124 + ,36 + ,6727 + ,257 + ,151036 + ,140 + ,23 + ,1619 + ,55 + ,33287 + ,88 + ,30 + ,1507 + ,56 + ,31172 + ,115 + ,30 + ,1682 + ,42 + ,28113 + ,109 + ,26 + ,2812 + ,92 + ,57803 + ,104 + ,24 + ,1943 + ,74 + ,49830 + ,63 + ,30 + ,2017 + ,66 + ,52143 + ,118 + ,21 + ,1702 + ,96 + ,21055 + ,68 + ,25 + ,3034 + ,110 + ,47007 + ,100 + ,18 + ,1379 + ,55 + ,28735 + ,63 + ,19 + ,1517 + ,79 + ,59147 + ,74 + ,33 + ,1637 + ,53 + ,78950 + ,132 + ,15 + ,1169 + ,54 + ,13497 + ,54 + ,34 + ,2384 + ,84 + ,46154 + ,134 + ,18 + ,726 + ,24 + ,53249 + ,57 + ,15 + ,993 + ,55 + ,10726 + ,59 + ,30 + ,2683 + ,96 + ,83700 + ,113 + ,25 + ,1713 + ,70 + ,40400 + ,96 + ,34 + ,2027 + ,50 + ,33797 + ,96 + ,21 + ,1818 + ,81 + ,36205 + ,78 + ,21 + ,1393 + ,28 + ,30165 + ,80 + ,25 + ,2000 + ,154 + ,58534 + ,93 + ,31 + ,1346 + ,85 + ,44663 + ,109 + ,31 + ,2676 + ,115 + ,92556 + ,115 + ,20 + ,2106 + ,43 + ,40078 + ,79 + ,28 + ,1591 + ,43 + ,34711 + ,103 + ,20 + ,1519 + ,43 + ,31076 + ,65 + ,17 + ,2171 + ,101 + ,74608 + ,66 + ,25 + ,3003 + ,121 + ,58092 + ,100 + ,24 + ,2364 + ,52 + ,42009 + ,96 + ,0 + ,1 + ,1 + ,0 + ,0 + ,27 + ,2017 + ,60 + ,36022 + ,105 + ,14 + ,1564 + ,50 + ,23333 + ,51 + ,32 + ,2072 + ,47 + ,53349 + ,108 + ,31 + ,2106 + ,63 + ,92596 + ,124 + ,21 + ,2270 + ,69 + ,49598 + ,81 + ,34 + ,1643 + ,56 + ,44093 + ,136 + ,23 + ,957 + ,29 + ,84205 + ,84 + ,24 + ,2025 + ,77 + ,63369 + ,92 + ,26 + ,1236 + ,46 + ,60132 + ,103 + ,22 + ,1178 + ,91 + ,37403 + ,82 + ,35 + ,744 + ,31 + ,24460 + ,106 + ,21 + ,1976 + ,92 + ,46456 + ,84 + ,31 + ,2224 + ,85 + ,66616 + ,124 + ,26 + ,2561 + ,56 + ,41554 + ,97 + ,22 + ,658 + ,28 + ,22346 + ,82 + ,21 + ,1779 + ,65 + ,30874 + ,79 + ,27 + ,2355 + ,71 + ,68701 + ,97 + ,30 + ,2017 + ,77 + ,35728 + ,107 + ,33 + ,1758 + ,59 + ,29010 + ,126 + ,11 + ,1675 + ,54 + ,23110 + ,40 + ,26 + ,1760 + ,62 + ,38844 + ,96 + ,26 + ,875 + ,23 + ,27084 + ,100 + ,23 + ,1169 + ,65 + ,35139 + ,91 + ,38 + ,2789 + ,93 + ,57476 + ,136 + ,29 + ,1606 + ,56 + ,33277 + ,116 + ,19 + ,2020 + ,76 + ,31141 + ,76 + ,19 + ,1300 + ,58 + ,61281 + ,65 + ,26 + ,1235 + ,35 + ,25820 + ,96 + ,26 + ,1215 + ,32 + ,23284 + ,97 + ,29 + ,1230 + ,38 + ,35378 + ,107 + ,36 + ,2226 + ,67 + ,74990 + ,144 + ,25 + ,2897 + ,65 + ,29653 + ,90 + ,24 + ,1071 + ,38 + ,64622 + ,93 + ,21 + ,340 + ,15 + ,4157 + ,78 + ,19 + ,2704 + ,110 + ,29245 + ,72 + ,12 + ,1247 + ,64 + ,50008 + ,45 + ,30 + ,1422 + ,64 + ,52338 + ,120 + ,21 + ,1535 + ,68 + ,13310 + ,59 + ,34 + ,2593 + ,66 + ,92901 + ,133 + ,32 + ,1397 + ,42 + ,10956 + ,117 + ,28 + ,2162 + ,58 + ,34241 + ,123 + ,28 + ,2513 + ,94 + ,75043 + ,110 + ,21 + ,917 + ,26 + ,21152 + ,75 + ,31 + ,1234 + ,71 + ,42249 + ,114 + ,26 + ,917 + ,66 + ,42005 + ,94 + ,29 + ,1924 + ,59 + ,41152 + ,116 + ,23 + ,853 + ,27 + ,14399 + ,86 + ,25 + ,1398 + ,34 + ,28263 + ,90 + ,22 + ,986 + ,44 + ,17215 + ,87 + ,26 + ,1608 + ,47 + ,48140 + ,99 + ,33 + ,2577 + ,220 + ,62897 + ,132 + ,24 + ,1201 + ,108 + ,22883 + ,96 + ,24 + ,1189 + ,56 + ,41622 + ,91 + ,21 + ,1431 + ,50 + ,40715 + ,77 + ,28 + ,1698 + ,40 + ,65897 + ,104 + ,27 + ,2185 + ,74 + ,76542 + ,97 + ,25 + ,1228 + ,56 + ,37477 + ,94 + ,15 + ,1266 + ,58 + ,53216 + ,60 + ,13 + ,830 + ,36 + ,40911 + ,46 + ,36 + ,2238 + ,111 + ,57021 + ,135 + ,24 + ,1787 + ,68 + ,73116 + ,90 + ,1 + ,223 + ,12 + ,3895 + ,2 + ,24 + ,2254 + ,100 + ,46609 + ,96 + ,31 + ,1952 + ,75 + ,29351 + ,109 + ,4 + ,665 + ,28 + ,2325 + ,15 + ,20 + ,804 + ,22 + ,31747 + ,64 + ,23 + ,1211 + ,49 + ,32665 + ,88 + ,23 + ,1143 + ,57 + ,19249 + ,84 + ,12 + ,710 + ,38 + ,15292 + ,46 + ,16 + ,596 + ,22 + ,5842 + ,59 + ,29 + ,1353 + ,44 + ,33994 + ,116 + ,10 + ,971 + ,32 + ,13018 + ,29 + ,0 + ,0 + ,0 + ,0 + ,0 + ,25 + ,1030 + ,31 + ,98177 + ,91 + ,21 + ,1130 + ,66 + ,37941 + ,76 + ,23 + ,1284 + ,44 + ,31032 + ,83 + ,21 + ,1438 + ,61 + ,32683 + ,84 + ,21 + ,849 + ,57 + ,34545 + ,65 + ,0 + ,78 + ,5 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,23 + ,925 + ,39 + ,27525 + ,84 + ,29 + ,1518 + ,78 + ,66856 + ,99 + ,28 + ,1946 + ,95 + ,28549 + ,112 + ,23 + ,914 + ,37 + ,38610 + ,92 + ,1 + ,778 + ,19 + ,2781 + ,3 + ,29 + ,1713 + ,71 + ,41211 + ,109 + ,17 + ,895 + ,40 + ,22698 + ,71 + ,29 + ,1756 + ,52 + ,41194 + ,106 + ,12 + ,701 + ,40 + ,32689 + ,48 + ,2 + ,285 + ,12 + ,5752 + ,8 + ,21 + ,1774 + ,55 + ,26757 + ,80 + ,25 + ,1071 + ,29 + ,22527 + ,95 + ,29 + ,1582 + ,46 + ,44810 + ,116 + ,2 + ,256 + ,9 + ,0 + ,8 + ,0 + ,98 + ,9 + ,0 + ,0 + ,18 + ,1358 + ,55 + ,100674 + ,56 + ,1 + ,41 + ,3 + ,0 + ,4 + ,21 + ,1771 + ,58 + ,57786 + ,70 + ,0 + ,42 + ,3 + ,0 + ,0 + ,4 + ,528 + ,16 + ,5444 + ,14 + ,0 + ,0 + ,0 + ,0 + ,0 + ,25 + ,1026 + ,45 + ,28470 + ,91 + ,26 + ,1296 + ,38 + ,61849 + ,89 + ,0 + ,81 + ,4 + ,0 + ,0 + ,4 + ,257 + ,13 + ,2179 + ,12 + ,17 + ,914 + ,23 + ,8019 + ,60 + ,21 + ,1178 + ,50 + ,39644 + ,80 + ,22 + ,1080 + ,19 + ,23494 + ,88) + ,dim=c(5 + ,144) + ,dimnames=list(c('CPR' + ,'PGVWS' + ,'LGNS' + ,'CMPCH' + ,'TNSFM') + ,1:144)) > y <- array(NA,dim=c(5,144),dimnames=list(c('CPR','PGVWS','LGNS','CMPCH','TNSFM'),1:144)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'no' > par3 = 'No linear trend' > par2 = 'none' > par1 = '5' > #'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) Warning message: NAs introduced by coercion > 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] "TNSFM" > x[,par1] [1] 70 80 0 81 124 140 88 115 109 104 63 118 68 100 63 74 132 54 [19] 134 57 59 113 96 96 78 80 93 109 115 79 103 65 66 100 96 0 [37] 105 51 108 124 81 136 84 92 103 82 106 84 124 97 82 79 97 107 [55] 126 40 96 100 91 136 116 76 65 96 97 107 144 90 93 78 72 45 [73] 120 59 133 117 123 110 75 114 94 116 86 90 87 99 132 96 91 77 [91] 104 97 94 60 46 135 90 2 96 109 15 64 88 84 46 59 116 29 [109] 0 91 76 83 84 65 0 0 84 99 112 92 3 109 71 106 48 8 [127] 80 95 116 8 0 56 4 70 0 14 0 91 89 0 12 60 80 88 > 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 2 3 4 8 12 14 15 29 40 45 46 48 51 54 56 57 59 60 63 9 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 3 2 2 64 65 66 68 70 71 72 74 75 76 77 78 79 80 81 82 83 84 86 87 1 3 1 1 2 1 1 1 1 2 1 2 2 4 2 2 1 5 1 1 88 89 90 91 92 93 94 95 96 97 99 100 103 104 105 106 107 108 109 110 3 1 3 4 2 2 2 1 7 4 2 3 2 2 1 2 2 1 4 1 112 113 114 115 116 117 118 120 123 124 126 132 133 134 135 136 140 144 1 1 1 2 4 1 1 1 1 3 1 2 1 1 1 2 1 1 > colnames(x) [1] "CPR" "PGVWS" "LGNS" "CMPCH" "TNSFM" > colnames(x)[par1] [1] "TNSFM" > x[,par1] [1] 70 80 0 81 124 140 88 115 109 104 63 118 68 100 63 74 132 54 [19] 134 57 59 113 96 96 78 80 93 109 115 79 103 65 66 100 96 0 [37] 105 51 108 124 81 136 84 92 103 82 106 84 124 97 82 79 97 107 [55] 126 40 96 100 91 136 116 76 65 96 97 107 144 90 93 78 72 45 [73] 120 59 133 117 123 110 75 114 94 116 86 90 87 99 132 96 91 77 [91] 104 97 94 60 46 135 90 2 96 109 15 64 88 84 46 59 116 29 [109] 0 91 76 83 84 65 0 0 84 99 112 92 3 109 71 106 48 8 [127] 80 95 116 8 0 56 4 70 0 14 0 91 89 0 12 60 80 88 > 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/1qjd51324644233.tab") + } + } > m Conditional inference tree with 9 terminal nodes Response: TNSFM Inputs: CPR, PGVWS, LGNS, CMPCH Number of observations: 144 1) CPR <= 14; criterion = 1, statistic = 137.916 2) CPR <= 4; criterion = 1, statistic = 22.752 3)* weights = 17 2) CPR > 4 4)* weights = 7 1) CPR > 14 5) CPR <= 26; criterion = 1, statistic = 104.458 6) CPR <= 21; criterion = 1, statistic = 58.509 7) CPR <= 18; criterion = 1, statistic = 16.955 8)* weights = 11 7) CPR > 18 9)* weights = 24 6) CPR > 21 10) CPR <= 24; criterion = 0.999, statistic = 12.77 11)* weights = 21 10) CPR > 24 12)* weights = 21 5) CPR > 26 13) CPR <= 32; criterion = 1, statistic = 20.81 14) CPR <= 29; criterion = 0.983, statistic = 8.164 15)* weights = 16 14) CPR > 29 16)* weights = 15 13) CPR > 32 17)* weights = 12 > postscript(file="/var/wessaorg/rcomp/tmp/2jtge1324644233.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/3twcn1324644233.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 70 61.363636 8.63636364 2 80 74.541667 5.45833333 3 0 3.882353 -3.88235294 4 81 95.047619 -14.04761905 5 124 115.066667 8.93333333 6 140 129.166667 10.83333333 7 88 87.428571 0.57142857 8 115 115.066667 -0.06666667 9 109 115.066667 -6.06666667 10 104 95.047619 8.95238095 11 63 87.428571 -24.42857143 12 118 115.066667 2.93333333 13 68 74.541667 -6.54166667 14 100 95.047619 4.95238095 15 63 61.363636 1.63636364 16 74 74.541667 -0.54166667 17 132 129.166667 2.83333333 18 54 61.363636 -7.36363636 19 134 129.166667 4.83333333 20 57 61.363636 -4.36363636 21 59 61.363636 -2.36363636 22 113 115.066667 -2.06666667 23 96 95.047619 0.95238095 24 96 129.166667 -33.16666667 25 78 74.541667 3.45833333 26 80 74.541667 5.45833333 27 93 95.047619 -2.04761905 28 109 115.066667 -6.06666667 29 115 115.066667 -0.06666667 30 79 74.541667 4.45833333 31 103 108.500000 -5.50000000 32 65 74.541667 -9.54166667 33 66 61.363636 4.63636364 34 100 95.047619 4.95238095 35 96 87.428571 8.57142857 36 0 3.882353 -3.88235294 37 105 108.500000 -3.50000000 38 51 43.571429 7.42857143 39 108 115.066667 -7.06666667 40 124 115.066667 8.93333333 41 81 74.541667 6.45833333 42 136 129.166667 6.83333333 43 84 87.428571 -3.42857143 44 92 87.428571 4.57142857 45 103 95.047619 7.95238095 46 82 87.428571 -5.42857143 47 106 129.166667 -23.16666667 48 84 74.541667 9.45833333 49 124 115.066667 8.93333333 50 97 95.047619 1.95238095 51 82 87.428571 -5.42857143 52 79 74.541667 4.45833333 53 97 108.500000 -11.50000000 54 107 115.066667 -8.06666667 55 126 129.166667 -3.16666667 56 40 43.571429 -3.57142857 57 96 95.047619 0.95238095 58 100 95.047619 4.95238095 59 91 87.428571 3.57142857 60 136 129.166667 6.83333333 61 116 108.500000 7.50000000 62 76 74.541667 1.45833333 63 65 74.541667 -9.54166667 64 96 95.047619 0.95238095 65 97 95.047619 1.95238095 66 107 108.500000 -1.50000000 67 144 129.166667 14.83333333 68 90 95.047619 -5.04761905 69 93 87.428571 5.57142857 70 78 74.541667 3.45833333 71 72 74.541667 -2.54166667 72 45 43.571429 1.42857143 73 120 115.066667 4.93333333 74 59 74.541667 -15.54166667 75 133 129.166667 3.83333333 76 117 115.066667 1.93333333 77 123 108.500000 14.50000000 78 110 108.500000 1.50000000 79 75 74.541667 0.45833333 80 114 115.066667 -1.06666667 81 94 95.047619 -1.04761905 82 116 108.500000 7.50000000 83 86 87.428571 -1.42857143 84 90 95.047619 -5.04761905 85 87 87.428571 -0.42857143 86 99 95.047619 3.95238095 87 132 129.166667 2.83333333 88 96 87.428571 8.57142857 89 91 87.428571 3.57142857 90 77 74.541667 2.45833333 91 104 108.500000 -4.50000000 92 97 108.500000 -11.50000000 93 94 95.047619 -1.04761905 94 60 61.363636 -1.36363636 95 46 43.571429 2.42857143 96 135 129.166667 5.83333333 97 90 87.428571 2.57142857 98 2 3.882353 -1.88235294 99 96 87.428571 8.57142857 100 109 115.066667 -6.06666667 101 15 3.882353 11.11764706 102 64 74.541667 -10.54166667 103 88 87.428571 0.57142857 104 84 87.428571 -3.42857143 105 46 43.571429 2.42857143 106 59 61.363636 -2.36363636 107 116 108.500000 7.50000000 108 29 43.571429 -14.57142857 109 0 3.882353 -3.88235294 110 91 95.047619 -4.04761905 111 76 74.541667 1.45833333 112 83 87.428571 -4.42857143 113 84 74.541667 9.45833333 114 65 74.541667 -9.54166667 115 0 3.882353 -3.88235294 116 0 3.882353 -3.88235294 117 84 87.428571 -3.42857143 118 99 108.500000 -9.50000000 119 112 108.500000 3.50000000 120 92 87.428571 4.57142857 121 3 3.882353 -0.88235294 122 109 108.500000 0.50000000 123 71 61.363636 9.63636364 124 106 108.500000 -2.50000000 125 48 43.571429 4.42857143 126 8 3.882353 4.11764706 127 80 74.541667 5.45833333 128 95 95.047619 -0.04761905 129 116 108.500000 7.50000000 130 8 3.882353 4.11764706 131 0 3.882353 -3.88235294 132 56 61.363636 -5.36363636 133 4 3.882353 0.11764706 134 70 74.541667 -4.54166667 135 0 3.882353 -3.88235294 136 14 3.882353 10.11764706 137 0 3.882353 -3.88235294 138 91 95.047619 -4.04761905 139 89 95.047619 -6.04761905 140 0 3.882353 -3.88235294 141 12 3.882353 8.11764706 142 60 61.363636 -1.36363636 143 80 74.541667 5.45833333 144 88 87.428571 0.57142857 > 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/4qi641324644233.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/573751324644233.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/620ab1324644233.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/7lflo1324644233.tab") + } > > try(system("convert tmp/2jtge1324644233.ps tmp/2jtge1324644233.png",intern=TRUE)) character(0) > try(system("convert tmp/3twcn1324644233.ps tmp/3twcn1324644233.png",intern=TRUE)) character(0) > try(system("convert tmp/4qi641324644233.ps tmp/4qi641324644233.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.352 0.252 3.603