2

When calculating a polychoric correlation in R (library(polycor), function hetcor) I get the warning message In log(P) : NaNs produced. I wasn't able to figure out what this warning message might constitute. I suppose it has to do with the calculation of the p-values for testing bivariate normality.

Thus my questions are:

  • What characteristics of this dataset result in this warning?
  • What's the meaning of this warning?
  • Is this warning problematic in terms of using the polychoric correlation matrix for further analyses?

Data subset:

foo <- structure(list(item1 = structure(c(4L, 4L, 4L, 2L, 2L, 2L, 
2L, 2L, 4L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 1L, 
2L, 2L, 3L, 3L, 3L, 2L, 2L, 1L, 1L, 2L, 3L, 2L, 2L, 3L, 2L, 3L, 
2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 
1L, 2L, 2L, 4L, 2L, 4L, 2L, 2L, 3L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 
2L, 2L, 3L, 2L, 2L, 2L, 3L, 1L, 2L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 
2L, 2L, 2L, 4L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 3L, 3L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 3L
), .Label = c("0", "1", "2", "3"), class = c("ordered", "factor"
)), item2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 
1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 3L, 2L, 1L, 3L, 2L, 1L, 1L, 3L, 
1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 3L, 2L, 2L, 1L, 
3L, 2L, 1L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L, 3L, 1L, 2L, 2L, 1L, 3L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 
1L, 2L, 4L, 2L, 2L, 1L, 2L, 2L, 4L, 2L, 4L, 1L, 1L, 2L, 1L, 1L, 
1L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 1L, 3L, 2L, 1L, 1L, 3L, 3L, 
1L, 4L, 1L, 1L, 1L, 1L, 2L, 3L, 3L, 3L, 2L, 1L, 3L, 2L, 1L, 1L, 
1L, 1L, 2L, 3L, 4L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 3L, 1L, 
3L, 3L, 4L, 3L, 3L), .Label = c("0", "1", "2", "3"), class = c("ordered", 
"factor"))), .Names = c("item1", "item2", "item3", "item4", 
"item5"))

Computation of correlation matrix:

hetcor(foo)

Comment: the real dataset contains about 2500 rows (and more variables), but when evaluating the contingency tables a sparse matrix doesn't seem to be an issue.

4

1 回答 1

3

对一个非常古老的问题的简短(和迟到的)答案。该警告是因为变量交叉表中的某些单元格(例如,变量 1 和 2)在单元格中具有 0 值。这可能会导致估计问题。

如果将双变量正态(和连续)数据转换为分类(四分体为二分法,多分体为多分体)数据,多组(和四组)相关性是正常理论近似值。正态理论近似假设所有细胞都有一些价值。但是,可以使用 0 个单元格值找到相关性,但带有警告。得到的相关性是正确的,但不稳定,因为如果我们为连续性添加一个小的修正(即,将 0 单元格添加 0.1 或 0.5),值会发生很大变化。Gunther 和 Hofler 讨论了这个问题,用于四色相关的情况,他们将解决方案与连续性校正进行比较。

(参见 A. Gunther 和 M. Hofler 的文章。关于 mplus 和 stata-stata 中 tetrachorical 相关性的不同结果宣布修改程序。Int J Methods Psychiatr Res, 15(3):157-66, 2006. 对此进行讨论四色相关性的问题。)

使用 psych 包中的 polychoric 函数,如果我们不应用连续性校正,我们会找到与 polycor 中的 hetcor 函数相同的答案,但如果我们对连续性进行校正,则值会有所不同。我建议更正。

有关此问题的更详细讨论,请参阅心理中的 polychoric 的帮助功能。

于 2016-07-31T17:37:33.570 回答