【问题标题】:R psych package - Sort correlation matrix after PCA using mat.sort()R psych 包 - 在 PCA 之后使用 mat.sort() 对相关矩阵进行排序
【发布时间】:2014-04-07 23:48:08
【问题描述】:

在主成分分析之后,我试图让我的原始相关矩阵的变量以与(排序的)载荷矩阵相同的方式排序(如 print.psych 所示)。我使用了 psych 包中的以下函数,但我无法让两者对齐。

pc <- principal(myCorrMatrix$correlations, nfactors=15, n.obs=49, rotate="oblimin")
print.psych(pc, cut=0.3, sort=TRUE)

sortedPC <- fa.sort(pc)
sortedMatrix <- mat.sort(myCorrMatrix$correlations, sortedPC)

我不是 100% 确定 mat.sort 的第二个参数应该是什么,但我尝试了 sortedPC 的几个元素都无济于事。任何指针将不胜感激!

【问题讨论】:

  • 最好是 dputmyCorrMatrix$correlations,因为您使用的所有命令都特定于 psych 包。见:stackoverflow.com/questions/5963269/…
  • @rmk:我知道这会让事情变得更容易,但我不想分享数据......

标签: r sorting matrix principal psych


【解决方案1】:

不要将fa.sort() 传递给mat.sort()mat.sort() 需要一个 fa 对象,其中包含 $loadings。请注意,principal() 还会在结果对象中提供 $loadings。我认为这应该可行:

sortedMatrix <- mat.sort(myCorrMatrix$correlations, pc)

这是一个例子:

data(Bechtoldt.1)
sorted <- mat.sort(Bechtoldt.1,principal(Bechtoldt.1,5))
cor.plot(sorted)

【讨论】:

    猜你喜欢
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 2018-03-15
    • 2017-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多