wtd.cov {weights} | R Documentation |
Produces weighted covariances with standard errors and significance.
Description
wtd.cov
produces a covariance matrix comparing two variables or matrices, using a set of weights. Standard errors, t-values, and p-values are estimated via a regression-based approach. If no weights are provided, unweighted covariance is returned.
Usage
wtd.cov(x, y=NULL, weight=NULL, collapse=TRUE)
Arguments
x |
A matrix or vector of values to be compared. If |
y |
A vector or matrix to be compared with |
weight |
Optional weights used to compute the weighted covariance. If |
collapse |
Logical indicator for whether the results should be simplified when the output is a vector. |
Value
A list containing:
covariance
— Weighted covariance matrixstd.err
— Standard error of the covariance estimatet.value
— T-statistic associated with the covariancep.value
— P-value for the t-statistic
If the results are scalar or one-dimensional, a simplified matrix will be returned.
Author(s)
Josh Pasek, Professor of Communication & Media and Political Science at the University of Michigan (https://www.joshpasek.com)
See Also
wtd.cor
, wtd.partial.cov
, onecor.wtd
, wtd.var
, stdz
Examples
x <- c(1, 2, 3, 4)
y <- c(2, 4, 6, 8)
w <- c(1, 2, 1, 1)
wtd.cov(x, y)
wtd.cov(x, y, weight = w)