
This again make sense as fast cars tend to consume more fuel. On the contrary, from the correlation matrix we see that the correlation between miles per gallon ( mpg) and the time to drive 1/4 of a mile ( qsec) is 0.42, meaning that fast cars (low qsec) tend to have a worse millage per gallon (low mpg). This makes sense, cars with more horsepower tend to consume more fuel (and thus have a lower millage par gallon). This also means that a correlation close to 0 indicates that the two variables are independent, that is, as one variable increases, there is no tendency in the other variable to either decrease or increase.Īs an illustration, the Pearson correlation between horsepower ( hp) and miles per gallon ( mpg) found above is -0.78, meaning that the 2 variables vary in opposite direction. Regarding the strength of the relationship: The more extreme the correlation coefficient (the closer to -1 or 1), the stronger the relationship. On the other hand, a positive correlation implies that the two variables under consideration vary in the same direction, i.e., if a variable increases the other one increases and if one decreases the other one decreases as well. Regarding the direction of the relationship: On the one hand, a negative correlation implies that the two variables under consideration vary in opposite directions, that is, if a variable increases the other decreases and vice versa.

The strength of the relationship between the 2 variables.The direction of the relationship between the 2 variables.Interpretation of a correlation coefficientįirst of all, correlation ranges from -1 to 1. Kendall’s tau-b which is computed from the number of concordant and discordant pairs is often used for qualitative ordinal variables.Spearman correlation (which is actually similar to Pearson but based on the ranked values for each variable rather than on the raw data) is often used to evaluate relationships involving at least one qualitative ordinal variable or two quantitative variables if the link is partially linear.

Pearson correlation is often used for quantitative continuous variables that have a linear relationship.There are several correlation methods (Run ?cor for more information about the different methods available in the cor() function): If you want to compute the Spearman correlation, add the argument method = "spearman" to the cor() function: # Spearman correlation between 2 variables The Pearson correlation is computed by default with the cor() function. Note that the correlation between variables X and Y is equal to the correlation between variables Y and X so the order of the variables in the cor() function does not matter. Suppose we want to compute the correlation between horsepower ( hp) and miles per gallon ( mpg): # Pearson correlation between 2 variables

The correlation between 2 variables is found with the cor() function.
