Description Usage Arguments Details Value Examples
Computes a weighted heterogeneous correlation matrix, consisting of Pearson product-moment correlations between numeric variables, polyserial correlations between numeric and ordinal variables, and polychoric correlations between ordinal variables.
1 2 3 4 5 6 |
dataFrame |
a data.frame containing all variables |
vars |
character or numeric vector indicating the variables for which a correlation table should
be computed. If |
weights |
Numeric vector of non-negative weights. If |
out |
Specifies the output format. |
Variables in the data.frame should be accordingly classified as numeric or factor variables.
Function resembles the hetcor
function from the polycor
package, but allows
for incorporating weights. For this purpose, the function makes use of the weightedCorr
function from the wCorr
package.
a correlation table or a list
1 2 3 4 5 6 7 8 9 10 11 | data(mtcars)
# create arbitrary weights
mtcars[,"weight"] <- abs(rnorm(nrow(mtcars), 10,5))
# choose variables
vars <- c("mpg", "cyl", "hp")
# inappropriate classes: variables which are inherently ordinal, have the 'wrong'
# class 'numeric'. (We use only the first imputation of the data set.)
sapply(mtcars[,vars], class)
mtcars[,"cyl"] <- as.factor(mtcars[,"cyl"])
wtdHetcor(mtcars, vars = vars, out = "long")
wtdHetcor(mtcars, vars = vars, weights = "weight", out = "long")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.