Computes a heterogenous correlation matrix, consisting of Pearson product-moment
correlations between numeric variables, polyserial correlations between numeric
and ordinal variables, and polychoric correlations between ordinal variables.
Usage
hetcor(data, ..., ML = FALSE, std.err = TRUE, bins=4, pd=TRUE)
## S3 method for class 'data.frame'
hetcor(data, ML = FALSE, std.err = TRUE,
use = c("complete.obs", "pairwise.complete.obs"), bins=4, pd=TRUE, ...)
## Default S3 method:
hetcor(data, ..., ML = FALSE, std.err = TRUE, bins=4, pd=TRUE)
## S3 method for class 'hetcor'
print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'hetcor'
as.matrix(x, ...)
Arguments
data
a data frame consisting of factors, ordered factors, logical variables,
and/or numeric variables, or the first of several variables.
...
variables and/or arguments to be passed down.
ML
if TRUE, compute maximum-likelihood estimates;
if FALSE, compute quick two-step estimates.
std.err
if TRUE, compute standard errors.
bins
number of bins to use for continuous variables in testing bivariate normality; the default is 4.
pd
if TRUE and if the correlation matrix is not positive-definite,
an attempt will be made to adjust it to a
positive-definite matrix, using the nearcor function in the sfsmisc package.
Note that default arguments to nearcor are used; for more control call nearcor directly.
use
if "complete.obs", remove observations with any missing data;
if "pairwise.complete.obs", compute each correlation using all observations with
valid data for that pair of variables.
x
an object of class "hetcor" to be printed, or from which to extract the correlation matrix.
digits
number of significant digits.
Value
Returns an object of class "hetcor" with the following components:
correlations
the correlation matrix.
type
the type of each correlation: "Pearson", "Polychoric", or "Polyserial".
std.errors
the standard errors of the correlations, if requested.
n
the number (or numbers) of observations on which the correlations are based.
tests
p-values for tests of bivariate normality for each pair of variables.
NA.method
the method by which any missing data were handled: "complete.obs"
or "pairwise.complete.obs".
ML
TRUE for ML estimates, FALSE for two-step estimates.
Note
Although the function reports standard errors for product-moment correlations, transformations (the most well known
is Fisher's z-transformation) are available that make the approach to asymptotic normality much more rapid.