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(4606.07 + ,54.64 + ,14.36 + ,4176.60 + ,52.39 + ,14.62 + ,4331.53 + ,52.51 + ,13.51 + ,3987.30 + ,52.92 + ,14.95 + ,4205.86 + ,55.22 + ,16.72 + ,4331.37 + ,55.41 + ,16.33 + ,4106.30 + ,57.02 + ,15.21 + ,4009.33 + ,58.55 + ,16.69 + ,3857.64 + ,57.49 + ,15.81 + ,3929.00 + ,55.52 + ,16.02 + ,4210.47 + ,57.84 + ,16.7 + ,4445.82 + ,58.69 + ,15.99 + ,4497.07 + ,59.74 + ,17.68 + ,4443.71 + ,60.7 + ,18.89 + ,4529.25 + ,60.74 + ,18.72 + ,4634.22 + ,64.32 + ,21.14 + ,4772.67 + ,66.9 + ,20.97 + ,4881.52 + ,70.93 + ,23.75 + ,5153.13 + ,75.89 + ,23.05 + ,5324.19 + ,80.6 + ,23.45 + ,5209.36 + ,81.39 + ,21.74 + ,5108.92 + ,81.33 + ,19.37 + ,5130.88 + ,77.04 + ,21.1 + ,5195.68 + ,79.54 + ,21.2 + ,5050.42 + ,81.93 + ,22.67 + ,5101.03 + ,80.79 + ,22.24 + ,5139.84 + ,81.98 + ,23.78 + ,5234.31 + ,85.94 + ,23.27 + ,5435.73 + ,86.6 + ,25.74 + ,5633.57 + ,87.42 + ,26.1 + ,5498.28 + ,93.14 + ,27.49 + ,5668.13 + ,95.76 + ,31.41 + ,5537.64 + ,99.75 + ,28.79 + ,5442.78 + ,97.71 + ,26.76 + ,5491.50 + ,94.99 + ,26.41 + ,5501.20 + ,96.41 + ,27.05 + ,5658.08 + ,96.28 + ,29.43 + ,5686.16 + ,100.14 + ,32.1 + ,5801.24 + ,99.9 + ,36.84 + ,5678.40 + ,102.87 + ,34.22 + ,5793.68 + ,107.37 + ,36.53 + ,5866.10 + ,115.68 + ,40.99 + ,6087.27 + ,124.33 + ,45.97 + ,6058.70 + ,128.44 + ,43.6 + ,6171.63 + ,130.19 + ,47.84 + ,6385.55 + ,148.4 + ,51.47 + ,6180.05 + ,169.14 + ,51.31 + ,6159.65 + ,153.98 + ,48.47 + ,6271.59 + ,163.13 + ,48.28 + ,6365.59 + ,165.4 + ,46.56 + ,6420.76 + ,166.35 + ,43.83 + ,6628.97 + ,173.73 + ,51.17 + ,6731.85 + ,174.23 + ,49.59 + ,6884.40 + ,177.04 + ,49.11 + ,6927.25 + ,170.78 + ,49.97 + ,6796.18 + ,174.01 + ,50.07 + ,6903.69 + ,183.76 + ,53.3 + ,7189.46 + ,201.95 + ,57.08 + ,7435.08 + ,205.38 + ,68.54 + ,7379.99 + ,197.36 + ,71.62 + ,7174.80 + ,196.53 + ,67.64 + ,7233.46 + ,179.94 + ,64.79 + ,7597.58 + ,174.84 + ,80.97 + ,7790.04 + ,179.86 + ,88.42 + ,7466.77 + ,172.77 + ,110.22 + ,7350.45 + ,162.56 + ,99 + ,6850.64 + ,178.4 + ,95.95 + ,6717.18 + ,190.83 + ,107.94 + ,6600.54 + ,201.07 + ,97.82 + ,6979.58 + ,198.95 + ,111.64 + ,6971.45 + ,190.46 + ,114.73 + ,6411.48 + ,186.27 + ,117.58 + ,6276.01 + ,187.96 + ,99.19 + ,6190.56 + ,174.99 + ,90.19 + ,5618.64 + ,164.1 + ,59.74 + ,4595.00 + ,131.48 + ,44.51 + ,4287.38 + ,116.14 + ,23.94 + ,4385.35 + ,103.43 + ,21.29 + ,3927.01 + ,96.87 + ,20.77 + ,3495.28 + ,93.68 + ,25.07 + ,3757.45 + ,96.49 + ,32.95 + ,4076.75 + ,105.22 + ,40.05 + ,4475.36 + ,110.11 + ,44.59 + ,4396.44 + ,118.47 + ,40.28 + ,4766.91 + ,122.15 + ,41.19 + ,4907.38 + ,137.35 + ,38.14 + ,5069.67 + ,134.83 + ,41.85 + ,4983.56 + ,138.34 + ,43.76 + ,5245.81 + ,141.98 + ,50.16 + ,5241.07 + ,149.45 + ,52.94 + ,5003.74 + ,154.68 + ,47.69 + ,5075.38 + ,145.98 + ,51.52 + ,5358.33 + ,156.33 + ,58.69 + ,5298.80 + ,176.28 + ,50.44 + ,4784.64 + ,159.08 + ,45.72 + ,4579.82 + ,151.18 + ,43.24 + ,4982.42 + ,162.63 + ,51.49 + ,4776.39 + ,174.2 + ,50.43 + ,5157.48 + ,180.51 + ,58.73 + ,5305.21 + ,185.31 + ,65.12 + ,5187.20 + ,186.33 + ,64.13) + ,dim=c(3 + ,101) + ,dimnames=list(c('World_Leaders' + ,'Commodity' + ,'Rio_Tinto ') + ,1:101)) > y <- array(NA,dim=c(3,101),dimnames=list(c('World_Leaders','Commodity','Rio_Tinto '),1:101)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par1 = 'kendall' > main = 'Correlation Matrix' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Patrick Wessa > #To cite this work: Patrick Wessa, (2010), Multivariate Correlation Matrix (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/Patrick.Wessa/rwasp_pairs.wasp#output/ > #Source of accompanying publication: > #Technical description: > panel.tau <- function(x, y, digits=2, prefix='', cex.cor) + { + usr <- par('usr'); on.exit(par(usr)) + par(usr = c(0, 1, 0, 1)) + rr <- cor.test(x, y, method=par1) + r <- round(rr$p.value,2) + txt <- format(c(r, 0.123456789), digits=digits)[1] + txt <- paste(prefix, txt, sep='') + if(missing(cex.cor)) cex <- 0.5/strwidth(txt) + text(0.5, 0.5, txt, cex = cex) + } > panel.hist <- function(x, ...) + { + usr <- par('usr'); on.exit(par(usr)) + par(usr = c(usr[1:2], 0, 1.5) ) + h <- hist(x, plot = FALSE) + breaks <- h$breaks; nB <- length(breaks) + y <- h$counts; y <- y/max(y) + rect(breaks[-nB], 0, breaks[-1], y, col='grey', ...) + } > postscript(file="/var/www/html/rcomp/tmp/1sdzq1292785521.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pairs(t(y),diag.panel=panel.hist, upper.panel=panel.smooth, lower.panel=panel.tau, main=main) Warning messages: 1: In strwidth(labels, "user") : font width unknown for character 0xd 2: In text.default(x, y, txt, cex = cex, font = font) : font width unknown for character 0xd 3: In text.default(x, y, txt, cex = cex, font = font) : font metrics unknown for character 0xd > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > n <- length(y[,1]) > n [1] 3 > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,paste('Correlations for all pairs of data series (method=',par1,')',sep=''),n+1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,' ',header=TRUE) > for (i in 1:n) { + a<-table.element(a,dimnames(t(x))[[2]][i],header=TRUE) + } > a<-table.row.end(a) > for (i in 1:n) { + a<-table.row.start(a) + a<-table.element(a,dimnames(t(x))[[2]][i],header=TRUE) + for (j in 1:n) { + r <- cor.test(y[i,],y[j,],method=par1) + a<-table.element(a,round(r$estimate,3)) + } + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/2vdxv1292785521.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Correlations for all pairs of data series with p-values',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'pair',1,TRUE) > a<-table.element(a,'Pearson r',1,TRUE) > a<-table.element(a,'Spearman rho',1,TRUE) > a<-table.element(a,'Kendall tau',1,TRUE) > a<-table.row.end(a) > cor.test(y[1,],y[2,],method=par1) Kendall's rank correlation tau data: y[1, ] and y[2, ] z = 8.4212, p-value < 2.2e-16 alternative hypothesis: true tau is not equal to 0 sample estimates: tau 0.5683168 > for (i in 1:(n-1)) + { + for (j in (i+1):n) + { + a<-table.row.start(a) + dum <- paste(dimnames(t(x))[[2]][i],';',dimnames(t(x))[[2]][j],sep='') + a<-table.element(a,dum,header=TRUE) + rp <- cor.test(y[i,],y[j,],method='pearson') + a<-table.element(a,round(rp$estimate,4)) + rs <- cor.test(y[i,],y[j,],method='spearman') + a<-table.element(a,round(rs$estimate,4)) + rk <- cor.test(y[i,],y[j,],method='kendall') + a<-table.element(a,round(rk$estimate,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'p-value',header=T) + a<-table.element(a,paste('(',round(rp$p.value,4),')',sep='')) + a<-table.element(a,paste('(',round(rs$p.value,4),')',sep='')) + a<-table.element(a,paste('(',round(rk$p.value,4),')',sep='')) + a<-table.row.end(a) + } + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3zvw11292785521.tab") > > try(system("convert tmp/1sdzq1292785521.ps tmp/1sdzq1292785521.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.495 0.216 3.146