The video tutorial walks through a complete workflow for performing correspondence analysis (CA) on a 2003 birth dataset using the FactoMineR package in R. It begins by defining age-group categories for mothers and fathers, distinguishing active categories (used to build the CA) from supplementary (illustrative) ones, and grouping sparse age groups. The presenter then shows how to set the working directory, import the CSV data with appropriate headers and row names, and load FactoMineR. Using the CA function, they specify which rows and columns are supplementary, run the analysis, and store results in an object. The summary.ca output is examined: chi‑square test significance, eigenvalues and inertia, coordinates, contributions, and squared cosines for the first three dimensions for both active and supplementary rows/columns. The tutorial demonstrates how to improve CA plots by adjusting font size, adding titles, shading, and selectively labeling points based on representation quality (cos2 ≥ 0.7), contribution, or specific categories, as well as switching axis pairs. The dimdesc function is used to list rows and columns ordered by increasing coordinate values. Finally, hierarchical clustering on principal components (HCPC) is applied to the CA results, clustering either rows or columns; the example clusters columns into three groups, interpreting the resulting dendrogram and class assignments. The video concludes with an invitation for viewers to try the methods themselves.
Chapters
In this video, we're going to look at how to do a correspondence analysis with FactoMineR. For this, we're going to work with data on the number of births in 2003, as a function of the ages of the father and mother. As rows, we have different age groups: mothers younger than 20, from 20 to 24, 25 to 29, etc. In the columns, we have the same age groups for the fathers. For example, in the first entry, 2085 corresponds to the number of children born to a mother and father both less than 20 years old. In this table, some values are really quite small. In particular, the number of births to mothers between the ages of 45 to 49 and 50 to 60. For the purposes of this tutorial, we would like to group these 2 together as one group, mothers 45 and over. We are going to use as active categories mother younger than 20, from 20 to 24, up to 40 to 44, and mother 45 and older. We'll use the rows mother from 45 to 49 and 50 to 60 as illustrative categories. Same thing for the fathers. Active categories here are fathers less than 20 years old, up to fathers from 50 to 54, and fathers 55 and over. Illustrative categories are fathers from 55 to 59 and fathers 60 and over. The colours shown here in the row and column names indicate whether the categories are active or supplementary. These colors will show up again in the CA plots. Let's move to the practical part: how to do correspondence analysis with FactoMineR. First, let's import the data. The first line of code lets me say in which folder my data is located, using the command setwd. Next, we import the dataset by giving the name of the folder. We signal that the column names are available with header=True, that the columns are separated by semicolons, which is normal in, in CSV files, that the row names, the individuals' names or row names, are available here in the first column of the dataset. So, the import seems to have worked, and we can check that it has. See, how all the variables are quantitative, as we wanted and expected. Next, we load the FactoMineR library, and run a CA using the CA function in FactoMineR. If you want, you can go and take a closer look at the help file for the CA function. The function requires us to input the data, here the table is called birth. We tell R that lines 7 and 8 are supplementary, As are columns 9 and 10. So, the CA has run. The results are placed in the object called res, and the simultaneous representation plot is created. We can take a closer look at the results of the CA using the function summary.ca. The first line here reminds us of the command used to run the CA. Next up, the results of the chi-square test on the variables using only the active rows and columns. The value is very big, so there is a significant relationship between the 2 variables. After this, we have a table showing the eigenvalues and the percentages of inertia associated with each dimension. Then, the results for the active rows, showing the coordinate value of the rows in the first dimension, the contribution of each row to the construction of the first dimension, and the quality of representation on the first dimension, followed by the results for the second dimension and the third. Same thing for the active columns: we get the coordinate values, the contributions, and the squared cosine for the first, second, and third dimensions. Next, we have the results for the supplementary variables. First up, the supplementary rows, with their coordinate values and quality of representation. We don't have their contribution, because they didn't contribute to the construction of the dimensions. Then, the same thing for the columns: coordinate values and quality of representation for the 1st, 2nd, and 3rd dimensions. We can go back to the plots and improve them by making the font size smaller, on adding a title, for example. With a smaller font size, the labels overlap much less. The plot is easier to take in. We see that the point for fathers from 35 to 39 is just below the axis line, so if we add a little shading, it becomes easier to read. We can then take a closer look at the dimensions using the dimdesc function. Here, dimdesc outputs the rows in terms of increasing coordinate value, on the columns, too, in terms of increasing coordinate value. There's no statistical test run for correspondence analysis. In summary, we have results uniquely for the coordinates of the first 3 dimensions, by default. Going back to the plots, we can make new ones by selecting certain things to highlight. For example, here we can decide we want to make the supplementary rows and columns invisible. This gives us a plot with only the active rows and columns appearing. Also, we can only put labels on points which are well represented. So, here are the rows with a sufficiently good representation, with square cosine of at least 0.7 on the plane, and similarly, the columns with square cosine of at least 0.7 on the plane. The points representing rows and columns with visible labels here are these well-projected ones. The others are not labeled and are shown with a transparency effect. This can be very useful when there are too many points on the plot to see clearly. Only showing the most important ones makes it easier to interpret. We can also put labels on only the best represented points. For instance, the 4 best represented rows, and the 3 best represented columns. Here, on this plot, we see the 4 best represented active rows are labeled, and the 2 supplementary rows too. If there had been more than 4 supplementary rows, only the best projected 4 would have been labeled. Moving on to the columns, the 3 best-represented ones are labeled, as well as the 2 supplementary ones. We can also label points as a function of their contribution. So, for instance, the 4 rows with the largest contribution to the plane's contraction on the 3 columns. Here's the plot showing them. We can also choose points to label from only certain categories. For instance, mothers younger than 20 on all columns. As no selection is made from the columns, all of them are labeled. Also, as in all factor analysis situations, we can instead choose to plot other pairs of axes, for example, 1 and 3. Lastly, we can try to do clustering. After running correspondence analysis, either we can do clustering on the rows, or on the columns. In the HCPC function, which helps us to do clustering, we simply choose which one we want. We use the cluster.ca input to say that we want to cluster the columns. Here is the tree that is output. Let's now partition it into 3 classes. Here is the result. It gives an interesting one. First, the fathers under 20 years old are in their own cluster. Next, the fathers from 20 to 24, and those from 25 to 29, are clustered together. And all the rest are in the 3rd cluster. And there you have it, correspondence analysis followed up by clustering. So that's all from us on this subject. Now it's your turn.