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

pcor

Partial correlation


Description

Partial correlation between two continuous variables when a correlation matrix is given.

Usage

pcor(R, indx, indy, indz, n)

Arguments

R

A correlation matrix.

indx

The index of the first variable whose conditional correlation is to estimated.

indy

The index of the second variable whose conditional correlation is to estimated.

indz

The index of the conditioning variables.

n

The sample size of the data from which the correlation matrix was computed.

Details

Given a correlation matrix the function will caclulate the partial correlation between variables indx and indy conditioning on variable(s) indz and will return the logarithm of the p-value.

Value

A numeric vector containing the partial correlation and logged p-value for the test of no partial correlation.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

See Also

Examples

y <- as.matrix( iris[, 1:2] )
z <- cbind(1, iris[, 3] )
er <- resid( .lm.fit(z, y) )
r <- cor(er)[1, 2]
z <- 0.5 * log( (1 + r) / (1 - r) ) * sqrt( 150 - 1 - 3 )
log(2) + pt( abs(z), 150 - 1 - 3, lower.tail = FALSE, log.p = TRUE )
r <- cor(iris[, 1:3])
pcor(r, 1,2, 3, 150)

pchc

Bayesian Network Learning with the PCHC and Related Algorithms

v0.5
GPL (>= 2)
Authors
Michail Tsagris [aut, cre]
Initial release
2021-03-21

We don't support your browser anymore

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