0

I performed a PCA using the library psych, and I selected 9 axis (eigenvalue > 1). But I cannot find a way to plot it. Do you know how can I do it?

Thank you

Fran
  • 1
  • 2
  • 2
    Hi, have you tried to use `plot(yourpsychobject)`? In addition, could you please have a look here: https://stackoverflow.com/q/5963269/10264278, a reproducible example is very useful to get more relevant answers. – Paul Feb 15 '22 at 09:11
  • What is the code you performed ? Depending on your object you might be able to retrieve coordinates of individuals for each principal component, etc and then this should be easy to plot – Basti Feb 15 '22 at 09:14
  • My code is: pca <- principal(df, nfactor=20, residuals=T, n.obs=520, covar = TRUE , rotate ="none") If I do plot(pca) I have all the variabòes considered, but I just want to plot the resulting axes – Fran Feb 15 '22 at 09:20
  • Could you share an exemple of your dataset by editing your post ? If you put the output of `dput(df)`it will help us to provide you the best answer – Basti Feb 15 '22 at 09:30
  • It is very big the output of dput(df). I don't know if this could help, but I have a huge dataset with my samples and all the variables (location, date ecc.) . Some of these variables are the number of reads of each taxa identified in my samples. So in df I selected only these latter columns and then I performed the pca – Fran Feb 15 '22 at 09:38
  • You could use a sample of your data (see `head()`) or a dummy dataset (maybe the `psych` library has some build-in dummy datasets). – Paul Feb 15 '22 at 09:57
  • Looking at `?psych::principal`, the object produced by this function can be used with `base::biplot()` function. See `biplot(psych::principal(psych::Harman.5, 2, rotate = "varimax"))`. – Paul Feb 15 '22 at 10:11
  • As a plot is inherently 2D, you cannot directly plot 9D data. If you select the *two* largest eigenvectors for PCA, you can project on the corresponding eigenvectors and plot the projected data. This is done automatically by `cmdscale`. – cdalitz Feb 15 '22 at 12:54
  • 1
    You can plot 9D as 36 separate 2D plots (axis 1 with 2, axis 1 with 3, ... axis 8 with 9), but it will be very difficult to interpret the results. – dcarlson Feb 15 '22 at 16:20
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 19 '22 at 13:49

0 Answers0