R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(1 + ,521 + ,18308 + ,185 + ,4.041 + ,7.2 + ,1 + ,367 + ,1148 + ,600 + ,0.55 + ,8.5 + ,1 + ,443 + ,18068 + ,372 + ,3.665 + ,5.7 + ,1 + ,365 + ,7729 + ,142 + ,2.351 + ,7.3 + ,1 + ,614 + ,100484 + ,432 + ,29.76 + ,7.5 + ,1 + ,385 + ,16728 + ,290 + ,3.294 + ,5 + ,1 + ,286 + ,14630 + ,346 + ,3.287 + ,6.7 + ,1 + ,397 + ,4008 + ,328 + ,0.666 + ,6.2 + ,1 + ,764 + ,38927 + ,354 + ,12.938 + ,7.3 + ,1 + ,427 + ,22322 + ,266 + ,6.478 + ,5 + ,1 + ,153 + ,3711 + ,320 + ,1.108 + ,2.8 + ,1 + ,231 + ,3136 + ,197 + ,1.007 + ,6.1 + ,1 + ,524 + ,50508 + ,266 + ,11.431 + ,7.1 + ,1 + ,328 + ,28886 + ,173 + ,5.544 + ,5.9 + ,1 + ,240 + ,16996 + ,190 + ,2.777 + ,4.6 + ,1 + ,286 + ,13035 + ,239 + ,2.478 + ,4.4 + ,1 + ,285 + ,12973 + ,190 + ,3.685 + ,7.4 + ,1 + ,569 + ,16309 + ,241 + ,4.22 + ,7.1 + ,1 + ,96 + ,5227 + ,189 + ,1.228 + ,7.5 + ,1 + ,498 + ,19235 + ,358 + ,4.781 + ,5.9 + ,1 + ,481 + ,44487 + ,315 + ,6.016 + ,9 + ,1 + ,468 + ,44213 + ,303 + ,9.295 + ,9.2 + ,1 + ,177 + ,23619 + ,228 + ,4.375 + ,5.1 + ,1 + ,198 + ,9106 + ,134 + ,2.573 + ,8.6 + ,1 + ,458 + ,24917 + ,189 + ,5.117 + ,6.6 + ,1 + ,108 + ,3872 + ,196 + ,0.799 + ,6.9 + ,1 + ,246 + ,8945 + ,183 + ,1.578 + ,2.7 + ,1 + ,291 + ,2373 + ,417 + ,1.202 + ,5.5 + ,1 + ,68 + ,7128 + ,233 + ,1.109 + ,7.2 + ,1 + ,311 + ,23624 + ,349 + ,7.73 + ,6.6 + ,1 + ,606 + ,5242 + ,284 + ,1.515 + ,6.9 + ,1 + ,512 + ,92629 + ,499 + ,17.99 + ,7.2 + ,1 + ,426 + ,28795 + ,231 + ,6.629 + ,5.8 + ,1 + ,47 + ,4487 + ,143 + ,0.639 + ,4.1 + ,1 + ,265 + ,48799 + ,249 + ,10.847 + ,6.4 + ,1 + ,370 + ,14067 + ,195 + ,3.146 + ,6.7 + ,1 + ,312 + ,12693 + ,288 + ,2.842 + ,6 + ,1 + ,222 + ,62184 + ,229 + ,11.882 + ,6.9 + ,1 + ,280 + ,9153 + ,287 + ,1.003 + ,8.5 + ,1 + ,759 + ,14250 + ,224 + ,3.487 + ,6.2 + ,1 + ,114 + ,3680 + ,161 + ,0.696 + ,3.4 + ,1 + ,419 + ,18063 + ,221 + ,4.877 + ,6.6 + ,1 + ,435 + ,65112 + ,237 + ,16.987 + ,6.6 + ,1 + ,186 + ,11340 + ,220 + ,1.723 + ,4.9 + ,1 + ,87 + ,4553 + ,185 + ,0.563 + ,6.4 + ,1 + ,188 + ,28960 + ,260 + ,6.187 + ,5.8 + ,1 + ,303 + ,19201 + ,261 + ,4.867 + ,6.3 + ,1 + ,102 + ,7533 + ,118 + ,1.793 + ,10.5 + ,1 + ,127 + ,26343 + ,268 + ,4.892 + ,5.4 + ,1 + ,251 + ,1641 + ,300 + ,0.454 + ,5.1 + ,0 + ,205 + ,145360 + ,237 + ,10.379 + ,6.8 + ,0 + ,453 + ,9066420 + ,240 + ,82.422 + ,5.6 + ,0 + ,320 + ,1038933 + ,185 + ,16.491 + ,3.8 + ,0 + ,405 + ,2739420 + ,201 + ,60.876 + ,8.2 + ,0 + ,89 + ,61620 + ,193 + ,0.474 + ,4.1 + ,0 + ,74 + ,827530 + ,254 + ,7.523 + ,2.8 + ,0 + ,101 + ,534100 + ,230 + ,5.45 + ,6.3 + ,0 + ,321 + ,328755 + ,197 + ,10.605 + ,11.4 + ,0 + ,315 + ,1413895 + ,248 + ,40.397 + ,19.4 + ,0 + ,229 + ,2909136 + ,258 + ,60.607 + ,5.8 + ,0 + ,302 + ,3604246 + ,206 + ,58.133 + ,6.9 + ,0 + ,216 + ,917504 + ,199 + ,8.192 + ,3.5) + ,dim=c(6 + ,62) + ,dimnames=list(c('Pop' + ,'Assaults' + ,'BachDgr' + ,'PoliceExp' + ,'TotlPopul' + ,'Unempl') + ,1:62)) > y <- array(NA,dim=c(6,62),dimnames=list(c('Pop','Assaults','BachDgr','PoliceExp','TotlPopul','Unempl'),1:62)) > 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' > 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/wessaorg/rcomp/tmp/10n5h1354817979.ps",horizontal=F,onefile=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) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > n <- length(y[,1]) > n [1] 6 > 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/wessaorg/rcomp/tmp/2awb41354817979.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 = 1.3363, p-value = 0.1814 alternative hypothesis: true tau is not equal to 0 sample estimates: tau 0.140859 > 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) + } + } There were 14 warnings (use warnings() to see them) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/3xtrw1354817979.tab") > > try(system("convert tmp/10n5h1354817979.ps tmp/10n5h1354817979.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.414 0.209 1.596