Pcor.prob: A function to calculate the null probability of a Pearson's...

Pcor.probR Documentation

A function to calculate the null probability of a Pearson's partial correlation coefficient.

Description

Given a matrix or data frame of multivariate observations (dat), one enters the column numbers (x, y) of the two variables whose partial correlation is sought and the set of column numbers of the other conditioning variables (Q). The Pearson partial correlation between the variables in columns x and y, conditional on the variables in the columns included in Q, is calculated and the null probability is calculated via a Student's t distribution. The result therefore assumes multivariate normality and linearity between the variables. Thus function, as written, is meant to be called by other functions.

Usage

Pcor.prob(dat, x, y, Q)

Arguments

dat

a matrix or data frame containing the multivariate observations

x

column number of the first variable in the pair

y

column number of the second variable in the pair

Q

a vector of column numbers of the conditioning variables

Details

This function calculates the partial correlation by inverting the covariance matrix constructed

Value

The null probability associated with the Pearson partial correlation

Author(s)

Bill Shipley

Examples

# Partial correlation between variables in columns 1 and 3, 
# conditional on the variables in columns 2 and 5.

set.seed(123)
dat <- gen.data()
Pcor.prob(dat = dat, x = 1, y = 3, Q = c(2, 5))

BillShipley/CauseAndCorrelation documentation built on Jan. 31, 2023, 4:20 a.m.