2

I have a character matrix for some different plant species, in which most species are missing data for at least a few characters. I want to do a principal components analysis, so I tried to impute the missing values, but when I try to do that I get the error message:

Error in eigen(crossprod(X, X), symmetric = TRUE) : infinite or missing values in 'x'

I thought having missing values was kind of the point! Does anyone know what I'm doing wrong?

Joe
  • 8,073
  • 1
  • 52
  • 58
  • How did you impute te missing values? Also provide sample data using `dput(your data)` and sample code. – NelsonGon Dec 13 '18 at 03:43
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. But I don't think PCA can be performed with missing data. You'd have to do the decomposition with complete cases only. – MrFlick Dec 13 '18 at 05:46
  • See this question for useful information on imputation. https://stackoverflow.com/questions/39862778/imputation-with-column-medians-in-r – Joe Dec 13 '18 at 13:34

2 Answers2

3

You should use the function imputePCA available in the package missMDA.

For more information: http://factominer.free.fr/missMDA/index.html

Best

Francois

Husson
  • 141
  • 3
0

I have the same issues when I try to impute dataset digits with missing values. One reason that could lead to the above Error is that you have features with 0 standard deviations (because their values are the same). Check this discussion: https://community.rstudio.com/t/problem-with-missmda/90809/7

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 07 '23 at 20:54