pcor: (Semi-)Partial correlation

View source: R/pcor.R

pcorR Documentation

(Semi-)Partial correlation

Description

Computes the (semi-)partial correlation of x and y, controlling for z.

Usage

pcor(x, y, z, semi = FALSE, use = "complete.obs", method = c("pearson",
  "spearman"))

Arguments

x

a numeric vector.

y

a numeric vector.

z

a numeric vector, matrix, data frame or list giving the controlling variables. For matrices, variables must be placed in columns.

semi

logical. If TRUE the semi-partial correlation coefficient is computed. In that case only y is controlled for z.

use

same as use of cor.

method

same as method of cor.

Author(s)

Maxime HERVE <maxime.herve@univ-rennes1.fr>

See Also

pcor.test for confidence intervals (and tests).

Examples

set.seed(1444)
x <- 1:30
y <- 1:30+rnorm(30,0,2)
z1 <- runif(30,0,4)
z2 <- 30:1+rnorm(30,0,3)
pcor(x,y,z1)
pcor(x,y,list(z1,z2))

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.