pcor: Partial correlation

Description Usage Arguments Value Author(s) See Also Examples

Description

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

Usage

1
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

cor, parcor, correlations

Examples

1
2
3
4
5
6
7
8
9
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))

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union


Attaching package: 'ggm'

The following object is masked from 'package:igraph':

    pa

[1] 0.388203
[1] 0.388203
[1] 0.4753595
[1] 0.6071743

ggm documentation built on March 26, 2020, 7:49 p.m.

Related to pcor in ggm...