problem with missMDA

Hello, I have a problem when I want to apply the missMDA on my data
here is the script

require(missMDA)
nb <- estim_ncpPCA(BD_donnees,ncp.min=0,ncp.max=5,method.cv="Kfold",nbsim=50)
imputed<- imputePCA(BD_donnees,ncp=nb$ncp)

and the error message

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

Thank you in advance for your help

Hi @khadim,
Welcome to the RStudio Community Forum.

In order to help with your issue we need to see the contents of your R object BD_donnees. Can you post a subset of the data that can be used in a Reproducible Example (see the posting guide to help with this)?

Is the error occurring on line 2 or line 3 of the code shown above?
HTH

2

and here is an image that shows the error

A screenshot of the data is not really useful. have a look at:

I send you the complete database that I use these data are just used in the academic context
Please click on this link to download the database

Here is the minimum reproducible code

BD_donnees<-read.csv(file='D:/donnees.csv', header = TRUE, sep = ";",
         dec = ",",row.names = 1)
require(missMDA)
nb <- estim_ncpPCA(BD_donnees,ncp.min=0,ncp.max=5,method.cv="Kfold",nbsim=50)
imputed<- imputePCA(BD_donnees,ncp=nb$ncp)

Thank you in advance

Hi @khadim,
Thanks for the data file - now we can fix the problem!
One column in the data frame has only integer 0 values with very many NAs. The help says that all variables must be "continuous".
So, if we remove that column, we get the code to run:

BD_donnees <- read.csv(file='c:/users/xxxxxx/downloads/donnees.csv', header = TRUE, sep = ";", 
                       dec = ",", row.names = 1)

str(BD_donnees)
names(BD_donnees)

temp.df <- BD_donnees[, -6]  # Remove problematic column

library(missMDA)
nb <- estim_ncpPCA(temp.df, ncp.min=0, ncp.max=5, method.cv="Kfold", nbsim=50)
imputed <- imputePCA(temp.df, ncp=nb$ncp)

HTH

2 Likes

Thank you very much you saved me

Hello. I still have a problem with a script but this time it's not with missMDA.
i know i need to do a new post. this is what I had done since yesterday but the algorithm has hidden the post or I must return the job soon.
in short
my problem is that when I run the ACP script an error message appears and I don't know why
here are the codes used

library(knitr)
BD_donnees<-read.csv("D:/donnees.csv",header =TRUE,sep =";",dec =".",row.names=1.)
colnames(BD_donnees)<-c("PE","IE","ER","CEAS","CEA","CET","CEI","CES","ERP","ERA","AT")
kable(head(BD_donnees,n=54L),caption = "Tableau des données")
## CHARGEMENT DES PACKAGE
library(FactoMineR)
library(missMDA)
library(FactoInvestigate)
library(Factoshiny)

# ABREVIATION DES VARIABLES
colnames(BD_donnees)<-c("PE","IE","ER","CEAS","CEA","CET","CEI","CES","ERP","ERA","AT")


# PRESENTATION DES DONNEES

## Tableau
head(BD_donnees)

##Tableau des données statistiques 
summary(BD_donnees)

# REALISATION DE L'ACP
## Completer les données manquantes
comp <- imputePCA(BD_donnees)

##ACP
e=c(1,2,3,4,5,6,7,8,9,10,11)
acp_BD_donnees<-PCA(comp$completeObs,quanti.sup =e)

## PRESENTATION DES RESULTATS DE L'ACP

## Valeurs propres
acp_BD_donnees$eig

## Coordonnées des individus
acp_BD_donnees$ind$coord

## Cosinus carrés des individus
acp_BD_donnees$ind$cos2

## Contribution
acp_BD_donnees$ind$contrib

#ACP AVEC PCAShiny
PCAshiny(acp_BD_donnees)

#GENERER LE RAPPORT AVEC FACTOINVESTIGATE
Investigate(acp_BD_donnees, file = "PCA.Rmd", document = "word_document", time = "1000L", parallel = FALSE)

Please click on this link to download the database

Thanks for your understanding

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.