在R(library(polycor)
,函数hetcor
)中计算多重相关时,我收到警告消息In log(P) : NaNs produced
。我无法弄清楚这条警告信息可能构成什么。我认为它与计算用于测试二元正态性的p值有关。
因此我的问题是:
数据子集:
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, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 3L, 1L, 1L,
2L, 3L, 2L, 1L, 2L, 2L, 3L, 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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"))
相关矩阵的计算:
hetcor(foo)
注释:真实数据集包含大约2500行(和更多变量),但在评估列联表时,稀疏矩阵似乎不是问题。
答案 0 :(得分:2)
对一个非常古老的问题的简短(和迟来的)答案。警告是因为变量的交叉列表中的某些单元格(例如,变量1和2)在单元格中具有0值。这可能导致估计问题。
polychoric(和tetrachoric)相关性是正态理论近似,如果将双变量正态(和连续)数据转换为分类(四分法的二分法,多分子的多分子)数据,将会发生什么。正态理论近似假设所有细胞都有一定的价值。但是,可以使用0个单元格值找到相关性,但会显示警告。得到的相关是正确的,但不稳定,因为如果我们为连续性添加一个小的校正(即,将0或.5添加到0个单元格),则值会发生很大变化。 Gunther和Hofler针对四重相关的情况讨论了这个问题,他们将解决方案与连续性校正进行比较。
(参见A. Gunther和M. Hofler撰写的文章。关于mplus和stata-stata中四分相关的不同结果宣布修改过程.Int J Methods Psychiatr Res,15(3):157-66,2006。用tetrachoric相关性讨论这个问题。)
使用心理包中的polychoric函数,我们找到与polycor的hetcor函数相同的答案,如果我们不对连续性应用校正,但如果我们确定连续性,则会有一些不同的值。我建议修正。
有关此问题的详细讨论,请参阅心理学中的多语言帮助函数。