【问题标题】:Constructing scores from principal loadings in R从 R 中的主要载荷构建分数
【发布时间】:2015-06-25 22:15:52
【问题描述】:

我想了解 psych 包中的 principal() 函数是如何计算 $score 元素的。

我想试试协方差矩阵而不是相关矩阵。

model <- principal(mtcars[8:11],nfactors=4, rotate='none', scores=T, cov=T)

基本上,PCA的分数应该是原始中心数据的线性组合,使用加载矩阵作为权重,所以我尝试了:

test <- scale(mtcars[8:11], center=T, scale=F) %*% model$loadings / model$scores

我了解principal() 函数对负载使用某种缩放比例,但是,每列的比例仍应相同,test 的情况并非如此。

如果我使用相关矩阵,这将不是问题。例如:

model <- principal(mtcars[8:11],nfactors=4, rotate='none', scores=T, cov=F)
test <- scale(mtcars[8:11], center=T, scale=T) %*% model$loadings / model$scores

帮助文档使用了因子分析的术语,这让我更加困惑。希望有人可以在这里启发我。

提前谢谢你!

【问题讨论】:

    标签: r pca principal psych


    【解决方案1】:

    您在psych 包中发现了一个错误。未标准化(协方差)解决方案的分数被发现不正确。这将在下一个版本中修复(至少一个月不会发布)。在此期间,您可以使用负载矩阵和(居中的)原始数据手动查找分数。

    model <- principal(mtcars[8:11],nfactors=4, rotate='none', scores=T, cov=T)
    L <- model$loadings            # Just get the loadings matrix
    S <- model$scores              # This gives an incorrect answer in the current version
    
    d <- mtcars[8:11]              # get your data
    dc <- scale(d,scale=FALSE)     # center the data but do not standardize it
    sc <- dc %*% L                 # scores are the centered data times the loadings
    lowerCor(sc)                   #These scores, being principal components
                                   # should be orthogonal 
        PC1 PC2 PC3 PC4
    PC1 1              
    PC2 0   1          
    PC3 0   0   1      
    PC4 0   0   0   1  
    

    当您发现psych 的问题在此未得到解答时,写信给我(包开发人员)很有用。

    请注意,对于未旋转的解决方案,组件载荷也是正交的(应该是正交的)。

    factor.congruence(L,L)
        PC1 PC2 PC3 PC4
    PC1   1   0   0   0
    PC2   0   1   0   0
    PC3   0   0   1   0
    PC4   0   0   0   1 
    

    (Burt 的因子同余度量,也称为 Tucker 系数,取(未居中的)载荷的内积,然后除以各列的平方和)。您还可以找到 Loadings 的叉积

    round( t(L) %*% L,3)
          PC1   PC2   PC3   PC4
    PC1 2.742 0.000 0.000 0.000
    PC2 0.000 0.721 0.000 0.000
    PC3 0.000 0.000 0.142 0.000
    PC4 0.000 0.000 0.000 0.051
    

    【讨论】:

      猜你喜欢
      • 2015-09-11
      • 2013-05-28
      • 1970-01-01
      • 2021-09-19
      • 2015-07-28
      • 2018-12-17
      • 2020-08-19
      • 1970-01-01
      • 2011-09-23
      相关资源
      最近更新 更多