Skip to contents

The correlation between \(x_i\) and \(x_j\) with the other variables partialled out of \(x_j\) only: \(-P_{ij} / (\sqrt{P_{ii}}\, \sqrt{P_{jj} - P_{ij}^2 / P_{ii}})\). Reproduces ppcor::spcor.

Usage

morie_semipartial_cor(data, method = "pearson")

Arguments

data

Numeric matrix or data frame (columns = variables).

method

Correlation method: "pearson" (default), "spearman", or "kendall".

Value

A list mirroring morie_partial_cor with the semi-partial coefficients in estimate.

Examples

morie_semipartial_cor(mtcars[, c("mpg", "wt", "disp")])$estimate
#>             mpg         wt       disp
#> mpg   1.0000000 -0.2501744 -0.1676239
#> wt   -0.2167851  1.0000000  0.2875263
#> disp -0.1550555  0.3069319  1.0000000