The video walks through a practical R workflow for performing Principal Component Analysis (PCA) on a dataset that contains missing values. Using the Orange dataset (8 continuous variables, 12 individuals), the speaker first demonstrates the default behavior of FactoMineR, which replaces missing entries with variable means before running PCA. To obtain a more principled solution, the missMDA package is introduced. The speaker explains how to estimate the optimal number of principal components for imputation with the function `est_ncpPCA`, describing the exhaustive cross‑validation process (testing 0‑5 components for each missing cell) and noting convergence warnings. For larger datasets, a faster k‑fold cross‑validation (`method = CVkfolds`) is suggested. After selecting the estimated number of components (2 in this example), the `imputePCA` function is used to impute missing values, producing a completed data object (`completeObs`). The speaker highlights that PCA‑based imputation leverages variable relationships, yielding more realistic estimates than simple mean replacement. Finally, the completed data are fed back into FactoMineR’s `PCA` function, and the resulting individual and variable factor maps are displayed. The tutorial concludes with a concise three‑step workflow: estimate dimensions, impute missing data, then run PCA on the imputed matrix, ensuring that the analysis relies only on observed information.
Chapters
We will see how to perform PCA on an incomplete dataset. We will use the following dataset, Orange, which contains 8 continuous variables, 12 individuals, and some missing values. Missing values are denoted by NA for not available. So we will load the FactoMineR package. It is also possible to perform a PCA on this dataset. So here are the results of the PCA. But what happened for the missing values? Missing values were replaced by the mean variable and PCA was performed on the completed data table. It is possible to achieve a PCA with missing data using the package missMDA. This package contains several functions. Some functions allow us to impute missing values in order to perform PCA on a completed data To do this, we need to estimate the number of dimensions which will be used to complete the dataset. We write nb= est_ncppca means that we test the number of dimensions between 0 and ncp_max= 5. This procedure is very long because for each cell the value is removed then estimated with 0 component, with 1 component, with 2 components, and up to 5 components. Then the difference between the estimated value with 0 component and the observed value is calculated, the estimation with 1 component and the observed value, and we do that for each component. So there were 50 warnings which show that the algorithm did not converge for 50 situations. The estimated number of components is 2, so this number is used for the imputation of the data table. For large data tables, it is better to use the argument method CV=kfolds, which means that some values of the dataset are removed, then reestimated for 0 and until 5 dimensions. This procedure is repeated a number of times. It is not repeated as many times as there are cells, and therefore the algorithm is faster. We do not perform the algorithm here, so we do Escape. We can now achieve the imputation with imputePCA , and we impute using 2 components of the PCA. The imputation is done. We can visualize the completed dataset in the object completeObs. If we compare with the raw dataset, we can see that the observed values do not change. And for missing values, for instance for individual 5 and the variable color intensity, the missing value is estimated by 633. The imputation is more interesting than the one that takes into account the average since the links between variables and the similarities between individuals are taken into account to improve the estimated value. With this completed data table, we can now perform PCA using the PCA function available in FactoMineR. We obtain the graphs of the individuals and the graphs of the variables. So to sum up, we first have to estimate the number of dimensions that will be used to perform PCA and to impute the dataset. Then we impute the dataset to have a completed data table. And finally, we perform the PCA on the completed data table. And with this methodology, the PCA is performed only on the observed values.