wtd.partial.cor {weights}R Documentation

Computes weighted partial correlations, controlling for covariates

Description

wtd.partial.cor estimates the weighted partial correlation between two variables or sets of variables, controlling for additional covariates. This function uses weighted regression to residualize the inputs and computes the correlation of the residuals, providing standard errors and significance tests.

Usage

wtd.partial.cor(x, y = NULL, preds = NULL, weight = NULL, collapse = TRUE)

Arguments

x

A numeric vector or matrix. Each column will be residualized on preds.

y

An optional numeric vector or matrix. If NULL, x is used as both inputs.

preds

Covariates to control for via weighted linear regression.

weight

Optional weights to be applied in the regression and correlation steps.

collapse

Logical. If TRUE, simplifies the output to a matrix when possible.

Value

A list with:

When collapse = TRUE, the result is simplified when possible.

Author(s)

Josh Pasek (https://www.joshpasek.com)

See Also

wtd.partial.cov, wtd.cor, onecor.wtd

Examples

set.seed(456)
x <- rnorm(100)
y <- 0.4 * x + rnorm(100)
z <- rnorm(100)
w <- runif(100, 1, 2)

wtd.partial.cor(x, y, preds = z, weight = w)

[Package weights version 1.1.2 Index]