wt_cov {configural} R Documentation

## Compute weighted covariances

### Description

Compute the weighted covariance among variables in a matrix or between the variables in two separate matrices/vectors.

### Usage

wt_cov(
x,
y = NULL,
wt = NULL,
as_cor = FALSE,
use = c("everything", "listwise", "pairwise"),
unbiased = TRUE,
df_type = c("count", "sum_wts")
)

wt_cor(x, y = NULL, wt = NULL, use = "everything")


### Arguments

 x Vector or matrix of x variables. y Vector or matrix of y variables wt Vector of weights as_cor Logical scalar that determines whether the covariances should be standardized (TRUE) or unstandardized (FALSE). use Method for handling missing values. "everything" uses all values and does not account for missingness, "listwise" uses only complete cases, and "pairwise" uses pairwise deletion. unbiased Logical scalar determining whether variance should be unbiased (TRUE) or maximum-likelihood (FALSE). df_type Character scalar determining whether the degrees of freedom for unbiased estimates should be based on numbers of cases (n - 1; "count"; default) or squared sums of weights (1 - sum(w^2); "sum_wts").

### Value

Scalar, vector, or matrix of covariances.

### Author(s)

Jeffrey A. Dahlke

### Examples

wt_cov(x = c(1, 0, 2), y = c(1, 2, 3), wt = c(1, 2, 2), as_cor = FALSE, use = "everything")
wt_cov(x = c(1, 0, 2), y = c(1, 2, 3), wt = c(1, 2, 2), as_cor = TRUE, use = "everything")
wt_cov(x = cbind(c(1, 0, 2), c(1, 2, 3)), wt = c(1, 2, 2), as_cor = FALSE, use = "everything")
wt_cov(x = cbind(c(1, 0, 2), c(1, 2, 3)), wt = c(1, 2, 2), as_cor = TRUE, use = "everything")
wt_cov(x = cbind(c(1, 0, 2, NA), c(1, 2, 3, 3)),
wt = c(1, 2, 2, 1), as_cor = FALSE, use = "listwise")
wt_cov(x = cbind(c(1, 0, 2, NA), c(1, 2, 3, 3)),
wt = c(1, 2, 2, 1), as_cor = TRUE, use = "listwise")


[Package configural version 0.1.5 Index]