tetcor {fungible} | R Documentation |
Compute ML Tetrachoric Correlations
Description
Compute ML tetrachoric correlations with optional bias correction and smoothing.
Usage
tetcor(
X,
y = NULL,
BiasCorrect = TRUE,
stderror = FALSE,
Smooth = TRUE,
max.iter = 5000,
PRINT = TRUE
)
Arguments
X |
Either a matrix or vector of (0/1) binary data. |
y |
An optional(if X is a matrix) vector of (0/1) binary data. |
BiasCorrect |
A logical that determines whether bias correction (Brown & Benedetti, 1977) is performed. Default = TRUE. |
stderror |
A logical that determines whether standard errors are calulated. Default = FALSE. |
Smooth |
A logical which determines whether the tetrachoric correlation matrix should be smoothed. A smoothed matrix is always positive definite. |
max.iter |
Maximum number of iterations. Default = 50. |
PRINT |
A logical that determines whether to print progress updates during calculations. Default = TRUE |
Value
If stderror = FALSE, tetcor
returns a matrix of tetrachoric
correlations. If stderror
= TRUE then tetcor
returns a list
the first component of which is a matrix of tetrachoric correlations and the
second component is a matrix of standard errors (see Hamdan, 1970).
r |
The tetrachoric correlation matrix |
.
se |
A matrix of standard errors. |
convergence |
(logical) The convergence status of the algorithm. A value of TRUE denotes that the algorithm converged. A value of FALSE denotes that the algorithm did not converge and the returned correlations are Pearson product moments. |
Warnings |
A list of warnings. |
Author(s)
Niels Waller
References
Brown, M. B. & Benedetti, J. K. (1977). On the mean and variance of the tetrachoric correlation coefficient. Psychometrika, 42, 347–355.
Divgi, D. R. (1979) Calculation of the tetrachoric correlation coefficient. Psychometrika, 44, 169-172.
Hamdan, M. A. (1970). The equivalence of tetrachoric and maximum likelihood estimates of rho in 2 by 2 tables. Biometrika, 57, 212-215.
Examples
## generate bivariate normal data
library(MASS)
set.seed(123)
rho <- .85
xy <- mvrnorm(100000, mu = c(0,0), Sigma = matrix(c(1, rho, rho, 1), ncol = 2))
# dichotomize at difficulty values
p1 <- .7
p2 <- .1
xy[,1] <- xy[,1] < qnorm(p1)
xy[,2] <- xy[,2] < qnorm(p2)
print( apply(xy,2,mean), digits = 2)
#[1] 0.700 0.099
tetcor(X = xy, BiasCorrect = TRUE,
stderror = TRUE, Smooth = TRUE, max.iter = 5000)
# $r
# [,1] [,2]
# [1,] 1.0000000 0.8552535
# [2,] 0.8552535 1.0000000
#
# $se
# [,1] [,2]
# [1,] NA 0.01458171
# [2,] 0.01458171 NA
#
# $Warnings
# list()