wtd.cor {weights} | R Documentation |
Produces weighted correlations with standard errors and significance. For a faster version without standard errors and p values, use the wtd.cors
function.
Description
wtd.cor
produces a Pearsons correlation coefficient comparing two variables or matrices. Note that weights run with the default parameters here treat the weights as an estimate of the precision of the information. For survey data, users should run this code with bootstrapped standard errors bootse=TRUE
, which are robust to heteroskadesticity, although these will vary slightly each time the weights are run. A prior version of this software was set to default to mean1=FALSE
and bootse=FALSE
.
Usage
wtd.cor(x, y=NULL, weight=NULL, mean1=TRUE, collapse=TRUE, bootse=FALSE,
bootp=FALSE, bootn=1000)
Arguments
x |
|
y |
|
weight |
|
mean1 |
|
collapse |
|
bootse |
|
bootp |
|
bootn |
|
Value
A list with matrices for the estimated correlation coefficient, the standard error on that correlation coefficient, the t-value for that correlation coefficient, and the p value for the significance of the correlation. If the list can be simplified, simplification will be done.
Author(s)
Josh Pasek, Assistant Professor of Communication Studies at the University of Michigan (www.joshpasek.com).
See Also
wtd.cors
stdz
wtd.t.test
wtd.chi.sq
Examples
test <- c(1,1,1,1,1,1,2,2,2,3,3,3,4,4)
t2 <- rev(test)
weight <- c(.5,.5,.5,.5,.5,1,1,1,1,2,2,2,2,2)
wtd.cor(test, t2)
wtd.cor(test, t2, weight)
wtd.cor(test, t2, weight, bootse=TRUE)