R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(10.81 + ,-0.2643 + ,0 + ,0 + ,24563400 + ,24.45 + ,2772.73 + ,0.0373 + ,115.7 + ,9.12 + ,-0.2643 + ,0 + ,0 + ,14163200 + ,23.62 + ,2151.83 + ,0.0353 + ,109.2 + ,11.03 + ,-0.2643 + ,0 + ,0 + ,18184800 + ,21.90 + ,1840.26 + ,0.0292 + ,116.9 + ,12.74 + ,-0.1918 + ,0 + ,0 + ,20810300 + ,27.12 + ,2116.24 + ,0.0327 + ,109.9 + ,9.98 + ,-0.1918 + ,0 + ,0 + ,12843000 + ,27.70 + ,2110.49 + ,0.0362 + ,116.1 + ,11.62 + ,-0.1918 + ,0 + ,0 + ,13866700 + ,29.23 + ,2160.54 + ,0.0325 + ,118.9 + ,9.40 + ,-0.2246 + ,0 + ,0 + ,15119200 + ,26.50 + ,2027.13 + ,0.0272 + ,116.3 + ,9.27 + ,-0.2246 + ,0 + ,0 + ,8301600 + ,22.84 + ,1805.43 + ,0.0272 + ,114.0 + ,7.76 + ,-0.2246 + ,0 + ,0 + ,14039600 + ,20.49 + ,1498.80 + ,0.0265 + ,97.0 + ,8.78 + ,0.3654 + ,0 + ,0 + ,12139700 + ,23.28 + ,1690.20 + ,0.0213 + ,85.3 + ,10.65 + ,0.3654 + ,0 + ,0 + ,9649000 + ,25.71 + ,1930.58 + ,0.019 + ,84.9 + ,10.95 + ,0.3654 + ,0 + ,0 + ,8513600 + ,26.52 + ,1950.40 + ,0.0155 + ,94.6 + ,12.36 + ,0.0447 + ,0 + ,0 + ,15278600 + ,25.51 + ,1934.03 + ,0.0114 + ,97.8 + ,10.85 + ,0.0447 + ,0 + ,0 + ,15590900 + ,23.36 + ,1731.49 + ,0.0114 + ,95.0 + ,11.84 + ,0.0447 + ,0 + ,0 + ,9691100 + ,24.15 + ,1845.35 + ,0.0148 + ,110.7 + ,12.14 + ,-0.0312 + ,0 + ,0 + ,10882700 + ,20.92 + ,1688.23 + ,0.0164 + ,108.5 + ,11.65 + ,-0.0312 + ,0 + ,0 + ,10294800 + ,20.38 + ,1615.73 + ,0.0118 + ,110.3 + ,8.86 + ,-0.0312 + ,0 + ,0 + ,16031900 + ,21.90 + ,1463.21 + ,0.0107 + ,106.3 + ,7.63 + ,-0.0048 + ,0 + ,0 + ,13683600 + ,19.21 + ,1328.26 + ,0.0146 + ,97.4 + ,7.38 + ,-0.0048 + ,0 + ,0 + ,8677200 + ,19.65 + ,1314.85 + ,0.018 + ,94.5 + ,7.25 + ,-0.0048 + ,0 + ,0 + ,9874100 + ,17.51 + ,1172.06 + ,0.0151 + ,93.7 + ,8.03 + ,0.0705 + ,0 + ,0 + ,10725500 + ,21.41 + ,1329.75 + ,0.0203 + ,79.6 + ,7.75 + ,0.0705 + ,0 + ,0 + ,8348400 + ,23.09 + ,1478.78 + ,0.022 + ,84.9 + ,7.16 + ,0.0705 + ,0 + ,0 + ,8046200 + ,20.70 + ,1335.51 + ,0.0238 + ,80.7 + ,7.18 + ,-0.0134 + ,0 + ,0 + ,10862300 + ,19.00 + ,1320.91 + ,0.026 + ,78.8 + ,7.51 + ,-0.0134 + ,0 + ,0 + ,8100300 + ,19.04 + ,1337.52 + ,0.0298 + ,64.8 + ,7.07 + ,-0.0134 + ,0 + ,0 + ,7287500 + ,19.45 + ,1341.17 + ,0.0302 + ,61.4 + ,7.11 + ,0.0812 + ,0 + ,0 + ,14002500 + ,20.54 + ,1464.31 + ,0.0222 + ,81.0 + ,8.98 + ,0.0812 + ,0 + ,0 + ,19037900 + ,19.77 + ,1595.91 + ,0.0206 + ,83.6 + ,9.53 + ,0.0812 + ,0 + ,0 + ,10774600 + ,20.60 + ,1622.80 + ,0.0211 + ,83.5 + ,10.54 + ,0.1885 + ,0 + ,0 + ,8960600 + ,21.21 + ,1735.02 + ,0.0211 + ,77.0 + ,11.31 + ,0.1885 + ,0 + ,0 + ,7773300 + ,21.30 + ,1810.45 + ,0.0216 + ,81.7 + ,10.36 + ,0.1885 + ,0 + ,0 + ,9579700 + ,22.33 + ,1786.94 + ,0.0232 + ,77.0 + ,11.44 + ,0.3628 + ,0 + ,0 + ,11270700 + ,21.12 + ,1932.21 + ,0.0204 + ,81.7 + ,10.45 + ,0.3628 + ,0 + ,0 + ,9492800 + ,20.77 + ,1960.26 + ,0.0177 + ,92.5 + ,10.69 + ,0.3628 + ,0 + ,0 + ,9136800 + ,22.11 + ,2003.37 + ,0.0188 + ,91.7 + ,11.28 + ,0.2942 + ,0 + ,0 + ,14487600 + ,22.34 + ,2066.15 + ,0.0193 + ,96.4 + ,11.96 + ,0.2942 + ,0 + ,0 + ,10133200 + ,21.43 + ,2029.82 + ,0.0169 + ,88.5 + ,13.52 + ,0.2942 + ,0 + ,0 + ,18659700 + ,20.14 + ,1994.22 + ,0.0174 + ,88.5 + ,12.89 + ,0.3036 + ,0 + ,0 + ,15980700 + ,21.11 + ,1920.15 + ,0.0229 + ,93.0 + ,14.03 + ,0.3036 + ,0 + ,0 + ,9732100 + ,21.19 + ,1986.74 + ,0.0305 + ,93.1 + ,16.27 + ,0.3036 + ,0 + ,0 + ,14626300 + ,23.07 + ,2047.79 + ,0.0327 + ,102.8 + ,16.17 + ,0.3703 + ,0 + ,0 + ,16904000 + ,23.01 + ,1887.36 + ,0.0299 + ,105.7 + ,17.25 + ,0.3703 + ,0 + ,0 + ,13616700 + ,22.12 + ,1838.10 + ,0.0265 + ,98.7 + ,19.38 + ,0.3703 + ,0 + ,0 + ,13772900 + ,22.40 + ,1896.84 + ,0.0254 + ,96.7 + ,26.20 + ,0.7398 + ,0 + ,0 + ,28749200 + ,22.66 + ,1974.99 + ,0.0319 + ,92.9 + ,33.53 + ,0.7398 + ,0 + ,0 + ,31408300 + ,24.21 + ,2096.81 + ,0.0352 + ,92.6 + ,32.20 + ,0.7398 + ,0 + ,0 + ,26342800 + ,24.13 + ,2175.44 + ,0.0326 + ,102.7 + ,38.45 + ,0.6988 + ,0 + ,0 + ,48909500 + ,23.73 + ,2062.41 + ,0.0297 + ,105.1 + ,44.86 + ,0.6988 + ,0 + ,0 + ,41542400 + ,22.79 + ,2051.72 + ,0.0301 + ,104.4 + ,41.67 + ,0.6988 + ,0 + ,0 + ,24857200 + ,21.89 + ,1999.23 + ,0.0315 + ,103.0 + ,36.06 + ,0.7478 + ,0 + ,0 + ,34093700 + ,22.92 + ,1921.65 + ,0.0351 + ,97.5 + ,39.76 + ,0.7478 + ,0 + ,0 + ,22555200 + ,23.44 + ,2068.22 + ,0.028 + ,103.1 + ,36.81 + ,0.7478 + ,0 + ,0 + ,19067500 + ,22.57 + ,2056.96 + ,0.0253 + ,106.2 + ,42.65 + ,0.5651 + ,0 + ,0 + ,19029100 + ,23.27 + ,2184.83 + ,0.0317 + ,103.6 + ,46.89 + ,0.5651 + ,0 + ,0 + ,15223200 + ,24.95 + ,2152.09 + ,0.0364 + ,105.5 + ,53.61 + ,0.5651 + ,0 + ,0 + ,21903700 + ,23.45 + ,2151.69 + ,0.0469 + ,87.5 + ,57.59 + ,0.6473 + ,0 + ,0 + ,33306600 + ,23.42 + ,2120.30 + ,0.0435 + ,85.2 + ,67.82 + ,0.6473 + ,0 + ,0 + ,23898100 + ,25.30 + ,2232.82 + ,0.0346 + ,98.3 + ,71.89 + ,0.6473 + ,0 + ,0 + ,23279600 + ,23.90 + ,2205.32 + ,0.0342 + ,103.8 + ,75.51 + ,0.3441 + ,0 + ,0 + ,40699800 + ,25.73 + ,2305.82 + ,0.0399 + ,106.8 + ,68.49 + ,0.3441 + ,0 + ,0 + ,37646000 + ,24.64 + ,2281.39 + ,0.036 + ,102.7 + ,62.72 + ,0.3441 + ,0 + ,0 + ,37277000 + ,24.95 + ,2339.79 + ,0.0336 + ,107.5 + ,70.39 + ,0.2415 + ,0 + ,0 + ,39246800 + ,22.15 + ,2322.57 + ,0.0355 + ,109.8 + ,59.77 + ,0.2415 + ,0 + ,0 + ,27418400 + ,20.85 + ,2178.88 + ,0.0417 + ,104.7 + ,57.27 + ,0.2415 + ,0 + ,0 + ,30318700 + ,21.45 + ,2172.09 + ,0.0432 + ,105.7 + ,67.96 + ,0.3151 + ,0 + ,0 + ,32808100 + ,22.15 + ,2091.47 + ,0.0415 + ,107.0 + ,67.85 + ,0.3151 + ,0 + ,0 + ,28668200 + ,23.75 + ,2183.75 + ,0.0382 + ,100.2 + ,76.98 + ,0.3151 + ,0 + ,0 + ,32370300 + ,25.27 + ,2258.43 + ,0.0206 + ,105.9 + ,81.08 + ,0.239 + ,0 + ,0 + ,24171100 + ,26.53 + ,2366.71 + ,0.0131 + ,105.1 + ,91.66 + ,0.239 + ,0 + ,0 + ,25009100 + ,27.22 + ,2431.77 + ,0.0197 + ,105.3 + ,84.84 + ,0.239 + ,0 + ,0 + ,32084300 + ,27.69 + ,2415.29 + ,0.0254 + ,110.0 + ,85.73 + ,0.2127 + ,0 + ,0 + ,50117500 + ,28.61 + ,2463.93 + ,0.0208 + ,110.2 + ,84.61 + ,0.2127 + ,0 + ,0 + ,27522200 + ,26.21 + ,2416.15 + ,0.0242 + ,111.2 + ,92.91 + ,0.2127 + ,0 + ,0 + ,26816800 + ,25.93 + ,2421.64 + ,0.0278 + ,108.2 + ,99.80 + ,0.273 + ,0 + ,0 + ,25136100 + ,27.86 + ,2525.09 + ,0.0257 + ,106.3 + ,121.19 + ,0.273 + ,0 + ,0 + ,30295600 + ,28.65 + ,2604.52 + ,0.0269 + ,108.5 + ,122.04 + ,0.273 + ,0.273 + ,0 + ,41526100 + ,27.51 + ,2603.23 + ,0.0269 + ,105.3 + ,131.76 + ,0.3657 + ,0.3657 + ,0 + ,43845100 + ,27.06 + ,2546.27 + ,0.0236 + ,111.9 + ,138.48 + ,0.3657 + ,0.3657 + ,0 + ,39188900 + ,26.91 + ,2596.36 + ,0.0197 + ,105.6 + ,153.47 + ,0.3657 + ,0.3657 + ,0 + ,40496400 + ,27.60 + ,2701.50 + ,0.0276 + ,99.5 + ,189.95 + ,0.4643 + ,0.4643 + ,0 + ,37438400 + ,34.48 + ,2859.12 + ,0.0354 + ,95.2 + ,182.22 + ,0.4643 + ,0.4643 + ,0 + ,46553700 + ,31.58 + ,2660.96 + ,0.0431 + ,87.8 + ,198.08 + ,0.4643 + ,0.4643 + ,0 + ,31771400 + ,33.46 + ,2652.28 + ,0.0408 + ,90.6 + ,135.36 + ,0.5096 + ,0.5096 + ,0 + ,62108100 + ,30.64 + ,2389.86 + ,0.0428 + ,87.9 + ,125.02 + ,0.5096 + ,0.5096 + ,0 + ,46645400 + ,25.66 + ,2271.48 + ,0.0403 + ,76.4 + ,143.50 + ,0.5096 + ,0.5096 + ,0 + ,42313100 + ,26.78 + ,2279.10 + ,0.0398 + ,65.9 + ,173.95 + ,0.3592 + ,0.3592 + ,0 + ,38841700 + ,26.91 + ,2412.80 + ,0.0394 + ,62.3 + ,188.75 + ,0.3592 + ,0.3592 + ,0 + ,32650300 + ,26.82 + ,2522.66 + ,0.0418 + ,57.2 + ,167.44 + ,0.3592 + ,0.3592 + ,0 + ,34281100 + ,26.05 + ,2292.98 + ,0.0502 + ,50.4 + ,158.95 + ,0.7439 + ,0.7439 + ,0 + ,33096200 + ,24.36 + ,2325.55 + ,0.056 + ,51.9 + ,169.53 + ,0.7439 + ,0.7439 + ,0 + ,23273800 + ,25.94 + ,2367.52 + ,0.0537 + ,58.5 + ,113.66 + ,0.7439 + ,0.7439 + ,0 + ,43697600 + ,25.37 + ,2091.88 + ,0.0494 + ,61.4 + ,107.59 + ,0.139 + ,0.139 + ,0 + ,66902300 + ,21.23 + ,1720.95 + ,0.0366 + ,38.8 + ,92.67 + ,0.139 + ,0.139 + ,0 + ,44957200 + ,19.35 + ,1535.57 + ,0.0107 + ,44.9 + ,85.35 + ,0.139 + ,0.139 + ,0 + ,33800900 + ,18.61 + ,1577.03 + ,0.0009 + ,38.6 + ,90.13 + ,0.1383 + ,0.1383 + ,0 + ,33487900 + ,16.37 + ,1476.42 + ,0.0003 + ,4.0 + ,89.31 + ,0.1383 + ,0.1383 + ,0 + ,27394900 + ,15.56 + ,1377.84 + ,0.0024 + ,25.3 + ,105.12 + ,0.1383 + ,0.1383 + ,0 + ,25963400 + ,17.70 + ,1528.59 + ,-0.0038 + ,26.9 + ,125.83 + ,0.2874 + ,0.2874 + ,0 + ,20952600 + ,19.52 + ,1717.30 + ,-0.0074 + ,40.8 + ,135.81 + ,0.2874 + ,0.2874 + ,0 + ,17702900 + ,20.26 + ,1774.33 + ,-0.0128 + ,54.8 + ,142.43 + ,0.2874 + ,0.2874 + ,0 + ,21282100 + ,23.05 + ,1835.04 + ,-0.0143 + ,49.3 + ,163.39 + ,0.0596 + ,0.0596 + ,0 + ,18449100 + ,22.81 + ,1978.50 + ,-0.021 + ,47.4 + ,168.21 + ,0.0596 + ,0.0596 + ,0 + ,14415700 + ,24.04 + ,2009.06 + ,-0.0148 + ,54.5 + ,185.35 + ,0.0596 + ,0.0596 + ,0 + ,17906300 + ,25.08 + ,2122.42 + ,-0.0129 + ,53.4 + ,188.50 + ,0.3201 + ,0.3201 + ,0 + ,22197500 + ,27.04 + ,2045.11 + ,-0.0018 + ,48.7 + ,199.91 + ,0.3201 + ,0.3201 + ,0 + ,15856500 + ,28.81 + ,2144.60 + ,0.0184 + ,50.6 + ,210.73 + ,0.3201 + ,0.3201 + ,0 + ,19068700 + ,29.86 + ,2269.15 + ,0.0272 + ,53.6 + ,192.06 + ,0.486 + ,0.486 + ,0 + ,30855100 + ,27.61 + ,2147.35 + ,0.0263 + ,56.5 + ,204.62 + ,0.486 + ,0.486 + ,0 + ,21209000 + ,28.22 + ,2238.26 + ,0.0214 + ,46.4 + ,235.00 + ,0.486 + ,0.486 + ,0 + ,19541600 + ,28.83 + ,2397.96 + ,0.0231 + ,52.3 + ,261.09 + ,0.6129 + ,0.6129 + ,0.6129 + ,21955000 + ,30.06 + ,2461.19 + ,0.0224 + ,57.7 + ,256.88 + ,0.6129 + ,0.6129 + ,0.6129 + ,33725900 + ,25.51 + ,2257.04 + ,0.0202 + ,62.7 + ,251.53 + ,0.6129 + ,0.6129 + ,0.6129 + ,28192800 + ,22.75 + ,2109.24 + ,0.0105 + ,54.3 + ,257.25 + ,0.6665 + ,0.6665 + ,0.6665 + ,27377000 + ,25.52 + ,2254.70 + ,0.0124 + ,51.0 + ,243.10 + ,0.6665 + ,0.6665 + ,0.6665 + ,16228100 + ,23.33 + ,2114.03 + ,0.0115 + ,53.2 + ,283.75 + ,0.6665 + ,0.6665 + ,0.6665 + ,21278900 + ,24.34 + ,2368.62 + ,0.0114 + ,48.6) + ,dim=c(9 + ,117) + ,dimnames=list(c('APPLE' + ,'REV.GROWTH' + ,'IPHONE' + ,'IPAD' + ,'VOLUME' + ,'MICROSOFT' + ,'NASDAQ' + ,'INFLATION' + ,'CONS.CONF') + ,1:117)) > y <- array(NA,dim=c(9,117),dimnames=list(c('APPLE','REV.GROWTH','IPHONE','IPAD','VOLUME','MICROSOFT','NASDAQ','INFLATION','CONS.CONF'),1:117)) > 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 = '' > par2 = 'none' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. Ian E. Holliday > #To cite this work: Ian E. Holliday, 2009, YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: > #Technical description: > library(party) Loading required package: survival Loading required package: splines Loading required package: grid Loading required package: modeltools Loading required package: stats4 Loading required package: coin Loading required package: mvtnorm Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : 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) Attaching package: 'Hmisc' The following object(s) are masked from package:survival : untangle.specials The following object(s) are masked from package:base : format.pval, round.POSIXt, trunc.POSIXt, units > par1 <- as.numeric(par1) > par3 <- as.numeric(par3) > x <- data.frame(t(y)) > is.data.frame(x) [1] TRUE > x <- x[!is.na(x[,par1]),] > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "APPLE" > x[,par1] [1] 10.81 9.12 11.03 12.74 9.98 11.62 9.40 9.27 7.76 8.78 [11] 10.65 10.95 12.36 10.85 11.84 12.14 11.65 8.86 7.63 7.38 [21] 7.25 8.03 7.75 7.16 7.18 7.51 7.07 7.11 8.98 9.53 [31] 10.54 11.31 10.36 11.44 10.45 10.69 11.28 11.96 13.52 12.89 [41] 14.03 16.27 16.17 17.25 19.38 26.20 33.53 32.20 38.45 44.86 [51] 41.67 36.06 39.76 36.81 42.65 46.89 53.61 57.59 67.82 71.89 [61] 75.51 68.49 62.72 70.39 59.77 57.27 67.96 67.85 76.98 81.08 [71] 91.66 84.84 85.73 84.61 92.91 99.80 121.19 122.04 131.76 138.48 [81] 153.47 189.95 182.22 198.08 135.36 125.02 143.50 173.95 188.75 167.44 [91] 158.95 169.53 113.66 107.59 92.67 85.35 90.13 89.31 105.12 125.83 [101] 135.81 142.43 163.39 168.21 185.35 188.50 199.91 210.73 192.06 204.62 [111] 235.00 261.09 256.88 251.53 257.25 243.10 283.75 > 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]) 7.07 7.11 7.16 7.18 7.25 7.38 7.51 7.63 7.75 7.76 8.03 1 1 1 1 1 1 1 1 1 1 1 8.78 8.86 8.98 9.12 9.27 9.4 9.53 9.98 10.36 10.45 10.54 1 1 1 1 1 1 1 1 1 1 1 10.65 10.69 10.81 10.85 10.95 11.03 11.28 11.31 11.44 11.62 11.65 1 1 1 1 1 1 1 1 1 1 1 11.84 11.96 12.14 12.36 12.74 12.89 13.52 14.03 16.17 16.27 17.25 1 1 1 1 1 1 1 1 1 1 1 19.38 26.2 32.2 33.53 36.06 36.81 38.45 39.76 41.67 42.65 44.86 1 1 1 1 1 1 1 1 1 1 1 46.89 53.61 57.27 57.59 59.77 62.72 67.82 67.85 67.96 68.49 70.39 1 1 1 1 1 1 1 1 1 1 1 71.89 75.51 76.98 81.08 84.61 84.84 85.35 85.73 89.31 90.13 91.66 1 1 1 1 1 1 1 1 1 1 1 92.67 92.91 99.8 105.12 107.59 113.66 121.19 122.04 125.02 125.83 131.76 1 1 1 1 1 1 1 1 1 1 1 135.36 135.81 138.48 142.43 143.5 153.47 158.95 163.39 167.44 168.21 169.53 1 1 1 1 1 1 1 1 1 1 1 173.95 182.22 185.35 188.5 188.75 189.95 192.06 198.08 199.91 204.62 210.73 1 1 1 1 1 1 1 1 1 1 1 235 243.1 251.53 256.88 257.25 261.09 283.75 1 1 1 1 1 1 1 > colnames(x) [1] "APPLE" "REV.GROWTH" "IPHONE" "IPAD" "VOLUME" [6] "MICROSOFT" "NASDAQ" "INFLATION" "CONS.CONF" > colnames(x)[par1] [1] "APPLE" > x[,par1] [1] 10.81 9.12 11.03 12.74 9.98 11.62 9.40 9.27 7.76 8.78 [11] 10.65 10.95 12.36 10.85 11.84 12.14 11.65 8.86 7.63 7.38 [21] 7.25 8.03 7.75 7.16 7.18 7.51 7.07 7.11 8.98 9.53 [31] 10.54 11.31 10.36 11.44 10.45 10.69 11.28 11.96 13.52 12.89 [41] 14.03 16.27 16.17 17.25 19.38 26.20 33.53 32.20 38.45 44.86 [51] 41.67 36.06 39.76 36.81 42.65 46.89 53.61 57.59 67.82 71.89 [61] 75.51 68.49 62.72 70.39 59.77 57.27 67.96 67.85 76.98 81.08 [71] 91.66 84.84 85.73 84.61 92.91 99.80 121.19 122.04 131.76 138.48 [81] 153.47 189.95 182.22 198.08 135.36 125.02 143.50 173.95 188.75 167.44 [91] 158.95 169.53 113.66 107.59 92.67 85.35 90.13 89.31 105.12 125.83 [101] 135.81 142.43 163.39 168.21 185.35 188.50 199.91 210.73 192.06 204.62 [111] 235.00 261.09 256.88 251.53 257.25 243.10 283.75 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/www/html/rcomp/tmp/1goe11293197797.tab") + } + } > m Conditional inference tree with 8 terminal nodes Response: APPLE Inputs: REV.GROWTH, IPHONE, IPAD, VOLUME, MICROSOFT, NASDAQ, INFLATION, CONS.CONF Number of observations: 117 1) IPHONE <= 0; criterion = 1, statistic = 83.123 2) VOLUME <= 20810300; criterion = 1, statistic = 42.288 3) REV.GROWTH <= 0.3628; criterion = 1, statistic = 18.22 4) NASDAQ <= 1595.91; criterion = 1, statistic = 21.723 5)* weights = 13 4) NASDAQ > 1595.91 6)* weights = 25 3) REV.GROWTH > 0.3628 7)* weights = 9 2) VOLUME > 20810300 8) MICROSOFT <= 24.95; criterion = 0.998, statistic = 13.371 9)* weights = 19 8) MICROSOFT > 24.95 10)* weights = 11 1) IPHONE > 0 11) REV.GROWTH <= 0.2874; criterion = 0.996, statistic = 20.263 12)* weights = 13 11) REV.GROWTH > 0.2874 13) VOLUME <= 33725900; criterion = 0.997, statistic = 16.28 14)* weights = 16 13) VOLUME > 33725900 15)* weights = 11 > postscript(file="/var/www/html/rcomp/tmp/2goe11293197797.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/www/html/rcomp/tmp/3goe11293197797.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 10.81 49.530526 -38.72052632 2 9.12 11.450800 -2.33080000 3 11.03 11.450800 -0.42080000 4 12.74 11.450800 1.28920000 5 9.98 11.450800 -1.47080000 6 11.62 11.450800 0.16920000 7 9.40 11.450800 -2.05080000 8 9.27 11.450800 -2.18080000 9 7.76 7.666923 0.09307692 10 8.78 23.281111 -14.50111111 11 10.65 23.281111 -12.63111111 12 10.95 23.281111 -12.33111111 13 12.36 11.450800 0.90920000 14 10.85 11.450800 -0.60080000 15 11.84 11.450800 0.38920000 16 12.14 11.450800 0.68920000 17 11.65 11.450800 0.19920000 18 8.86 7.666923 1.19307692 19 7.63 7.666923 -0.03692308 20 7.38 7.666923 -0.28692308 21 7.25 7.666923 -0.41692308 22 8.03 7.666923 0.36307692 23 7.75 7.666923 0.08307692 24 7.16 7.666923 -0.50692308 25 7.18 7.666923 -0.48692308 26 7.51 7.666923 -0.15692308 27 7.07 7.666923 -0.59692308 28 7.11 7.666923 -0.55692308 29 8.98 7.666923 1.31307692 30 9.53 11.450800 -1.92080000 31 10.54 11.450800 -0.91080000 32 11.31 11.450800 -0.14080000 33 10.36 11.450800 -1.09080000 34 11.44 11.450800 -0.01080000 35 10.45 11.450800 -1.00080000 36 10.69 11.450800 -0.76080000 37 11.28 11.450800 -0.17080000 38 11.96 11.450800 0.50920000 39 13.52 11.450800 2.06920000 40 12.89 11.450800 1.43920000 41 14.03 11.450800 2.57920000 42 16.27 11.450800 4.81920000 43 16.17 23.281111 -7.11111111 44 17.25 23.281111 -6.03111111 45 19.38 23.281111 -3.90111111 46 26.20 49.530526 -23.33052632 47 33.53 49.530526 -16.00052632 48 32.20 49.530526 -17.33052632 49 38.45 49.530526 -11.08052632 50 44.86 49.530526 -4.67052632 51 41.67 49.530526 -7.86052632 52 36.06 49.530526 -13.47052632 53 39.76 49.530526 -9.77052632 54 36.81 23.281111 13.52888889 55 42.65 23.281111 19.36888889 56 46.89 23.281111 23.60888889 57 53.61 49.530526 4.07947368 58 57.59 49.530526 8.05947368 59 67.82 87.466364 -19.64636364 60 71.89 49.530526 22.35947368 61 75.51 87.466364 -11.95636364 62 68.49 49.530526 18.95947368 63 62.72 49.530526 13.18947368 64 70.39 49.530526 20.85947368 65 59.77 49.530526 10.23947368 66 57.27 49.530526 7.73947368 67 67.96 49.530526 18.42947368 68 67.85 49.530526 18.31947368 69 76.98 87.466364 -10.48636364 70 81.08 87.466364 -6.38636364 71 91.66 87.466364 4.19363636 72 84.84 87.466364 -2.62636364 73 85.73 87.466364 -1.73636364 74 84.61 87.466364 -2.85636364 75 92.91 87.466364 5.44363636 76 99.80 87.466364 12.33363636 77 121.19 87.466364 33.72363636 78 122.04 124.094615 -2.05461538 79 131.76 150.437273 -18.67727273 80 138.48 150.437273 -11.95727273 81 153.47 150.437273 3.03272727 82 189.95 150.437273 39.51272727 83 182.22 150.437273 31.78272727 84 198.08 218.733125 -20.65312500 85 135.36 150.437273 -15.07727273 86 125.02 150.437273 -25.41727273 87 143.50 150.437273 -6.93727273 88 173.95 150.437273 23.51272727 89 188.75 218.733125 -29.98312500 90 167.44 150.437273 17.00272727 91 158.95 218.733125 -59.78312500 92 169.53 218.733125 -49.20312500 93 113.66 150.437273 -36.77727273 94 107.59 124.094615 -16.50461538 95 92.67 124.094615 -31.42461538 96 85.35 124.094615 -38.74461538 97 90.13 124.094615 -33.96461538 98 89.31 124.094615 -34.78461538 99 105.12 124.094615 -18.97461538 100 125.83 124.094615 1.73538462 101 135.81 124.094615 11.71538462 102 142.43 124.094615 18.33538462 103 163.39 124.094615 39.29538462 104 168.21 124.094615 44.11538462 105 185.35 124.094615 61.25538462 106 188.50 218.733125 -30.23312500 107 199.91 218.733125 -18.82312500 108 210.73 218.733125 -8.00312500 109 192.06 218.733125 -26.67312500 110 204.62 218.733125 -14.11312500 111 235.00 218.733125 16.26687500 112 261.09 218.733125 42.35687500 113 256.88 218.733125 38.14687500 114 251.53 218.733125 32.79687500 115 257.25 218.733125 38.51687500 116 243.10 218.733125 24.36687500 117 283.75 218.733125 65.01687500 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/www/html/rcomp/tmp/4rgd41293197797.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/www/html/rcomp/tmp/5n7bd1293197797.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/www/html/rcomp/tmp/6yhag1293197797.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/www/html/rcomp/tmp/7jhql1293197797.tab") + } > try(system("convert tmp/2goe11293197797.ps tmp/2goe11293197797.png",intern=TRUE)) character(0) > try(system("convert tmp/3goe11293197797.ps tmp/3goe11293197797.png",intern=TRUE)) character(0) > try(system("convert tmp/4rgd41293197797.ps tmp/4rgd41293197797.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.003 0.662 6.589