Covariance and Correlation
Covariance is a measure of the joint variability of two random variables. Covariance measures the linear relationship between two variables.
If the greater values of one variable mainly correspond with the greater values of the other variable, and the same holds for the lesser values, i.e., the variables tend to show similar behavior, the covariance is positive. and if the variables tend to show opposite behavior, the covariance is negative.
A correlation coefficient measures the extent to which two variables tend to change together. The coefficient describes both the strength and the direction of the relationship.
What is a monotonic relationship?
A monotonic relationship is a relationship that does one of the following: (1) as the value of one variable increases, so does the value of the other variable; or (2) as the value of one variable increases, the other variable value decreases. Examples of monotonic and non-monotonic relationships are presented in the diagram below:
Monotonicity is "less restrictive" than that of a linear relationship.
For example, the middle image above shows a relationship that is monotonic, but not linear.
if a scatterplot shows that the relationship between your two variables looks monotonic you would run a Spearman's correlation because this will then measure the strength and direction of this monotonic relationship. On the other hand if, for example, the relationship appears linear (assessed via scatterplot) you would run a Pearson's correlation because this will measure the strength and direction of any linear relationship.
Pearson product moment correlation
The Pearson correlation evaluates the linear relationship between two continuous variables. A relationship is linear when a change in one variable is associated with a proportional change in the other variable.
For example, you might use a Pearson correlation to evaluate whether increases in temperature at your production facility are associated with decreasing thickness of your chocolate coating.
Spearman rank-order correlation
Also called Spearman's rho, the Spearman correlation evaluates the monotonic relationship between two continuous or ordinal variables.
The Spearman correlation coefficient is based on the ranked values for each variable rather than the raw data.
Spearman correlation is often used to evaluate relationships involving ordinal variables. For example, you might use a Spearman correlation to evaluate whether the order in which employees complete a test exercise is related to the number of months they have been employed.
Correlation coefficients only measure linear (Pearson) or monotonic (Spearman) relationships. Other relationships are possible.
Pearson = +1, Spearman = +1
Pearson = +0.851, Spearman = +1
Pearson = -1, Spearman = -1
Pearson = -0.093, Spearman = -0.093
----------------------------------------------------------------------------------------------------
A comparison of correlation and covariance
Although both the correlation coefficient and the covariance are measures of linear association, they differ in the following ways:
Correlations coefficients are standardized. Thus, a perfect linear relationship results in a coefficient of 1.
Covariance values are not standardized. Thus, the value for a perfect linear relationship depends on the data.
The correlation coefficient is a function of the covariance. The correlation coefficient is equal to the covariance divided by the product of the standard deviations of the variables.
Therefore, a positive covariance always results in a positive correlation and a negative covariance always results in a negative correlation.







