Packages
In R, there are several packages that provide the correlation functionality to the programmer. We will be using the following packages in this chapter:
corrgram
: This is the tool to graphically display correlationsHmisc
: This contains a variety of miscellaneous R functionspolycor
: This contains functions to compute polychoric correlationsggm
: This contains functions for analyzing and fitting graphical Markov models
Correlation
Basic correlation is performed in R using the cor
function. The cor
function is defined as follows:
cor(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman"))
The various parameters of this function are described in the following table:
Parameter |
Description |
---|---|
|
This is the dataset. |
|
This is the dataset that is compatible with |
|
This is the optional method for computing the covariance of missing values assigned. The choices are:
|