Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pcor

Partial correlation


Description

Computes the partial correlation between two variables given a set of other variables.

Usage

pcor(u, S)

Arguments

u

a vector of integers of length > 1. The first two integers are the indices of variables the correlation of which must be computed. The rest of the vector is the conditioning set.

S

a symmetric positive definite matrix, a sample covariance matrix.

Value

a scalar, the partial correlation matrix between variables u[1] and u[2] given u[-c(1,2)].

Author(s)

Giovanni M. Marchetti

See Also

Examples

data(marks)
## The correlation between vectors and algebra given analysis and statistics
 pcor(c("vectors", "algebra", "analysis", "statistics"), var(marks))
## The same
pcor(c(2,3,4,5), var(marks))
## The correlation between vectors and algebra given statistics
 pcor(c("vectors", "algebra", "statistics"), var(marks))
## The marginal correlation between analysis and statistics 
pcor(c("analysis","statistics"), var(marks))

ggm

Graphical Markov Models with Mixed Graphs

v2.5
GPL-2
Authors
Giovanni M. Marchetti, Mathias Drton, Kayvan Sadeghi
Initial release
2020-02-014

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.