Skip to contents

Thin extender over ppcor::pcor (matrix-wise) or ppcor::pcor.test (when y and z are supplied) for partial correlations controlling for one or more variables.

Usage

morie_ppcor_partial(x, y = NULL, z = NULL, method = "pearson", ...)

Arguments

x

Numeric vector, matrix, or data frame. When y and z are NULL, the full pairwise partial correlation matrix is returned via ppcor::pcor.

y

Optional second numeric vector.

z

Optional numeric vector / matrix of control variables.

method

Correlation method ("pearson", "spearman", or "kendall"), forwarded to ppcor.

...

Further arguments forwarded to the upstream function.

Value

A list with $method (qualified upstream name) and $raw (the upstream return object).

Examples

if (requireNamespace("ppcor", quietly = TRUE)) {
  set.seed(1)
  x <- rnorm(40); z <- rnorm(40); y <- x + z + rnorm(40)
  morie_ppcor_partial(x, y, z)
}
#> $method
#> [1] "partial_cor_test (rmorie native)"
#> 
#> $raw
#>    estimate     p.value statistic  n gp  Method
#> 1 0.6045424 4.58353e-05  4.616385 40  1 pearson
#>