The video demonstrates how to conduct a Factorial Analysis on Mixed Data (FAMD) using the FactoMineR package in R. It begins by explaining that FAMD is a principal component method that simultaneously handles quantitative and categorical active variables, preserving the nature of continuous variables unlike MCA, which requires discretisation. The presenter loads the 'morphology' dataset (10 quantitative variables and one categorical variable 'drift'), runs the famd function, and notes that no supplementary elements are specified. The summary of the FAMD result is examined: eigenvalues and inertia percentages, sample coordinates, contributions, and quality of representation (cos2) for the first three dimensions; quantitative variable coordinates, contributions, and cos2; and categorical variable (drift) categories with their coordinates, contributions, cos2, and v‑tests. The v‑test interpretation (values beyond ±2 indicate significant deviation from zero) is illustrated with specific categories. Four standard plots are generated: a combined variables graph (using squared correlation ratios for categorical variables and squared correlation coefficients for quantitative ones), a category graph (centroids of samples per category), a correlation circle for quantitative variables, and a sample plot coloured by the drift categories. Finally, the speaker mentions that the principal components from FAMD can be used for downstream clustering, which benefits from distances that incorporate both quantitative and categorical information.
Chapters
The purpose of this video is to show how to perform a factorial analysis on mixed data with the FactoMineR package. The factorial analysis on mixed data is a principal component method which takes into account both quantitative and categorical variables as active variables. So first I will load the FactoMineR package and I will use the FA md function. We can see the help of this function and on the bottom of this help there is an example on geomorphology. So I can load the dataset and first summarize the dataset. So this dataset contains 10 quantitative variables and 1 categorical variable which is named drift and corresponds to type of drift. Typically, with this dataset, an MCA could be performed if all the continuous variables are divided into categories and thus recoded into categorical variables. Then all the variables are categorical and MCA can be performed. But in this case, some information is lost because the variables are in nature continuous. So we will prefer to perform a factorial analysis on mixed data where we will keep the nature of the variables. The quantitative variables are considered as quantitative and the categorical variable is considered as a categorical one. So I'm going to perform a factorial analysis on mixed data using the famd function on the dataset morphology. There are no supplementary samples, no supplementary variables, else I could specify some supplementary elements. Because here there is only one categorical variable, this variable is considered as active, else all the active variables would be quantitative and we would perform a PCA. So the analysis is performed and first I summarize the results using the summary function on the output, so the object res. We will see that this function gives results that are mixed between PCA results and MCA results. So first we have a recall of the lines of code that is used, that was used, so FAMD on the dataset morphology. Then we have the eigenvalues and the percentage of inertia, that is to say the percentage of variance associated with each dimension. And then we have the results for the samples, by default the first 10 samples, with the coordinate on the first dimension, the contribution to the construction of the first dimension, and the quality of representation measured by the square cosine. If the square cosine is close to 1, it means that sample is well projected on the dimension. So Here are the results for the first dimension, and then the same results for the second and the third dimension. Then we have the results for the variables. First for the quantitative variables. So by default, once again, the results for the first 10 variables. The results are the coordinate of the variable on the dimension, the contribution of the variable to the construction of the dimension, and the quality of representation for the first 3 dimensions. Then we have the results for the categorical variables. Here we just have one categorical variable, and for one categorical variable we have the results for all its categories. So the drift categorical variable has 6 categories, and therefore we have the 6 categories and their coordinates, their contribution to the construction of the dimension, their quality of representation, and then their v-test. So the v-test takes its values between -2 and 2 unless the coordinate is significantly different from 0. A v-test is less than -2 if, on average, the coordinates of samples who take the category are significantly less than 0, and the v-test is greater than 2 if the samples who take the category have coordinates that are average significantly greater than 0. So samples who take the category diamict have coordinates significantly greater than 0 on the first dimension. Samples who take the category kem and those who take the category terraces have coordinates significantly less than 0 on the first dimension. And it is the same on the second and on the third dimension. So there was no result here for supplementary samples, for supplementary quantitative variables, or supplementary categorical variables. Because there were no supplementary elements. So then we have several graphs. We have 4 graphs. First, the variables graph with both continuous and categorical variables. A coordinate for a categorical variable is the squared correlation ratio between the continuous variables that correspond to the coordinates of the samples on the dimension and the categorical variables. The squared correlation ratio is an indicator that quantifies the link between a quantitative and a categorical variable. It is the indicator that is used in one-way analysis of variance. So we have the squared correlation ratio with the first dimension and the squared correlation ratio with the second dimension for the variable drift. For quantitative variables, we will calculate the squared correlation coefficient between the variable and the dimension. So wine the squared correlation ratio, the squared correlation coefficient, because it makes possible to represent quantitative and categorical variables on the same graph. Thus, we have a graph with the categories. The categories could be drawn on the samples graph, more precisely the same graph as in MCA, where a category is at the centroid of the samples whose take the category. We draw the samples here and then a graph with the quantitative variables, the same graph as in PCA corresponding to the correlation circle graph. I can draw the graph of samples and color the samples according to the variable drift. So samples are colored according to the category they have for this variable. So in red we have the samples who take the category beach, and in dark blue samples that take the category cave. So as with all principal component methods, after the factorial analysis on mixed data, we can perform a classification, a clustering. So the main advantage of a classification or a clustering performed on the principal components is that the distances between samples take into account both the information provided by the quantitative variables and by the categorical variables.