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(1966 + ,1 + ,41 + ,1966 + ,2 + ,39 + ,1966 + ,3 + ,50 + ,1966 + ,4 + ,40 + ,1966 + ,5 + ,43 + ,1966 + ,6 + ,38 + ,1966 + ,7 + ,44 + ,1966 + ,8 + ,35 + ,1966 + ,9 + ,39 + ,1966 + ,10 + ,35 + ,1966 + ,11 + ,29 + ,1966 + ,12 + ,49 + ,1967 + ,1 + ,50 + ,1967 + ,2 + ,59 + ,1967 + ,3 + ,63 + ,1967 + ,4 + ,32 + ,1967 + ,5 + ,39 + ,1967 + ,6 + ,47 + ,1967 + ,7 + ,53 + ,1967 + ,8 + ,60 + ,1967 + ,9 + ,57 + ,1967 + ,10 + ,52 + ,1967 + ,11 + ,70 + ,1967 + ,12 + ,90 + ,1968 + ,1 + ,74 + ,1968 + ,2 + ,62 + ,1968 + ,3 + ,55 + ,1968 + ,4 + ,84 + ,1968 + ,5 + ,94 + ,1968 + ,6 + ,70 + ,1968 + ,7 + ,108 + ,1968 + ,8 + ,139 + ,1968 + ,9 + ,120 + ,1968 + ,10 + ,97 + ,1968 + ,11 + ,126 + ,1968 + ,12 + ,149 + ,1969 + ,1 + ,158 + ,1969 + ,2 + ,124 + ,1969 + ,3 + ,140 + ,1969 + ,4 + ,109 + ,1969 + ,5 + ,114 + ,1969 + ,6 + ,77 + ,1969 + ,7 + ,120 + ,1969 + ,8 + ,133 + ,1969 + ,9 + ,110 + ,1969 + ,10 + ,92 + ,1969 + ,11 + ,97 + ,1969 + ,12 + ,78 + ,1970 + ,1 + ,99 + ,1970 + ,2 + ,107 + ,1970 + ,3 + ,112 + ,1970 + ,4 + ,90 + ,1970 + ,5 + ,98 + ,1970 + ,6 + ,125 + ,1970 + ,7 + ,155 + ,1970 + ,8 + ,190 + ,1970 + ,9 + ,236 + ,1970 + ,10 + ,189 + ,1970 + ,11 + ,174 + ,1970 + ,12 + ,178 + ,1971 + ,1 + ,136 + ,1971 + ,2 + ,161 + ,1971 + ,3 + ,171 + ,1971 + ,4 + ,149 + ,1971 + ,5 + ,184 + ,1971 + ,6 + ,155 + ,1971 + ,7 + ,276 + ,1971 + ,8 + ,224 + ,1971 + ,9 + ,213 + ,1971 + ,10 + ,279 + ,1971 + ,11 + ,268 + ,1971 + ,12 + ,287 + ,1972 + ,1 + ,238 + ,1972 + ,2 + ,213 + ,1972 + ,3 + ,257 + ,1972 + ,4 + ,293 + ,1972 + ,5 + ,212 + ,1972 + ,6 + ,246 + ,1972 + ,7 + ,353 + ,1972 + ,8 + ,339 + ,1972 + ,9 + ,308 + ,1972 + ,10 + ,247 + ,1972 + ,11 + ,257 + ,1972 + ,12 + ,322 + ,1973 + ,1 + ,298 + ,1973 + ,2 + ,273 + ,1973 + ,3 + ,312 + ,1973 + ,4 + ,249 + ,1973 + ,5 + ,286 + ,1973 + ,6 + ,279 + ,1973 + ,7 + ,309 + ,1973 + ,8 + ,401 + ,1973 + ,9 + ,309 + ,1973 + ,10 + ,328 + ,1973 + ,11 + ,353 + ,1973 + ,12 + ,354 + ,1974 + ,1 + ,327 + ,1974 + ,2 + ,324 + ,1974 + ,3 + ,285 + ,1974 + ,4 + ,243 + ,1974 + ,5 + ,241 + ,1974 + ,6 + ,287 + ,1974 + ,7 + ,355 + ,1974 + ,8 + ,460 + ,1974 + ,9 + ,364 + ,1974 + ,10 + ,487 + ,1974 + ,11 + ,452 + ,1974 + ,12 + ,391 + ,1975 + ,1 + ,500 + ,1975 + ,2 + ,451 + ,1975 + ,3 + ,375 + ,1975 + ,4 + ,372 + ,1975 + ,5 + ,302 + ,1975 + ,6 + ,316 + ,1975 + ,7 + ,398 + ,1975 + ,8 + ,394 + ,1975 + ,9 + ,431 + ,1975 + ,10 + ,431) + ,dim=c(3 + ,118) + ,dimnames=list(c('Year' + ,'Month' + ,'Robberies') + ,1:118)) > y <- array(NA,dim=c(3,118),dimnames=list(c('Year','Month','Robberies'),1:118)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par1 = 'pearson' > main = 'Correlation Matrix' > par1 <- 'pearson' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Patrick Wessa, (2012), Multivariate Correlation Matrix (v1.0.5) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/Patrick.Wessa/rwasp_pairs.wasp/ > #Source of accompanying publication: > # > 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/fisher/rcomp/tmp/1ds3b1354882568.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/2xulq1354882568.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) Pearson's product-moment correlation data: y[1, ] and y[2, ] t = -0.4313, df = 116, p-value = 0.6671 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.2191864 0.1417724 sample estimates: cor -0.04001234 > 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) + } + } Warning messages: 1: In cor.test.default(y[i, ], y[j, ], method = "spearman") : Cannot compute exact p-values with ties 2: In cor.test.default(y[i, ], y[j, ], method = "spearman") : Cannot compute exact p-values with ties 3: In cor.test.default(y[i, ], y[j, ], method = "spearman") : Cannot compute exact p-values with ties > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/34f9b1354882568.tab") > > try(system("convert tmp/1ds3b1354882568.ps tmp/1ds3b1354882568.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.095 0.275 1.346