tetcor: Compute ML Tetrachoric Correlations

Description Usage Arguments Value Author(s) References Examples

Description

Compute ML tetrachoric correlations with optional bias correction and smoothing.

Usage

1
2
3
4
5
6
7
8
9
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## 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()

fungible documentation built on Sept. 29, 2021, 1:06 a.m.

Related to tetcor in fungible...