Correlation is usually defined as a measure of the linear relationship between two quantitative variables (e.g. : relation between height and weight ) .Simply correlation mean that there is some type of relationship between two variables.

Types of correlation

  1. There are two types of correlation when the values of one variable increase as the values of the other increase, this is known as positive correlation .

2. When the values of one variable decrease as the values of another increase to form an inverse relationship, this is known as negative correlation.

3. When there is no linear dependency between the variables , this know as No Correlation.

NO Correlation

4. when there is a functional dependency between the variables. In this case all the points are in a straight line, this know as Perfect Correlation.

5. When a correlation is stronger the closer the points are located to one another on the line. this know as Strong Correlation.

6. When a correlation is weaker the farther apart the points are located to one another on the line, this known as Weak Correlation.

Methods for correlation analyses

There are different correlation analysis methods to find correlation between two variables .

Pearson correlation 

which measures a linear dependence between two variables (x and y). It’s also known as a parametric correlation test because it depends to the distribution of the data. It can be used only when x and y are from normal distribution. The plot of y = f(x) is named the linear regression curve.

formula of Pearson correlation

Pearson correlation

Spearman correlation

The Spearman correlation method computes the correlation between the rank of x and the rank of y variables.

Kendall correlation formula

The Kendall correlation method measures the correspondence between the ranking of x and y variables.

Finding correlation with R

We use cor() function to find the correlation between two variables.

Lets take a example facebook Posts (site updates) and fan interactions table shows below.

Lets plot the table using scatter plot

x <- c(16,31,27,23,15,17,17,18,14,13)
y <- c(165,314,280,195,137,286,199,128,462,236)

plot(x,y, main= "Scatter plot", ylab = ",Fan_interactions" , xlab = "Facebook_posts_updates" , pch = 19)

Lets find the correlation of x and y variables

cor(x,y) 
 [1] 0.126395 

This is how we find the correlation between two variables.Now lets see about Covariance.

Covariance

Covariance is a measure of the linear relationship between two variables. A positive value indicates a direct or increasing linear relationship, and a negative value indicates a decreasing linear relationship.

We use cov()function find the covariance of a two variables .Lets find the covariance using R

cov(x,y)
[1] 75.64444

This how we doing the correlation with R

soure 01 : http://www.sthda.com/english/wiki/correlation-test-between-two-variables-in-r

source 02 : http://www.r-tutor.com/elementary-statistics/numerical-measures/covariance

source 03 : https://www.displayr.com/what-is-correlation/