简体   繁体   English

从R中的因子分析Biplot {psych}中消除箭头

[英]Eliminating arrows from a factor analysis Biplot {psych} in R

In the biplot produced by the following code I am trying to get rid of the red lines. biplot由以下代码制作我试图摆脱红线。 I would appreciate it if anyone could help. 如果有人可以帮助,我将不胜感激。

library(psych)
data(bfi)
fa2 <- fa(bfi[16:25],2)  #factor analysis
fa2$scores <- fa2$scores[1:100,]  #just take the first 100
biplot(fa2,pch=c(24,21)[bfi[1:100,"gender"]],bg=c("blue","red")[bfi[1:100,"gender"]],
main="Biplot of Conscientiousness and Neuroticism by gender")

在此处输入图片说明

For whatever reason, the psych library decided to re-write it's own biplot so it ignores many of the standard parameters. 无论出于何种原因, psych图书馆都决定重写自己的Biplot,因此它忽略了许多标准参数。 You can create your own version and just remove the arrow drawing. 您可以创建自己的版本,只需删除箭头图即可。 This method is somewhat hacky but tested with psych_1.4.5 . 该方法有些hacky,但已使用psych_1.4.5进行了psych_1.4.5 Just verify that 只要验证一下

body(biplot.psych)[[c(11,3,12)]]

returns 回报

arrows(0, 0, x$loadings[, 1L] * 0.8, x$loadings[, 2L] * 0.8, 
    col = col[2L], length = arrow.len)

to make sure we are changing the correct line. 确保我们更改了正确的行。 Then you can do 那你可以做

biplot.psych2<-biplot.psych
body(biplot.psych2)[[11]][[3]][[12]]<-NULL

And then call our new function with 然后使用

biplot.psych2(fa2,pch=c(24,21)[bfi[1:100,"gender"]],
    bg=c("blue","red")[bfi[1:100,"gender"]],
    main="Biplot of Conscientiousness and Neuroticism by gender")

to get 要得到

在此处输入图片说明

Months after you posted your question, here is a quick answer. 发布问题数月后,这里有一个快速解答。 What you are actually asking for is not a biplot (which includes the factor scores as well as the factor loadings), but just a plot of the factor scores. 您实际要求的不是biplot(包括因子得分以及因子负载),而只是因子得分的图。 Using your example, just 用你的例子,

plot(fa2$scores,bg=c("blue","red")[bfi[1:100,"gender"]],pch=c(24,21)[bfi[1:100,"gender"]],ylim=c(-3,3),xlim=c(-3,3)). 情节(FA2 $分数,BG = C( “蓝”, “红”)[BFI [1:100, “性别”]],PCH = C(24,21)[BFI [1:100, “性别”] ],ylim = C(-3,3),XLIM = C(-3,3))。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM