Questions tagged [pearson]

in statistics, Pearson's r, the Pearson product moment correlation coefficient, shows the extent of a linear relationship between two data sets on a scale from -1 to 1.

Overview

Pearson product-moment correlation coefficient is given by the following equation:

enter image description here

where,

pXY = Pearson’s correlation coefficient;
Cov(X,Y) = covariance of random variables X and Y;
Var(X) = variance of random variable X;
Var(Y) = variance of random variable Y;


Tag usage

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

155 questions
0
votes
0 answers

Calculate the pearson correlation between two lists

I have many equally structured text files containing experimental data (641*976). At the beginning I define the correct "working directory" and order all the files in a list. Thereby I generate two different lists. Once the file.listx containing my…
stefx
  • 25
  • 10
0
votes
1 answer

Have a problem computing pearson p-value for dict values

I want to compute the pearson p value for values of two dictionaries using for loop. Dictionaries represent the data of two dataframes one of which has some changes. The dictionaries contain the info on the name of columns, the keys and the…
Ison
  • 403
  • 2
  • 9
0
votes
3 answers

Pearson correlation matrix in Python, ValueError

I'm trying to get a matrix, (lat, lon) size, with the Pearson Coefficient value for every grid point, for x : a 3D DataArray (time, lat, lon) (time size is 30) y : a DataArray column vector with a 30 values series inside So i would like to calculate…
0
votes
0 answers

How to calculate generalized moments for 3 time-series, i.e., coskew between 3 time series, and cokurtosis between 4 time series, etc

I would like to compute a "generalization of the Pearson correlation coefficient", the nth- comomentum that could work for n time series. In short, I would like to have a function that receives n different time series and: for n=2 gives me the…
0
votes
2 answers

How can I interpret correlation results?

I have some doubts about Pearson correlation in Matlab, especially in regard to the concept of p-value. I have 2 vectors (A and B) and I computed Pearson correlation using corrcoeff function. I have the following results: Correlation 1 …
0
votes
2 answers

Generate numpy array with duplicate rate

Here is my problem: i have to generate some synthetic data (like 7/8 columns), correlated each other (using pearson coefficient). I can do this easily, but next i have to insert a percentage of duplicates in each column (yes, pearson coefficent will…
davide
  • 91
  • 7
0
votes
0 answers

How to calculate Pearson's correlation coefficient in R for grouped data

How to calculate Karl Pearson's correlation coefficient "using R" for data with frequency distribution. Say, if we need to calculate the Pearson's coefficient for data enclosed in the screenshot, how would we do it ??
deep
  • 91
  • 1
  • 2
  • 8
0
votes
1 answer

Bootstrap correlation matlab

I want to correlate two arrays (A and B) from a medical image. I expect a high correlation since they come from the same patient (acquired twice in the same session). [rho, p] = corr(A(:), B(:)) gives me rho = 0.8321 but p = 0.1255 so the…
Inchan
  • 1
  • 3
0
votes
1 answer

Python: Pearson's r

So this is my code for calculating the correlation between two variables using pearson's r. def correlation(x, y): std_x = (x - x.mean()) / x.std(ddof=0) std_y = (y - y.mean()) / y.std(ddof=0) return (std_x * std_y).mean() I…
MM3
  • 87
  • 1
  • 9
0
votes
0 answers

Weighted Pearson's Correlation with one Object

I want to create a correlation matrix using data but weighted based on significant edges. m <- matrix(data = rnorm(36), nrow = 6, ncol = 6) x <- LETTERS[1:6] for (a in 1:length(x)) y <- c(y, paste("c", a, sep = "")) mCor <- cor(t(m)) w <-…
abbas786
  • 401
  • 3
  • 11
0
votes
2 answers

Python nested loop - table index as variable

I am not Python programmer, but I need to use some method from SciPy library. I just want to repeat inner loop a couple of times, but with changed index of table. Here is my code for now: from scipy.stats import pearsonr fileName =…
0
votes
1 answer

Numpy TypeError: an integer is required

This will be maybe quite personal question but I don't know who to ask I hope somebody can help and don't skip me THANKS!. I have installed python using Anaconda and using Jupyter notebook. I have 2 csv files of data. products.head() ID_FUPID …
Simon
  • 17
  • 1
  • 4
0
votes
1 answer

Default parameter on python function not always working

I'm reading Programming Collective Intelligence and writing some of the code in a more pythonic way than it's written in the book, just for the sake of learning. The first chapter is about recommendation systems. Based on the next dictionary, some…
Xoel
  • 318
  • 4
  • 15
0
votes
2 answers

How to replace missing value with Pearson Correlation on MATLAB

I have problem with using 'corr' function in MATLAB, a = 1 4 3 2 2 3 3 2 3 2 3 2 4 1 3 2 >> corr(a) ans = 1 -1 NaN NaN -1 1 NaN NaN NaN NaN NaN …
user555928
  • 1
  • 1
  • 1
0
votes
1 answer

R Error in correlation test. 'x' must be a numeric vector

I know that this question has been asked before but not in the context i am asking it now. I have a dataframe that looks like this year Units 1 2005-2007 0.082 2 2008-2010 0.411 3 2011-2013 1.258 my simple code looks like…
tom sawyer
  • 47
  • 1
  • 2
  • 9