Computes a heterogenous correlation matrix, consisting of Pearson productmoment correlations between numeric variables, polyserial correlations between numeric and ordinal variables, and polychoric correlations between ordinal variables.
1 2 3 4 5 6 7 8 9 10  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, ...)

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 
std.err 
if 
bins 
number of bins to use for continuous variables in testing bivariate normality; the default is 4. 
pd 
if 
use 
if 
x 
an object of class 
digits 
number of significant digits. 
Returns an object of class "hetcor"
with the following components:
correlations 
the correlation matrix. 
type 
the type of each correlation: 
std.errors 
the standard errors of the correlations, if requested. 
n 
the number (or numbers) of observations on which the correlations are based. 
tests 
pvalues for tests of bivariate normality for each pair of variables. 
NA.method 
the method by which any missing data were handled: 
ML 

Although the function reports standard errors for productmoment correlations, transformations (the most well known is Fisher's ztransformation) are available that make the approach to asymptotic normality much more rapid.
John Fox jfox@mcmaster.ca
Drasgow, F. (1986) Polychoric and polyserial correlations. Pp. 6874 in S. Kotz and N. Johnson, eds., The Encyclopedia of Statistics, Volume 7. Wiley.
Olsson, U. (1979) Maximum likelihood estimation of the polychoric correlation coefficient. Psychometrika 44, 443460.
Rodriguez, R.N. (1982) Correlation. Pp. 193204 in S. Kotz and N. Johnson, eds., The Encyclopedia of Statistics, Volume 2. Wiley.
Ghosh, B.K. (1966) Asymptotic expansion for the moments of the distribution of correlation coefficient. Biometrika 53, 258262.
Olkin, I., and Pratt, J.W. (1958) Unbiased estimation of certain correlation coefficients. Annals of Mathematical Statistics 29, 201211.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  if(require(mvtnorm)){
set.seed(12345)
R < matrix(0, 4, 4)
R[upper.tri(R)] < runif(6)
diag(R) < 1
R < cov2cor(t(R) %*% R)
round(R, 4) # population correlations
data < rmvnorm(1000, rep(0, 4), R)
round(cor(data), 4) # sample correlations
}
if(require(mvtnorm)){
x1 < data[,1]
x2 < data[,2]
y1 < cut(data[,3], c(Inf, .75, Inf))
y2 < cut(data[,4], c(Inf, 1, .5, 1.5, Inf))
data < data.frame(x1, x2, y1, y2)
hetcor(data) # Pearson, polychoric, and polyserial correlations, 2step est.
}
if(require(mvtnorm)){
hetcor(x1, x2, y1, y2, ML=TRUE) # Pearson, polychoric, polyserial correlations, ML est.
}

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.