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 + ,1 + ,9.12 + ,-0.2643 + ,0 + ,0 + ,14163200 + ,23.62 + ,2151.83 + ,0.0353 + ,109.2 + ,2 + ,11.03 + ,-0.2643 + ,0 + ,0 + ,18184800 + ,21.90 + ,1840.26 + ,0.0292 + ,116.9 + ,3 + ,12.74 + ,-0.1918 + ,0 + ,0 + ,20810300 + ,27.12 + ,2116.24 + ,0.0327 + ,109.9 + ,4 + ,9.98 + ,-0.1918 + ,0 + ,0 + ,12843000 + ,27.70 + ,2110.49 + ,0.0362 + ,116.1 + ,5 + ,11.62 + ,-0.1918 + ,0 + ,0 + ,13866700 + ,29.23 + ,2160.54 + ,0.0325 + ,118.9 + ,6 + ,9.40 + ,-0.2246 + ,0 + ,0 + ,15119200 + ,26.50 + ,2027.13 + ,0.0272 + ,116.3 + ,7 + ,9.27 + ,-0.2246 + ,0 + ,0 + ,8301600 + ,22.84 + ,1805.43 + ,0.0272 + ,114.0 + ,8 + ,7.76 + ,-0.2246 + ,0 + ,0 + ,14039600 + ,20.49 + ,1498.80 + ,0.0265 + ,97.0 + ,9 + ,8.78 + ,0.3654 + ,0 + ,0 + ,12139700 + ,23.28 + ,1690.20 + ,0.0213 + ,85.3 + ,10 + ,10.65 + ,0.3654 + ,0 + ,0 + ,9649000 + ,25.71 + ,1930.58 + ,0.019 + ,84.9 + ,11 + ,10.95 + ,0.3654 + ,0 + ,0 + ,8513600 + ,26.52 + ,1950.40 + ,0.0155 + ,94.6 + ,12 + ,12.36 + ,0.0447 + ,0 + ,0 + ,15278600 + ,25.51 + ,1934.03 + ,0.0114 + ,97.8 + ,13 + ,10.85 + ,0.0447 + ,0 + ,0 + ,15590900 + ,23.36 + ,1731.49 + ,0.0114 + ,95.0 + ,14 + ,11.84 + ,0.0447 + ,0 + ,0 + ,9691100 + ,24.15 + ,1845.35 + ,0.0148 + ,110.7 + ,15 + ,12.14 + ,-0.0312 + ,0 + ,0 + ,10882700 + ,20.92 + ,1688.23 + ,0.0164 + ,108.5 + ,16 + ,11.65 + ,-0.0312 + ,0 + ,0 + ,10294800 + ,20.38 + ,1615.73 + ,0.0118 + ,110.3 + ,17 + ,8.86 + ,-0.0312 + ,0 + ,0 + ,16031900 + ,21.90 + ,1463.21 + ,0.0107 + ,106.3 + ,18 + ,7.63 + ,-0.0048 + ,0 + ,0 + ,13683600 + ,19.21 + ,1328.26 + ,0.0146 + ,97.4 + ,19 + ,7.38 + ,-0.0048 + ,0 + ,0 + ,8677200 + ,19.65 + ,1314.85 + ,0.018 + ,94.5 + ,20 + ,7.25 + ,-0.0048 + ,0 + ,0 + ,9874100 + ,17.51 + ,1172.06 + ,0.0151 + ,93.7 + ,21 + ,8.03 + ,0.0705 + ,0 + ,0 + ,10725500 + ,21.41 + ,1329.75 + ,0.0203 + ,79.6 + ,22 + ,7.75 + ,0.0705 + ,0 + ,0 + ,8348400 + ,23.09 + ,1478.78 + ,0.022 + ,84.9 + ,23 + ,7.16 + ,0.0705 + ,0 + ,0 + ,8046200 + ,20.70 + ,1335.51 + ,0.0238 + ,80.7 + ,24 + ,7.18 + ,-0.0134 + ,0 + ,0 + ,10862300 + ,19.00 + ,1320.91 + ,0.026 + ,78.8 + ,25 + ,7.51 + ,-0.0134 + ,0 + ,0 + ,8100300 + ,19.04 + ,1337.52 + ,0.0298 + ,64.8 + ,26 + ,7.07 + ,-0.0134 + ,0 + ,0 + ,7287500 + ,19.45 + ,1341.17 + ,0.0302 + ,61.4 + ,27 + ,7.11 + ,0.0812 + ,0 + ,0 + ,14002500 + ,20.54 + ,1464.31 + ,0.0222 + ,81.0 + ,28 + ,8.98 + ,0.0812 + ,0 + ,0 + ,19037900 + ,19.77 + ,1595.91 + ,0.0206 + ,83.6 + ,29 + ,9.53 + ,0.0812 + ,0 + ,0 + ,10774600 + ,20.60 + ,1622.80 + ,0.0211 + ,83.5 + ,30 + ,10.54 + ,0.1885 + ,0 + ,0 + ,8960600 + ,21.21 + ,1735.02 + ,0.0211 + ,77.0 + ,31 + ,11.31 + ,0.1885 + ,0 + ,0 + ,7773300 + ,21.30 + ,1810.45 + ,0.0216 + ,81.7 + ,32 + ,10.36 + ,0.1885 + ,0 + ,0 + ,9579700 + ,22.33 + ,1786.94 + ,0.0232 + ,77.0 + ,33 + ,11.44 + ,0.3628 + ,0 + ,0 + ,11270700 + ,21.12 + ,1932.21 + ,0.0204 + ,81.7 + ,34 + ,10.45 + ,0.3628 + ,0 + ,0 + ,9492800 + ,20.77 + ,1960.26 + ,0.0177 + ,92.5 + ,35 + ,10.69 + ,0.3628 + ,0 + ,0 + ,9136800 + ,22.11 + ,2003.37 + ,0.0188 + ,91.7 + ,36 + ,11.28 + ,0.2942 + ,0 + ,0 + ,14487600 + ,22.34 + ,2066.15 + ,0.0193 + ,96.4 + ,37 + ,11.96 + ,0.2942 + ,0 + ,0 + ,10133200 + ,21.43 + ,2029.82 + ,0.0169 + ,88.5 + ,38 + ,13.52 + ,0.2942 + ,0 + ,0 + ,18659700 + ,20.14 + ,1994.22 + ,0.0174 + ,88.5 + ,39 + ,12.89 + ,0.3036 + ,0 + ,0 + ,15980700 + ,21.11 + ,1920.15 + ,0.0229 + ,93.0 + ,40 + ,14.03 + ,0.3036 + ,0 + ,0 + ,9732100 + ,21.19 + ,1986.74 + ,0.0305 + ,93.1 + ,41 + ,16.27 + ,0.3036 + ,0 + ,0 + ,14626300 + ,23.07 + ,2047.79 + ,0.0327 + ,102.8 + ,42 + ,16.17 + ,0.3703 + ,0 + ,0 + ,16904000 + ,23.01 + ,1887.36 + ,0.0299 + ,105.7 + ,43 + ,17.25 + ,0.3703 + ,0 + ,0 + ,13616700 + ,22.12 + ,1838.10 + ,0.0265 + ,98.7 + ,44 + ,19.38 + ,0.3703 + ,0 + ,0 + ,13772900 + ,22.40 + ,1896.84 + ,0.0254 + ,96.7 + ,45 + ,26.20 + ,0.7398 + ,0 + ,0 + ,28749200 + ,22.66 + ,1974.99 + ,0.0319 + ,92.9 + ,46 + ,33.53 + ,0.7398 + ,0 + ,0 + ,31408300 + ,24.21 + ,2096.81 + ,0.0352 + ,92.6 + ,47 + ,32.20 + ,0.7398 + ,0 + ,0 + ,26342800 + ,24.13 + ,2175.44 + ,0.0326 + ,102.7 + ,48 + ,38.45 + ,0.6988 + ,0 + ,0 + ,48909500 + ,23.73 + ,2062.41 + ,0.0297 + ,105.1 + ,49 + ,44.86 + ,0.6988 + ,0 + ,0 + ,41542400 + ,22.79 + ,2051.72 + ,0.0301 + ,104.4 + ,50 + ,41.67 + ,0.6988 + ,0 + ,0 + ,24857200 + ,21.89 + ,1999.23 + ,0.0315 + ,103.0 + ,51 + ,36.06 + ,0.7478 + ,0 + ,0 + ,34093700 + ,22.92 + ,1921.65 + ,0.0351 + ,97.5 + ,52 + ,39.76 + ,0.7478 + ,0 + ,0 + ,22555200 + ,23.44 + ,2068.22 + ,0.028 + ,103.1 + ,53 + ,36.81 + ,0.7478 + ,0 + ,0 + ,19067500 + ,22.57 + ,2056.96 + ,0.0253 + ,106.2 + ,54 + ,42.65 + ,0.5651 + ,0 + ,0 + ,19029100 + ,23.27 + ,2184.83 + ,0.0317 + ,103.6 + ,55 + ,46.89 + ,0.5651 + ,0 + ,0 + ,15223200 + ,24.95 + ,2152.09 + ,0.0364 + ,105.5 + ,56 + ,53.61 + ,0.5651 + ,0 + ,0 + ,21903700 + ,23.45 + ,2151.69 + ,0.0469 + ,87.5 + ,57 + ,57.59 + ,0.6473 + ,0 + ,0 + ,33306600 + ,23.42 + ,2120.30 + ,0.0435 + ,85.2 + ,58 + ,67.82 + ,0.6473 + ,0 + ,0 + ,23898100 + ,25.30 + ,2232.82 + ,0.0346 + ,98.3 + ,59 + ,71.89 + ,0.6473 + ,0 + ,0 + ,23279600 + ,23.90 + ,2205.32 + ,0.0342 + ,103.8 + ,60 + ,75.51 + ,0.3441 + ,0 + ,0 + ,40699800 + ,25.73 + ,2305.82 + ,0.0399 + ,106.8 + ,61 + ,68.49 + ,0.3441 + ,0 + ,0 + ,37646000 + ,24.64 + ,2281.39 + ,0.036 + ,102.7 + ,62 + ,62.72 + ,0.3441 + ,0 + ,0 + ,37277000 + ,24.95 + ,2339.79 + ,0.0336 + ,107.5 + ,63 + ,70.39 + ,0.2415 + ,0 + ,0 + ,39246800 + ,22.15 + ,2322.57 + ,0.0355 + ,109.8 + ,64 + ,59.77 + ,0.2415 + ,0 + ,0 + ,27418400 + ,20.85 + ,2178.88 + ,0.0417 + ,104.7 + ,65 + ,57.27 + ,0.2415 + ,0 + ,0 + ,30318700 + ,21.45 + ,2172.09 + ,0.0432 + ,105.7 + ,66 + ,67.96 + ,0.3151 + ,0 + ,0 + ,32808100 + ,22.15 + ,2091.47 + ,0.0415 + ,107.0 + ,67 + ,67.85 + ,0.3151 + ,0 + ,0 + ,28668200 + ,23.75 + ,2183.75 + ,0.0382 + ,100.2 + ,68 + ,76.98 + ,0.3151 + ,0 + ,0 + ,32370300 + ,25.27 + ,2258.43 + ,0.0206 + ,105.9 + ,69 + ,81.08 + ,0.239 + ,0 + ,0 + ,24171100 + ,26.53 + ,2366.71 + ,0.0131 + ,105.1 + ,70 + ,91.66 + ,0.239 + ,0 + ,0 + ,25009100 + ,27.22 + ,2431.77 + ,0.0197 + ,105.3 + ,71 + ,84.84 + ,0.239 + ,0 + ,0 + ,32084300 + ,27.69 + ,2415.29 + ,0.0254 + ,110.0 + ,72 + ,85.73 + ,0.2127 + ,0 + ,0 + ,50117500 + ,28.61 + ,2463.93 + ,0.0208 + ,110.2 + ,73 + ,84.61 + ,0.2127 + ,0 + ,0 + ,27522200 + ,26.21 + ,2416.15 + ,0.0242 + ,111.2 + ,74 + ,92.91 + ,0.2127 + ,0 + ,0 + ,26816800 + ,25.93 + ,2421.64 + ,0.0278 + ,108.2 + ,75 + ,99.80 + ,0.273 + ,0 + ,0 + ,25136100 + ,27.86 + ,2525.09 + ,0.0257 + ,106.3 + ,76 + ,121.19 + ,0.273 + ,0 + ,0 + ,30295600 + ,28.65 + ,2604.52 + ,0.0269 + ,108.5 + ,77 + ,122.04 + ,0.273 + ,0.273 + ,0 + ,41526100 + ,27.51 + ,2603.23 + ,0.0269 + ,105.3 + ,78 + ,131.76 + ,0.3657 + ,0.3657 + ,0 + ,43845100 + ,27.06 + ,2546.27 + ,0.0236 + ,111.9 + ,79 + ,138.48 + ,0.3657 + ,0.3657 + ,0 + ,39188900 + ,26.91 + ,2596.36 + ,0.0197 + ,105.6 + ,80 + ,153.47 + ,0.3657 + ,0.3657 + ,0 + ,40496400 + ,27.60 + ,2701.50 + ,0.0276 + ,99.5 + ,81 + ,189.95 + ,0.4643 + ,0.4643 + ,0 + ,37438400 + ,34.48 + ,2859.12 + ,0.0354 + ,95.2 + ,82 + ,182.22 + ,0.4643 + ,0.4643 + ,0 + ,46553700 + ,31.58 + ,2660.96 + ,0.0431 + ,87.8 + ,83 + ,198.08 + ,0.4643 + ,0.4643 + ,0 + ,31771400 + ,33.46 + ,2652.28 + ,0.0408 + ,90.6 + ,84 + ,135.36 + ,0.5096 + ,0.5096 + ,0 + ,62108100 + ,30.64 + ,2389.86 + ,0.0428 + ,87.9 + ,85 + ,125.02 + ,0.5096 + ,0.5096 + ,0 + ,46645400 + ,25.66 + ,2271.48 + ,0.0403 + ,76.4 + ,86 + ,143.50 + ,0.5096 + ,0.5096 + ,0 + ,42313100 + ,26.78 + ,2279.10 + ,0.0398 + ,65.9 + ,87 + ,173.95 + ,0.3592 + ,0.3592 + ,0 + ,38841700 + ,26.91 + ,2412.80 + ,0.0394 + ,62.3 + ,88 + ,188.75 + ,0.3592 + ,0.3592 + ,0 + ,32650300 + ,26.82 + ,2522.66 + ,0.0418 + ,57.2 + ,89 + ,167.44 + ,0.3592 + ,0.3592 + ,0 + ,34281100 + ,26.05 + ,2292.98 + ,0.0502 + ,50.4 + ,90 + ,158.95 + ,0.7439 + ,0.7439 + ,0 + ,33096200 + ,24.36 + ,2325.55 + ,0.056 + ,51.9 + ,91 + ,169.53 + ,0.7439 + ,0.7439 + ,0 + ,23273800 + ,25.94 + ,2367.52 + ,0.0537 + ,58.5 + ,92 + ,113.66 + ,0.7439 + ,0.7439 + ,0 + ,43697600 + ,25.37 + ,2091.88 + ,0.0494 + ,61.4 + ,93 + ,107.59 + ,0.139 + ,0.139 + ,0 + ,66902300 + ,21.23 + ,1720.95 + ,0.0366 + ,38.8 + ,94 + ,92.67 + ,0.139 + ,0.139 + ,0 + ,44957200 + ,19.35 + ,1535.57 + ,0.0107 + ,44.9 + ,95 + ,85.35 + ,0.139 + ,0.139 + ,0 + ,33800900 + ,18.61 + ,1577.03 + ,0.0009 + ,38.6 + ,96 + ,90.13 + ,0.1383 + ,0.1383 + ,0 + ,33487900 + ,16.37 + ,1476.42 + ,0.0003 + ,4.0 + ,97 + ,89.31 + ,0.1383 + ,0.1383 + ,0 + ,27394900 + ,15.56 + ,1377.84 + ,0.0024 + ,25.3 + ,98 + ,105.12 + ,0.1383 + ,0.1383 + ,0 + ,25963400 + ,17.70 + ,1528.59 + ,-0.0038 + ,26.9 + ,99 + ,125.83 + ,0.2874 + ,0.2874 + ,0 + ,20952600 + ,19.52 + ,1717.30 + ,-0.0074 + ,40.8 + ,100 + ,135.81 + ,0.2874 + ,0.2874 + ,0 + ,17702900 + ,20.26 + ,1774.33 + ,-0.0128 + ,54.8 + ,101 + ,142.43 + ,0.2874 + ,0.2874 + ,0 + ,21282100 + ,23.05 + ,1835.04 + ,-0.0143 + ,49.3 + ,102 + ,163.39 + ,0.0596 + ,0.0596 + ,0 + ,18449100 + ,22.81 + ,1978.50 + ,-0.021 + ,47.4 + ,103 + ,168.21 + ,0.0596 + ,0.0596 + ,0 + ,14415700 + ,24.04 + ,2009.06 + ,-0.0148 + ,54.5 + ,104 + ,185.35 + ,0.0596 + ,0.0596 + ,0 + ,17906300 + ,25.08 + ,2122.42 + ,-0.0129 + ,53.4 + ,105 + ,188.50 + ,0.3201 + ,0.3201 + ,0 + ,22197500 + ,27.04 + ,2045.11 + ,-0.0018 + ,48.7 + ,106 + ,199.91 + ,0.3201 + ,0.3201 + ,0 + ,15856500 + ,28.81 + ,2144.60 + ,0.0184 + ,50.6 + ,107 + ,210.73 + ,0.3201 + ,0.3201 + ,0 + ,19068700 + ,29.86 + ,2269.15 + ,0.0272 + ,53.6 + ,108 + ,192.06 + ,0.486 + ,0.486 + ,0 + ,30855100 + ,27.61 + ,2147.35 + ,0.0263 + ,56.5 + ,109 + ,204.62 + ,0.486 + ,0.486 + ,0 + ,21209000 + ,28.22 + ,2238.26 + ,0.0214 + ,46.4 + ,110 + ,235.00 + ,0.486 + ,0.486 + ,0 + ,19541600 + ,28.83 + ,2397.96 + ,0.0231 + ,52.3 + ,111 + ,261.09 + ,0.6129 + ,0.6129 + ,0.6129 + ,21955000 + ,30.06 + ,2461.19 + ,0.0224 + ,57.7 + ,112 + ,256.88 + ,0.6129 + ,0.6129 + ,0.6129 + ,33725900 + ,25.51 + ,2257.04 + ,0.0202 + ,62.7 + ,113 + ,251.53 + ,0.6129 + ,0.6129 + ,0.6129 + ,28192800 + ,22.75 + ,2109.24 + ,0.0105 + ,54.3 + ,114 + ,257.25 + ,0.6665 + ,0.6665 + ,0.6665 + ,27377000 + ,25.52 + ,2254.70 + ,0.0124 + ,51.0 + ,115 + ,243.10 + ,0.6665 + ,0.6665 + ,0.6665 + ,16228100 + ,23.33 + ,2114.03 + ,0.0115 + ,53.2 + ,116 + ,283.75 + ,0.6665 + ,0.6665 + ,0.6665 + ,21278900 + ,24.34 + ,2368.62 + ,0.0114 + ,48.6 + ,117) + ,dim=c(10 + ,117) + ,dimnames=list(c('APPLE' + ,'REV.GROWTH' + ,'IPHONE' + ,'IPAD' + ,'VOLUME' + ,'MICROSOFT' + ,'NASDAQ' + ,'INFLATION' + ,'CONS.CONF' + ,'Trend') + ,1:117)) > y <- array(NA,dim=c(10,117),dimnames=list(c('APPLE','REV.GROWTH','IPHONE','IPAD','VOLUME','MICROSOFT','NASDAQ','INFLATION','CONS.CONF','Trend'),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" "Trend" > 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/1wupo1293197061.tab") + } + } > m Conditional inference tree with 9 terminal nodes Response: APPLE Inputs: REV.GROWTH, IPHONE, IPAD, VOLUME, MICROSOFT, NASDAQ, INFLATION, CONS.CONF, Trend Number of observations: 117 1) Trend <= 75; criterion = 1, statistic = 94.607 2) Trend <= 55; criterion = 1, statistic = 57.091 3) REV.GROWTH <= 0.3703; criterion = 1, statistic = 34.653 4) NASDAQ <= 1595.91; criterion = 0.998, statistic = 14.054 5)* weights = 13 4) NASDAQ > 1595.91 6) Trend <= 38; criterion = 0.994, statistic = 11.51 7)* weights = 25 6) Trend > 38 8)* weights = 7 3) REV.GROWTH > 0.3703 9)* weights = 10 2) Trend > 55 10) NASDAQ <= 2183.75; criterion = 0.998, statistic = 13.47 11)* weights = 7 10) NASDAQ > 2183.75 12)* weights = 13 1) Trend > 75 13) Trend <= 104; criterion = 1, statistic = 21.148 14) MICROSOFT <= 21.23; criterion = 0.998, statistic = 13.321 15)* weights = 8 14) MICROSOFT > 21.23 16)* weights = 21 13) Trend > 104 17)* weights = 13 > postscript(file="/var/www/html/rcomp/tmp/2wupo1293197061.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/3wupo1293197061.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 10.830000 -0.02000000 2 9.12 10.830000 -1.71000000 3 11.03 10.830000 0.20000000 4 12.74 10.830000 1.91000000 5 9.98 10.830000 -0.85000000 6 11.62 10.830000 0.79000000 7 9.40 10.830000 -1.43000000 8 9.27 10.830000 -1.56000000 9 7.76 7.666923 0.09307692 10 8.78 10.830000 -2.05000000 11 10.65 10.830000 -0.18000000 12 10.95 10.830000 0.12000000 13 12.36 10.830000 1.53000000 14 10.85 10.830000 0.02000000 15 11.84 10.830000 1.01000000 16 12.14 10.830000 1.31000000 17 11.65 10.830000 0.82000000 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 10.830000 -1.30000000 31 10.54 10.830000 -0.29000000 32 11.31 10.830000 0.48000000 33 10.36 10.830000 -0.47000000 34 11.44 10.830000 0.61000000 35 10.45 10.830000 -0.38000000 36 10.69 10.830000 -0.14000000 37 11.28 10.830000 0.45000000 38 11.96 10.830000 1.13000000 39 13.52 15.644286 -2.12428571 40 12.89 15.644286 -2.75428571 41 14.03 15.644286 -1.61428571 42 16.27 15.644286 0.62571429 43 16.17 15.644286 0.52571429 44 17.25 15.644286 1.60571429 45 19.38 15.644286 3.73571429 46 26.20 37.219000 -11.01900000 47 33.53 37.219000 -3.68900000 48 32.20 37.219000 -5.01900000 49 38.45 37.219000 1.23100000 50 44.86 37.219000 7.64100000 51 41.67 37.219000 4.45100000 52 36.06 37.219000 -1.15900000 53 39.76 37.219000 2.54100000 54 36.81 37.219000 -0.40900000 55 42.65 37.219000 5.43100000 56 46.89 58.705714 -11.81571429 57 53.61 58.705714 -5.09571429 58 57.59 58.705714 -1.11571429 59 67.82 78.048462 -10.22846154 60 71.89 78.048462 -6.15846154 61 75.51 78.048462 -2.53846154 62 68.49 78.048462 -9.55846154 63 62.72 78.048462 -15.32846154 64 70.39 78.048462 -7.65846154 65 59.77 58.705714 1.06428571 66 57.27 58.705714 -1.43571429 67 67.96 58.705714 9.25428571 68 67.85 58.705714 9.14428571 69 76.98 78.048462 -1.06846154 70 81.08 78.048462 3.03153846 71 91.66 78.048462 13.61153846 72 84.84 78.048462 6.79153846 73 85.73 78.048462 7.68153846 74 84.61 78.048462 6.56153846 75 92.91 78.048462 14.86153846 76 99.80 151.770476 -51.97047619 77 121.19 151.770476 -30.58047619 78 122.04 151.770476 -29.73047619 79 131.76 151.770476 -20.01047619 80 138.48 151.770476 -13.29047619 81 153.47 151.770476 1.69952381 82 189.95 151.770476 38.17952381 83 182.22 151.770476 30.44952381 84 198.08 151.770476 46.30952381 85 135.36 151.770476 -16.41047619 86 125.02 151.770476 -26.75047619 87 143.50 151.770476 -8.27047619 88 173.95 151.770476 22.17952381 89 188.75 151.770476 36.97952381 90 167.44 151.770476 15.66952381 91 158.95 151.770476 7.17952381 92 169.53 151.770476 17.75952381 93 113.66 151.770476 -38.11047619 94 107.59 103.976250 3.61375000 95 92.67 103.976250 -11.30625000 96 85.35 103.976250 -18.62625000 97 90.13 103.976250 -13.84625000 98 89.31 103.976250 -14.66625000 99 105.12 103.976250 1.14375000 100 125.83 103.976250 21.85375000 101 135.81 103.976250 31.83375000 102 142.43 151.770476 -9.34047619 103 163.39 151.770476 11.61952381 104 168.21 151.770476 16.43952381 105 185.35 228.443846 -43.09384615 106 188.50 228.443846 -39.94384615 107 199.91 228.443846 -28.53384615 108 210.73 228.443846 -17.71384615 109 192.06 228.443846 -36.38384615 110 204.62 228.443846 -23.82384615 111 235.00 228.443846 6.55615385 112 261.09 228.443846 32.64615385 113 256.88 228.443846 28.43615385 114 251.53 228.443846 23.08615385 115 257.25 228.443846 28.80615385 116 243.10 228.443846 14.65615385 117 283.75 228.443846 55.30615385 > 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/473791293197061.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/5ld401293197061.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/6vm4l1293197061.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/7znk91293197061.tab") + } > try(system("convert tmp/2wupo1293197061.ps tmp/2wupo1293197061.png",intern=TRUE)) character(0) > try(system("convert tmp/3wupo1293197061.ps tmp/3wupo1293197061.png",intern=TRUE)) character(0) > try(system("convert tmp/473791293197061.ps tmp/473791293197061.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.284 0.640 11.580