R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(25.94 + ,23688100 + ,39.18 + ,3940.35 + ,0.02740 + ,144.7 + ,5.45 + ,28.66 + ,13741000 + ,35.78 + ,4696.69 + ,0.03220 + ,140.8 + ,5.73 + ,33.95 + ,14143500 + ,42.54 + ,4572.83 + ,0.03760 + ,137.1 + ,5.85 + ,31.01 + ,16763800 + ,27.92 + ,3860.66 + ,0.03070 + ,137.7 + ,6.02 + ,21.00 + ,16634600 + ,25.05 + ,3400.91 + ,0.03190 + ,144.7 + ,6.27 + ,26.19 + ,13693300 + ,32.03 + ,3966.11 + ,0.03730 + ,139.2 + ,6.53 + ,25.41 + ,10545800 + ,27.95 + ,3766.99 + ,0.03660 + ,143.0 + ,6.54 + ,30.47 + ,9409900 + ,27.95 + ,4206.35 + ,0.03410 + ,140.8 + ,6.5 + ,12.88 + ,39182200 + ,24.15 + ,3672.82 + ,0.03450 + ,142.5 + ,6.52 + ,9.78 + ,37005800 + ,27.57 + ,3369.63 + ,0.03450 + ,135.8 + ,6.51 + ,8.25 + ,15818500 + ,22.97 + ,2597.93 + ,0.03450 + ,132.6 + ,6.51 + ,7.44 + ,16952000 + ,17.37 + ,2470.52 + ,0.03390 + ,128.6 + ,6.4 + ,10.81 + ,24563400 + ,24.45 + ,2772.73 + ,0.03730 + ,115.7 + ,5.98 + ,9.12 + ,14163200 + ,23.62 + ,2151.83 + ,0.03530 + ,109.2 + ,5.49 + ,11.03 + ,18184800 + ,21.90 + ,1840.26 + ,0.02920 + ,116.9 + ,5.31 + ,12.74 + ,20810300 + ,27.12 + ,2116.24 + ,0.03270 + ,109.9 + ,4.8 + ,9.98 + ,12843000 + ,27.70 + ,2110.49 + ,0.03620 + ,116.1 + ,4.21 + ,11.62 + ,13866700 + ,29.23 + ,2160.54 + ,0.03250 + ,118.9 + ,3.97 + ,9.40 + ,15119200 + ,26.50 + ,2027.13 + ,0.02720 + ,116.3 + ,3.77 + ,9.27 + ,8301600 + ,22.84 + ,1805.43 + ,0.02720 + ,114.0 + ,3.65 + ,7.76 + ,14039600 + ,20.49 + ,1498.80 + ,0.02650 + ,97.0 + ,3.07 + ,8.78 + ,12139700 + ,23.28 + ,1690.20 + ,0.02130 + ,85.3 + ,2.49 + ,10.65 + ,9649000 + ,25.71 + ,1930.58 + ,0.01900 + ,84.9 + ,2.09 + ,10.95 + ,8513600 + ,26.52 + ,1950.40 + ,0.01550 + ,94.6 + ,1.82 + ,12.36 + ,15278600 + ,25.51 + ,1934.03 + ,0.01140 + ,97.8 + ,1.73 + ,10.85 + ,15590900 + ,23.36 + ,1731.49 + ,0.01140 + ,95.0 + ,1.74 + ,11.84 + ,9691100 + ,24.15 + ,1845.35 + ,0.01480 + ,110.7 + ,1.73 + ,12.14 + ,10882700 + ,20.92 + ,1688.23 + ,0.01640 + ,108.5 + ,1.75 + ,11.65 + ,10294800 + ,20.38 + ,1615.73 + ,0.01180 + ,110.3 + ,1.75 + ,8.86 + ,16031900 + ,21.90 + ,1463.21 + ,0.01070 + ,106.3 + ,1.75 + ,7.63 + ,13683600 + ,19.21 + ,1328.26 + ,0.01460 + ,97.4 + ,1.73 + ,7.38 + ,8677200 + ,19.65 + ,1314.85 + ,0.01800 + ,94.5 + ,1.74 + ,7.25 + ,9874100 + ,17.51 + ,1172.06 + ,0.01510 + ,93.7 + ,1.75 + ,8.03 + ,10725500 + ,21.41 + ,1329.75 + ,0.02030 + ,79.6 + ,1.75 + ,7.75 + ,8348400 + ,23.09 + ,1478.78 + ,0.02200 + ,84.9 + ,1.34 + ,7.16 + ,8046200 + ,20.70 + ,1335.51 + ,0.02380 + ,80.7 + ,1.24 + ,7.18 + ,10862300 + ,19.00 + ,1320.91 + ,0.02600 + ,78.8 + ,1.24 + ,7.51 + ,8100300 + ,19.04 + ,1337.52 + ,0.02980 + ,64.8 + ,1.26 + ,7.07 + ,7287500 + ,19.45 + ,1341.17 + ,0.03020 + ,61.4 + ,1.25 + ,7.11 + ,14002500 + ,20.54 + ,1464.31 + ,0.02220 + ,81.0 + ,1.26 + ,8.98 + ,19037900 + ,19.77 + ,1595.91 + ,0.02060 + ,83.6 + ,1.26 + ,9.53 + ,10774600 + ,20.60 + ,1622.80 + ,0.02110 + ,83.5 + ,1.22 + ,10.54 + ,8960600 + ,21.21 + ,1735.02 + ,0.02110 + ,77.0 + ,1.01 + ,11.31 + ,7773300 + ,21.30 + ,1810.45 + ,0.02160 + ,81.7 + ,1.03 + ,10.36 + ,9579700 + ,22.33 + ,1786.94 + ,0.02320 + ,77.0 + ,1.01 + ,11.44 + ,11270700 + ,21.12 + ,1932.21 + ,0.02040 + ,81.7 + ,1.01 + ,10.45 + ,9492800 + ,20.77 + ,1960.26 + ,0.01770 + ,92.5 + ,1 + ,10.69 + ,9136800 + ,22.11 + ,2003.37 + ,0.01880 + ,91.7 + ,0.98 + ,11.28 + ,14487600 + ,22.34 + ,2066.15 + ,0.01930 + ,96.4 + ,1 + ,11.96 + ,10133200 + ,21.43 + ,2029.82 + ,0.01690 + ,88.5 + ,1.01 + ,13.52 + ,18659700 + ,20.14 + ,1994.22 + ,0.01740 + ,88.5 + ,1 + ,12.89 + ,15980700 + ,21.11 + ,1920.15 + ,0.02290 + ,93.0 + ,1 + ,14.03 + ,9732100 + ,21.19 + ,1986.74 + ,0.03050 + ,93.1 + ,1 + ,16.27 + ,14626300 + ,23.07 + ,2047.79 + ,0.03270 + ,102.8 + ,1.03 + ,16.17 + ,16904000 + ,23.01 + ,1887.36 + ,0.02990 + ,105.7 + ,1.26 + ,17.25 + ,13616700 + ,22.12 + ,1838.10 + ,0.02650 + ,98.7 + ,1.43 + ,19.38 + ,13772900 + ,22.40 + ,1896.84 + ,0.02540 + ,96.7 + ,1.61 + ,26.20 + ,28749200 + ,22.66 + ,1974.99 + ,0.03190 + ,92.9 + ,1.76 + ,33.53 + ,31408300 + ,24.21 + ,2096.81 + ,0.03520 + ,92.6 + ,1.93 + ,32.20 + ,26342800 + ,24.13 + ,2175.44 + ,0.03260 + ,102.7 + ,2.16 + ,38.45 + ,48909500 + ,23.73 + ,2062.41 + ,0.02970 + ,105.1 + ,2.28 + ,44.86 + ,41542400 + ,22.79 + ,2051.72 + ,0.03010 + ,104.4 + ,2.5 + ,41.67 + ,24857200 + ,21.89 + ,1999.23 + ,0.03150 + ,103.0 + ,2.63 + ,36.06 + ,34093700 + ,22.92 + ,1921.65 + ,0.03510 + ,97.5 + ,2.79 + ,39.76 + ,22555200 + ,23.44 + ,2068.22 + ,0.02800 + ,103.1 + ,3 + ,36.81 + ,19067500 + ,22.57 + ,2056.96 + ,0.02530 + ,106.2 + ,3.04 + ,42.65 + ,19029100 + ,23.27 + ,2184.83 + ,0.03170 + ,103.6 + ,3.26 + ,46.89 + ,15223200 + ,24.95 + ,2152.09 + ,0.03640 + ,105.5 + ,3.5 + ,53.61 + ,21903700 + ,23.45 + ,2151.69 + ,0.04690 + ,87.5 + ,3.62 + ,57.59 + ,33306600 + ,23.42 + ,2120.30 + ,0.04350 + ,85.2 + ,3.78 + ,67.82 + ,23898100 + ,25.30 + ,2232.82 + ,0.03460 + ,98.3 + ,4 + ,71.89 + ,23279600 + ,23.90 + ,2205.32 + ,0.03420 + ,103.8 + ,4.16 + ,75.51 + ,40699800 + ,25.73 + ,2305.82 + ,0.03990 + ,106.8 + ,4.29 + ,68.49 + ,37646000 + ,24.64 + ,2281.39 + ,0.03600 + ,102.7 + ,4.49 + ,62.72 + ,37277000 + ,24.95 + ,2339.79 + ,0.03360 + ,107.5 + ,4.59 + ,70.39 + ,39246800 + ,22.15 + ,2322.57 + ,0.03550 + ,109.8 + ,4.79 + ,59.77 + ,27418400 + ,20.85 + ,2178.88 + ,0.04170 + ,104.7 + ,4.94 + ,57.27 + ,30318700 + ,21.45 + ,2172.09 + ,0.04320 + ,105.7 + ,4.99 + ,67.96 + ,32808100 + ,22.15 + ,2091.47 + ,0.04150 + ,107.0 + ,5.24 + ,67.85 + ,28668200 + ,23.75 + ,2183.75 + ,0.03820 + ,100.2 + ,5.25 + ,76.98 + ,32370300 + ,25.27 + ,2258.43 + ,0.02060 + ,105.9 + ,5.25 + ,81.08 + ,24171100 + ,26.53 + ,2366.71 + ,0.01310 + ,105.1 + ,5.25 + ,91.66 + ,25009100 + ,27.22 + ,2431.77 + ,0.01970 + ,105.3 + ,5.25 + ,84.84 + ,32084300 + ,27.69 + ,2415.29 + ,0.02540 + ,110.0 + ,5.24 + ,85.73 + ,50117500 + ,28.61 + ,2463.93 + ,0.02080 + ,110.2 + ,5.25 + ,84.61 + ,27522200 + ,26.21 + ,2416.15 + ,0.02420 + ,111.2 + ,5.26 + ,92.91 + ,26816800 + ,25.93 + ,2421.64 + ,0.02780 + ,108.2 + ,5.26 + ,99.80 + ,25136100 + ,27.86 + ,2525.09 + ,0.02570 + ,106.3 + ,5.25 + ,121.19 + ,30295600 + ,28.65 + ,2604.52 + ,0.02690 + ,108.5 + ,5.25 + ,122.04 + ,41526100 + ,27.51 + ,2603.23 + ,0.02690 + ,105.3 + ,5.25 + ,131.76 + ,43845100 + ,27.06 + ,2546.27 + ,0.02360 + ,111.9 + ,5.26 + ,138.48 + ,39188900 + ,26.91 + ,2596.36 + ,0.01970 + ,105.6 + ,5.02 + ,153.47 + ,40496400 + ,27.60 + ,2701.50 + ,0.02760 + ,99.5 + ,4.94 + ,189.95 + ,37438400 + ,34.48 + ,2859.12 + ,0.03540 + ,95.2 + ,4.76 + ,182.22 + ,46553700 + ,31.58 + ,2660.96 + ,0.04310 + ,87.8 + ,4.49 + ,198.08 + ,31771400 + ,33.46 + ,2652.28 + ,0.04080 + ,90.6 + ,4.24 + ,135.36 + ,62108100 + ,30.64 + ,2389.86 + ,0.04280 + ,87.9 + ,3.94 + ,125.02 + ,46645400 + ,25.66 + ,2271.48 + ,0.04030 + ,76.4 + ,2.98 + ,143.50 + ,42313100 + ,26.78 + ,2279.10 + ,0.03980 + ,65.9 + ,2.61 + ,173.95 + ,38841700 + ,26.91 + ,2412.80 + ,0.03940 + ,62.3 + ,2.28 + ,188.75 + ,32650300 + ,26.82 + ,2522.66 + ,0.04180 + ,57.2 + ,1.98 + ,167.44 + ,34281100 + ,26.05 + ,2292.98 + ,0.05020 + ,50.4 + ,2 + ,158.95 + ,33096200 + ,24.36 + ,2325.55 + ,0.05600 + ,51.9 + ,2.01 + ,169.53 + ,23273800 + ,25.94 + ,2367.52 + ,0.05370 + ,58.5 + ,2 + ,113.66 + ,43697600 + ,25.37 + ,2091.88 + ,0.04940 + ,61.4 + ,1.81 + ,107.59 + ,66902300 + ,21.23 + ,1720.95 + ,0.03660 + ,38.8 + ,0.97 + ,92.67 + ,44957200 + ,19.35 + ,1535.57 + ,0.01070 + ,44.9 + ,0.39 + ,85.35 + ,33800900 + ,18.61 + ,1577.03 + ,0.00090 + ,38.6 + ,0.16 + ,90.13 + ,33487900 + ,16.37 + ,1476.42 + ,0.00030 + ,4.0 + ,0.15 + ,89.31 + ,27394900 + ,15.56 + ,1377.84 + ,0.00240 + ,25.3 + ,0.22 + ,105.12 + ,25963400 + ,17.70 + ,1528.59 + ,-0.00380 + ,26.9 + ,0.18 + ,125.83 + ,20952600 + ,19.52 + ,1717.30 + ,-0.00740 + ,40.8 + ,0.15 + ,135.81 + ,17702900 + ,20.26 + ,1774.33 + ,-0.01280 + ,54.8 + ,0.18 + ,142.43 + ,21282100 + ,23.05 + ,1835.04 + ,-0.01430 + ,49.3 + ,0.21 + ,163.39 + ,18449100 + ,22.81 + ,1978.50 + ,-0.02100 + ,47.4 + ,0.16 + ,168.21 + ,14415700 + ,24.04 + ,2009.06 + ,-0.01480 + ,54.5 + ,0.16 + ,185.35 + ,17906300 + ,25.08 + ,2122.42 + ,-0.01290 + ,53.4 + ,0.15 + ,188.50 + ,22197500 + ,27.04 + ,2045.11 + ,-0.00180 + ,48.7 + ,0.12 + ,199.91 + ,15856500 + ,28.81 + ,2144.60 + ,0.01840 + ,50.6 + ,0.12 + ,210.73 + ,19068700 + ,29.86 + ,2269.15 + ,0.02720 + ,53.6 + ,0.12 + ,192.06 + ,30855100 + ,27.61 + ,2147.35 + ,0.02630 + ,56.5 + ,0.11 + ,204.62 + ,21209000 + ,28.22 + ,2238.26 + ,0.02140 + ,46.4 + ,0.13 + ,235.00 + ,19541600 + ,28.83 + ,2397.96 + ,0.02310 + ,52.3 + ,0.16 + ,261.09 + ,21955000 + ,30.06 + ,2461.19 + ,0.02240 + ,57.7 + ,0.2 + ,256.88 + ,33725900 + ,25.51 + ,2257.04 + ,0.02020 + ,62.7 + ,0.2 + ,251.53 + ,28192800 + ,22.75 + ,2109.24 + ,0.01050 + ,54.3 + ,0.18 + ,257.25 + ,27377000 + ,25.52 + ,2254.70 + ,0.01240 + ,51.0 + ,0.18 + ,243.10 + ,16228100 + ,23.33 + ,2114.03 + ,0.01150 + ,53.2 + ,0.19 + ,283.75 + ,21278900 + ,24.34 + ,2368.62 + ,0.01140 + ,48.6 + ,0.19 + ,300.98 + ,21457400 + ,26.51 + ,2507.41 + ,0.01170 + ,49.9 + ,0.19) + ,dim=c(7 + ,130) + ,dimnames=list(c('APPLE' + ,'VOLUME' + ,'MICROSOFT' + ,'NASDAQ' + ,'INFLATION' + ,'CONS.CONF' + ,'FED.FUNDS.RATE') + ,1:130)) > y <- array(NA,dim=c(7,130),dimnames=list(c('APPLE','VOLUME','MICROSOFT','NASDAQ','INFLATION','CONS.CONF','FED.FUNDS.RATE'),1:130)) > 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 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] 25.94 28.66 33.95 31.01 21.00 26.19 25.41 30.47 12.88 9.78 [11] 8.25 7.44 10.81 9.12 11.03 12.74 9.98 11.62 9.40 9.27 [21] 7.76 8.78 10.65 10.95 12.36 10.85 11.84 12.14 11.65 8.86 [31] 7.63 7.38 7.25 8.03 7.75 7.16 7.18 7.51 7.07 7.11 [41] 8.98 9.53 10.54 11.31 10.36 11.44 10.45 10.69 11.28 11.96 [51] 13.52 12.89 14.03 16.27 16.17 17.25 19.38 26.20 33.53 32.20 [61] 38.45 44.86 41.67 36.06 39.76 36.81 42.65 46.89 53.61 57.59 [71] 67.82 71.89 75.51 68.49 62.72 70.39 59.77 57.27 67.96 67.85 [81] 76.98 81.08 91.66 84.84 85.73 84.61 92.91 99.80 121.19 122.04 [91] 131.76 138.48 153.47 189.95 182.22 198.08 135.36 125.02 143.50 173.95 [101] 188.75 167.44 158.95 169.53 113.66 107.59 92.67 85.35 90.13 89.31 [111] 105.12 125.83 135.81 142.43 163.39 168.21 185.35 188.50 199.91 210.73 [121] 192.06 204.62 235.00 261.09 256.88 251.53 257.25 243.10 283.75 300.98 > 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.44 7.51 7.63 7.75 7.76 1 1 1 1 1 1 1 1 1 1 1 8.03 8.25 8.78 8.86 8.98 9.12 9.27 9.4 9.53 9.78 9.98 1 1 1 1 1 1 1 1 1 1 1 10.36 10.45 10.54 10.65 10.69 10.81 10.85 10.95 11.03 11.28 11.31 1 1 1 1 1 1 1 1 1 1 1 11.44 11.62 11.65 11.84 11.96 12.14 12.36 12.74 12.88 12.89 13.52 1 1 1 1 1 1 1 1 1 1 1 14.03 16.17 16.27 17.25 19.38 21 25.41 25.94 26.19 26.2 28.66 1 1 1 1 1 1 1 1 1 1 1 30.47 31.01 32.2 33.53 33.95 36.06 36.81 38.45 39.76 41.67 42.65 1 1 1 1 1 1 1 1 1 1 1 44.86 46.89 53.61 57.27 57.59 59.77 62.72 67.82 67.85 67.96 68.49 1 1 1 1 1 1 1 1 1 1 1 70.39 71.89 75.51 76.98 81.08 84.61 84.84 85.35 85.73 89.31 90.13 1 1 1 1 1 1 1 1 1 1 1 91.66 92.67 92.91 99.8 105.12 107.59 113.66 121.19 122.04 125.02 125.83 1 1 1 1 1 1 1 1 1 1 1 131.76 135.36 135.81 138.48 142.43 143.5 153.47 158.95 163.39 167.44 168.21 1 1 1 1 1 1 1 1 1 1 1 169.53 173.95 182.22 185.35 188.5 188.75 189.95 192.06 198.08 199.91 204.62 1 1 1 1 1 1 1 1 1 1 1 210.73 235 243.1 251.53 256.88 257.25 261.09 283.75 300.98 1 1 1 1 1 1 1 1 1 > colnames(x) [1] "APPLE" "VOLUME" "MICROSOFT" "NASDAQ" [5] "INFLATION" "CONS.CONF" "FED.FUNDS.RATE" > colnames(x)[par1] [1] "APPLE" > x[,par1] [1] 25.94 28.66 33.95 31.01 21.00 26.19 25.41 30.47 12.88 9.78 [11] 8.25 7.44 10.81 9.12 11.03 12.74 9.98 11.62 9.40 9.27 [21] 7.76 8.78 10.65 10.95 12.36 10.85 11.84 12.14 11.65 8.86 [31] 7.63 7.38 7.25 8.03 7.75 7.16 7.18 7.51 7.07 7.11 [41] 8.98 9.53 10.54 11.31 10.36 11.44 10.45 10.69 11.28 11.96 [51] 13.52 12.89 14.03 16.27 16.17 17.25 19.38 26.20 33.53 32.20 [61] 38.45 44.86 41.67 36.06 39.76 36.81 42.65 46.89 53.61 57.59 [71] 67.82 71.89 75.51 68.49 62.72 70.39 59.77 57.27 67.96 67.85 [81] 76.98 81.08 91.66 84.84 85.73 84.61 92.91 99.80 121.19 122.04 [91] 131.76 138.48 153.47 189.95 182.22 198.08 135.36 125.02 143.50 173.95 [101] 188.75 167.44 158.95 169.53 113.66 107.59 92.67 85.35 90.13 89.31 [111] 105.12 125.83 135.81 142.43 163.39 168.21 185.35 188.50 199.91 210.73 [121] 192.06 204.62 235.00 261.09 256.88 251.53 257.25 243.10 283.75 300.98 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/1t8ep1292237033.tab") + } + } > m Conditional inference tree with 9 terminal nodes Response: APPLE Inputs: VOLUME, MICROSOFT, NASDAQ, INFLATION, CONS.CONF, FED.FUNDS.RATE Number of observations: 130 1) CONS.CONF <= 62.7; criterion = 1, statistic = 44.873 2) NASDAQ <= 2091.88; criterion = 1, statistic = 21.304 3)* weights = 14 2) NASDAQ > 2091.88 4)* weights = 18 1) CONS.CONF > 62.7 5) VOLUME <= 24857200; criterion = 1, statistic = 54.324 6) VOLUME <= 20810300; criterion = 1, statistic = 24.456 7) NASDAQ <= 2151.83; criterion = 1, statistic = 22.125 8) NASDAQ <= 1805.43; criterion = 0.993, statistic = 10.553 9) NASDAQ <= 1595.91; criterion = 0.996, statistic = 11.772 10)* weights = 12 9) NASDAQ > 1595.91 11)* weights = 8 8) NASDAQ > 1805.43 12)* weights = 23 7) NASDAQ > 2151.83 13)* weights = 12 6) VOLUME > 20810300 14)* weights = 8 5) VOLUME > 24857200 15) MICROSOFT <= 25.27; criterion = 1, statistic = 21.273 16)* weights = 16 15) MICROSOFT > 25.27 17)* weights = 19 > postscript(file="/var/www/rcomp/tmp/2t8ep1292237033.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/rcomp/tmp/3t8ep1292237033.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 25.94 49.072500 -23.13250000 2 28.66 26.128333 2.53166667 3 33.95 26.128333 7.82166667 4 31.01 26.128333 4.88166667 5 21.00 26.128333 -5.12833333 6 26.19 26.128333 0.06166667 7 25.41 26.128333 -0.71833333 8 30.47 26.128333 4.34166667 9 12.88 50.825000 -37.94500000 10 9.78 119.258421 -109.47842105 11 8.25 26.128333 -17.87833333 12 7.44 26.128333 -18.68833333 13 10.81 49.072500 -38.26250000 14 9.12 13.544348 -4.42434783 15 11.03 13.544348 -2.51434783 16 12.74 13.544348 -0.80434783 17 9.98 13.544348 -3.56434783 18 11.62 26.128333 -14.50833333 19 9.40 13.544348 -4.14434783 20 9.27 10.390000 -1.12000000 21 7.76 7.716667 0.04333333 22 8.78 10.390000 -1.61000000 23 10.65 13.544348 -2.89434783 24 10.95 13.544348 -2.59434783 25 12.36 13.544348 -1.18434783 26 10.85 10.390000 0.46000000 27 11.84 13.544348 -1.70434783 28 12.14 10.390000 1.75000000 29 11.65 10.390000 1.26000000 30 8.86 7.716667 1.14333333 31 7.63 7.716667 -0.08666667 32 7.38 7.716667 -0.33666667 33 7.25 7.716667 -0.46666667 34 8.03 7.716667 0.31333333 35 7.75 7.716667 0.03333333 36 7.16 7.716667 -0.55666667 37 7.18 7.716667 -0.53666667 38 7.51 7.716667 -0.20666667 39 7.07 115.362143 -108.29214286 40 7.11 7.716667 -0.60666667 41 8.98 7.716667 1.26333333 42 9.53 10.390000 -0.86000000 43 10.54 10.390000 0.15000000 44 11.31 13.544348 -2.23434783 45 10.36 10.390000 -0.03000000 46 11.44 13.544348 -2.10434783 47 10.45 13.544348 -3.09434783 48 10.69 13.544348 -2.85434783 49 11.28 13.544348 -2.26434783 50 11.96 13.544348 -1.58434783 51 13.52 13.544348 -0.02434783 52 12.89 13.544348 -0.65434783 53 14.03 13.544348 0.48565217 54 16.27 13.544348 2.72565217 55 16.17 13.544348 2.62565217 56 17.25 13.544348 3.70565217 57 19.38 13.544348 5.83565217 58 26.20 50.825000 -24.62500000 59 33.53 50.825000 -17.29500000 60 32.20 50.825000 -18.62500000 61 38.45 50.825000 -12.37500000 62 44.86 50.825000 -5.96500000 63 41.67 49.072500 -7.40250000 64 36.06 50.825000 -14.76500000 65 39.76 49.072500 -9.31250000 66 36.81 13.544348 23.26565217 67 42.65 26.128333 16.52166667 68 46.89 26.128333 20.76166667 69 53.61 49.072500 4.53750000 70 57.59 50.825000 6.76500000 71 67.82 49.072500 18.74750000 72 71.89 49.072500 22.81750000 73 75.51 119.258421 -43.74842105 74 68.49 50.825000 17.66500000 75 62.72 50.825000 11.89500000 76 70.39 50.825000 19.56500000 77 59.77 50.825000 8.94500000 78 57.27 50.825000 6.44500000 79 67.96 50.825000 17.13500000 80 67.85 50.825000 17.02500000 81 76.98 50.825000 26.15500000 82 81.08 49.072500 32.00750000 83 91.66 119.258421 -27.59842105 84 84.84 119.258421 -34.41842105 85 85.73 119.258421 -33.52842105 86 84.61 119.258421 -34.64842105 87 92.91 119.258421 -26.34842105 88 99.80 119.258421 -19.45842105 89 121.19 119.258421 1.93157895 90 122.04 119.258421 2.78157895 91 131.76 119.258421 12.50157895 92 138.48 119.258421 19.22157895 93 153.47 119.258421 34.21157895 94 189.95 119.258421 70.69157895 95 182.22 119.258421 62.96157895 96 198.08 119.258421 78.82157895 97 135.36 119.258421 16.10157895 98 125.02 119.258421 5.76157895 99 143.50 119.258421 24.24157895 100 173.95 218.937222 -44.98722222 101 188.75 218.937222 -30.18722222 102 167.44 218.937222 -51.49722222 103 158.95 218.937222 -59.98722222 104 169.53 218.937222 -49.40722222 105 113.66 115.362143 -1.70214286 106 107.59 115.362143 -7.77214286 107 92.67 115.362143 -22.69214286 108 85.35 115.362143 -30.01214286 109 90.13 115.362143 -25.23214286 110 89.31 115.362143 -26.05214286 111 105.12 115.362143 -10.24214286 112 125.83 115.362143 10.46785714 113 135.81 115.362143 20.44785714 114 142.43 115.362143 27.06785714 115 163.39 115.362143 48.02785714 116 168.21 115.362143 52.84785714 117 185.35 218.937222 -33.58722222 118 188.50 115.362143 73.13785714 119 199.91 218.937222 -19.02722222 120 210.73 218.937222 -8.20722222 121 192.06 218.937222 -26.87722222 122 204.62 218.937222 -14.31722222 123 235.00 218.937222 16.06277778 124 261.09 218.937222 42.15277778 125 256.88 218.937222 37.94277778 126 251.53 218.937222 32.59277778 127 257.25 218.937222 38.31277778 128 243.10 218.937222 24.16277778 129 283.75 218.937222 64.81277778 130 300.98 218.937222 82.04277778 > 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/rcomp/tmp/44ivs1292237033.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/rcomp/tmp/5iab11292237033.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/rcomp/tmp/6tjam1292237033.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/rcomp/tmp/7w19a1292237033.tab") + } > try(system("convert tmp/2t8ep1292237033.ps tmp/2t8ep1292237033.png",intern=TRUE)) character(0) > try(system("convert tmp/3t8ep1292237033.ps tmp/3t8ep1292237033.png",intern=TRUE)) character(0) > try(system("convert tmp/44ivs1292237033.ps tmp/44ivs1292237033.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.010 0.680 3.708