[R] Psych package: Error in biplot.psych(sample.mod) : Biplot requires factor/component scores:
Simon Kiss
sjkiss at gmail.com
Wed Jun 26 00:33:48 CEST 2013
Hello: I'm trying to construct a biplot from the psych package. The underlying data frame looks just like sample.data, below. I turned it into a polychoric correlation matrix sample.cor, below, as it is derived from a series of Likert (ordinal) items. All are positive, I just used negative numbers in this dataset to get two separate factors. I created a PCA from sample.cor$rho, specifying that scores were to be kept via scores=TRUE, but the command, biplot.psych(sample.mod) returns the error message: Error in biplot.psych, Biplot requires factor/component scores.
But it seems from the help documentation, that one really only has to use the command biplot(mod) to get the plot.
Can someone please advise?
Yours, Simon Kiss
#Sample data
sample.data<-data.frame(var1=sample(c(0,0.33, 0.66, 1), size=100, replace=TRUE), var2=sample(c(0,0.33, 0.66, 1), size=100, replace=TRUE), var3=sample(c(0,-0.33, -0.66, -1), size=100, replace=TRUE), var4=sample(c(0,-0.33,-0.66,-1), size=100, replace=TRUE))
#Correlation Matrix
sample.cor<-polychoric(sample.data, polycor=TRUE)
#Principal Components Analysis
sample.mod<-principal(sample.cor$rho, nfactors=2,scores=TRUE,covar=TRUE)
#Draw Biplot
biplot.psych(sample.mod)
#error
Error in biplot.psych(sample.mod) :
Biplot requires factor/component scores:
More information about the R-help
mailing list