correlation

How to change font size of the correlation coefficient in corrplot?

六月ゝ 毕业季﹏ 提交于 2019-11-27 14:45:27
问题 I am plotting correlation plot with corrplot. I want to plot also the correlation coefficients: require(corrplot) test <- matrix(data = rnorm(400), nrow=20, ncol=20) corrplot(cor(test), method = "color", addCoef.col="grey", order = "AOE") But they are too big in the plot: Is there any way to make the font of the coefficent smaller? I've been looking at ?corrplot but there are only parameters to change the legend and axis font sizes ( cl.cex and tl.cex ). pch.cex doesn't work either. 回答1: It

How to modify this Correlation Matrix plot?

白昼怎懂夜的黑 提交于 2019-11-27 12:34:21
问题 I have the following codes to display a correlation matrix, panel.cor <- function(x, y, digits=2, prefix="", cex.cor) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits=digits)[1] txt <- paste(prefix, txt, sep="") if(missing(cex.cor)) cex <- 0.8/strwidth(txt) test <- cor.test(x,y) # borrowed from printCoefmat Signif <- symnum(test$p.value, corr = FALSE, na = FALSE, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c

Calculate correlation - cor() - for only a subset of columns

一曲冷凌霜 提交于 2019-11-27 10:27:57
I have a dataframe and would like to calculate the correlation (with Spearman, data is categorical and ranked) but only for a subset of columns. I tried with all, but R's cor () function only accepts numerical data (x must be numeric, says the error message), even if Spearman is used. One brute approach is to delete the non-numerical columns from the dataframe. This is not as elegant, for speed I still don't want to calculate correlations between all columns. I hope there is a way to simply say "calculate correlations for columns x, y, z". Column references could by number or by name. I

Generate correlated random numbers from binomial distributions in R

大憨熊 提交于 2019-11-27 08:44:14
I am trying to find a way to generate correlated random numbers from several binomial distributions. I know how to do it with normal distributions (using mvrnorm), but I did not find a function applicable to binomial ones. You can generate correlated uniforms using the copula package, then use the qbinom function to convert those to binomial variables. Here is one quick example: library(copula) tmp <- normalCopula( 0.75, dim=2 ) x <- rcopula(tmp, 1000) x2 <- cbind( qbinom(x[,1], 10, 0.5), qbinom(x[,2], 15, 0.7) ) Now x2 is a matrix with the 2 columns representing 2 binomial variables that are

Correlation of two arrays in C#

痴心易碎 提交于 2019-11-27 07:51:34
Having two arrays of double values, I want to compute correlation coefficient (single double value, just like the CORREL function in MS Excel). Is there some simple one-line solution in C#? I already discovered math lib called Meta Numerics. According to this SO question , it should do the job. Here is docs for Meta Numerics correlation method, which I don't get. Could pls somebody provide me with simple code snippet or example how to use the library? Note: At the end, I was forced to use one of custom implementations. But if someone reading this question knows good, well documented C# math

How can I set a minimum distance constraint for generating points with numpy.random.rand?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 07:42:50
问题 I am trying to generate an efficient code for generating a number of random position vectors which I then use to calculate a pair correlation function. I am wondering if there is straightforward way to set a constraint on the minimum distance allowed between any two points placed in my box. My code currently is as follows: def pointRun(number, dr): """ Compute the 3D pair correlation function for a random distribution of 'number' particles placed into a 1.0x1.0x1.0 box. """ ## Create array of

Efficient pairwise correlation for two matrices of features

前提是你 提交于 2019-11-27 06:59:21
问题 In Python I need to find the pairwise correlation between all features in a matrix A and all features in a matrix B . In particular, I am interesting in finding the strongest Pearson correlation that a given feature in A has across all features in B . I do not care whether the strongest correlation is positive or negative. I've done a inefficient implementation using two loops and scipy below. However, I'd like to use np.corrcoef or another similar method to compute it efficiently. Matrix A

Does calculating correlation between two dataframes require a loop?

Deadly 提交于 2019-11-27 06:43:06
问题 I have a set of large dataframes that look like A and B: A <- data.frame(A1=c(1,2,3,4,5),B1=c(6,7,8,9,10),C1=c(11,12,13,14,15 )) A1 B1 C1 1 1 6 11 2 2 7 12 3 3 8 13 4 4 9 14 5 5 10 15 B <- data.frame(A2=c(6,7,7,10,11),B2=c(2,1,3,8,11),C2=c(1,5,16,7,8)) A2 B2 C2 1 6 2 1 2 7 1 5 3 7 3 16 4 10 8 7 5 11 11 8 I would like to create a vector (C) that denotes the Pearson correlation between A1 & A2, B1 & B2, and C1 & C2. In this case, for example, those correlations are: [1] 0.95 0.92 0.46 回答1: cor

find time shift between two similar waveforms

瘦欲@ 提交于 2019-11-27 06:34:39
I have to compare two time-vs-voltage waveforms. Because of the peculiarity of the sources of these waveforms, one of them can be a time shifted version of the other. How can i find whether there is a time shift? and if yes, how much is it. I am doing this in Python and wish to use numpy/scipy libraries. Gus scipy provides a correlation function which will work fine for small input and also if you want non-circular correlation meaning that the signal will not wrap around. note that in mode='full' , the size of the array returned by signal.correlation is sum of the signal sizes minus one (i.e.

Spearman correlation and ties

帅比萌擦擦* 提交于 2019-11-27 05:22:45
问题 I'm computing Spearman's rho on small sets of paired rankings. Spearman is well known for not handling ties properly. For example, taking 2 sets of 8 rankings, even if 6 are ties in one of the two sets, the correlation is still very high: > cor.test(c(1,2,3,4,5,6,7,8), c(0,0,0,0,0,0,7,8), method="spearman") Spearman's rank correlation rho S = 19.8439, p-value = 0.0274 sample estimates: rho 0.7637626 Warning message: Cannot compute exact p-values with ties The p-value <.05 seems like a pretty