Learn R Programming

greybox (version 2.0.2)

pcor: Partial correlations

Description

Function calculates partial correlations between the provided variables

Usage

pcor(x, y = NULL, use = c("na.or.complete", "complete.obs", "everything",
  "all.obs"), method = c("pearson", "spearman", "kendall"))

Value

The following list of values is returned:

  • value - Matrix of the coefficients of partial correlations;

  • p.value - The p-values for the parameters;

  • method - The method used in the calculations.

Arguments

x

Either data.frame or a matrix with numeric values.

y

The numerical variable.

use

What observations to use. See cor function for details. The only option that is not available here is "pairwise.complete.obs".

method

Which method to use for the calculation of the partial correlations. This can be either Pearson's, Spearman's or Kendall's coefficient. See cor for details.

Author

Ivan Svetunkov, ivan@svetunkov.ru

Details

The calculation is done based on multiple linear regressions. The function calculates them for each pair of variables based on the residuals of linear models of those variables from the other variables in the dataset.

See Also

mcor, cramer, association

Examples

Run this code

pcor(mtcars)

Run the code above in your browser using DataLab