[R] Psych package: Error in biplot.psych(sample.mod) : Biplot requires factor/component scores:
peter dalgaard
pdalgd at gmail.com
Wed Jun 26 11:23:34 CEST 2013
On Jun 26, 2013, at 00:33 , Simon Kiss wrote:
> 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
I'm not familiar with the psych package, but biplots can't generally be constructed from an analysis that is based on the correlation matrix alone (as opposed to using the original data). I would expect that the scores=TRUE has no effect since principal() is given no access to the original data.
It is not clear to me how to compute individual scores in a PCA based on polychoric correlations. (Someone might have figured out a way, but it is non-obvious.)
> #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:
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list