简体   繁体   中英

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. 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. You can create your own version and just remove the arrow drawing. This method is somewhat hacky but tested with 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. 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)).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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