pcor function

Partial correlations

Partial correlations

Function calculates partial correlations between the provided variables

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

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.

Returns

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.

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.

Examples

pcor(mtcars)

See Also

mcor, cramer, association

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

  • Maintainer: Ivan Svetunkov
  • License: LGPL-2.1
  • Last published: 2025-04-04