Correlation and Covariance in R (R Tutorial 4.9)
In this video, you will learn to calculate Pearson's correlation, a parametric measure of the linear association between two quantitative continuous variables, Spearman's rank correlation, a non-parametric measure of the association between two quantitative variables, and Kendall's rank correlation, a non-parametric test that measures the strength of dependence between two variables.
We will start this video tutorial by explaining what Pearson’s correlation, Spearman's rank correlation and Kendall’s rank correlation are and when to use them.
In order to examine the data visually, we will produce a scatterplot in R to explore the relationship between variables using "plot" command; then you will learn to calculate the correlation between variables using the "cor" command and to produce Pearson's, Spearman's rank and Kendall's rank correlation in R using the "method" argument on the "cor" command.
You will also learn to produce a confidence interval and test the hypothesis for the correlation using the "cor.test" command and calculate the "p value" when there are exact values in dataset using the "exact" argument. Further you will see how to change the alternative hypothesis using the "alt" argument and change the confidence level using the "conf.level" command.
You will also learn to calculate the covariance or to produce the covariance matrix in R using the "cov" command, to produce a correlation matrix using the "cor" command and the "method" argument and dealing with categorical variables when creating correlation matrix by subsetting data using square brackets
In this tutorial you will see how to produce all possible pair-wise plots using the "pairs" command or produce a pairs’ plot only for some of the variables in the dataset by sub-setting data using square brackets.
We recommend using the link below to download the dataset and practice on your own while watching this tutorial.
You can access and download the dataset that was used in this tutorial here: