cor_auto giving different results for missing = 'listwise' vs 'pairwise' for correlation with two variables

huangapple go评论65阅读模式
英文:

cor_auto giving different results for missing = 'listwise' vs 'pairwise' for correlation with two variables

问题

When calculating a polychoric correlation between two variables with missing values, cor_automissing参数设置为 'listwise' 与 'pairwise' 时提供不同的输出,例如:

library(qgraph)
set.seed(5)
df<-data.frame(lapply(1:2,function(x)sample(1:6,100,replace = T)),
stringsAsFactors = F)
colnames(df)=c("a", "b")

# make some missing values
df[10:20,2]<-NA

# these are different
cor_auto(df[,c("a", "b")], missing = "listwise")
cor_auto(df[,c("a", "b")], missing = "pairwise")

我期望当只包括两个变量时(只包括两个变量都非缺失的情况),这两者应该产生相同的输出。有人知道这种差异是如何产生的吗?

英文:

When calculating a polychoric correlation between two variables with missing values, cor_auto is providing different outputs with the missing argument set to 'listwise' compared to 'pairwise', for example:

library(qgraph)
set.seed(5)
df&lt;-data.frame(lapply(1:2,function(x)sample(1:6,100,replace = T)),
stringsAsFactors = F)
colnames(df)=c(&quot;a&quot;, &quot;b&quot;)

# make some missing values
df[10:20,2]&lt;-NA

# these are different
cor_auto(df[,c(&quot;a&quot;, &quot;b&quot;)], missing = &quot;listwise&quot;)
cor_auto(df[,c(&quot;a&quot;, &quot;b&quot;)], missing = &quot;pairwise&quot;)

I expected that these should result in the same output when only two variables are included (only cases with both variables non-missing included). Does anyone know how this difference comes about?

答案1

得分: 1

以下是翻译好的部分:

这里的基础功能是 lavaan::lavCor,除了众多项的多项式相关性估计外,它还估计了阈值。通过设置 missing = "listwise",变量 a 的阈值仅使用具有完整数据的行来估计,因此与使用 missing = "pairwise" 估计的阈值不同。这导致了不一致性。

英文:

The underlying function here is lavaan::lavCor which also estimates thresholds in addition to the polychoric correlation. By setting missing = &quot;listwise&quot;, the thresholds of variable a are estimated using only the rows that have complete data, and so are different than the thresholds estimated with missing = &quot;pairwise&quot;. This leads to the discrepancy.

huangapple
  • 本文由 发表于 2023年5月10日 22:11:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76219452.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定