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 |
y |
An optional numeric vector or matrix. If |
preds |
Covariates to control for via weighted linear regression. |
weight |
Optional weights to be applied in the regression and correlation steps. |
collapse |
Logical. If |
Value
A list with:
correlation
— Estimated partial correlationsstd.err
— Standard errorst.value
— T-statisticsp.value
— P-values
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)