corcov: Covariance and correlation

Description Usage Arguments Value Author(s) See Also Examples

Description

These functions offer an interface to compute arbitrary order partial (or semi-partial) variance-covariance or correlation matrices as well as partial cross variance-covariances or correlations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
cor(X)

cov(X, method = c("Unbiased", "ML"))

pcor(X, z)

pcov(X, z)

pxcor(X, Y, Z)

pxcov(X, Y, Z, method = c("Unbiased", "ML"))

xcor(X, Y)

xcov(X, Y, method = c("Unbiased", "ML"))

Arguments

X

A numeric matrix with observations in rows and variables in columns.

method

A character of length 1. The unbiased estimate divided with n-1 and whereas ML uses n.

z

A integer vector of indices to condition on.

Y

A numeric matrix with the same number of rows as X.

Z

A numeric matrix with the same number of rows as X. This is the matrix of variables to condition on.

Value

All functions return a matrix of correlations or covariances.

Author(s)

Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>

See Also

corFamily (the internal workhorse functions)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
n <- 11
X <- createData(n, 4)
Y <- createData(n, 2)
Z <- createData(n, 9)

cor(X)
cov(X, method = "ML")
cov(X, method = "Unbiased")

xcov(X, Y)
xcor(X, Y)

pcov(X, z = numeric(0)) 
pcov(X, z = 1:2)
pcor(X, z = numeric(0))
pcor(X, z = 3)

pxcov(X, Y, Z)
pxcor(X, Y, Z)

AEBilgrau/correlateR documentation built on Nov. 15, 2019, 9:21 a.m.