SesIndexCreatoR: An R package for socioeconomic indices computation and visualization

In order to study social inequalities, indices can be used to summarize the multiple dimensions of the socioeconomic status. As a part of the Equit’Area Project, a public health program focused on social and environmental health inequalities; a statistical procedure to create (neighborhood) socioeconomic indices was developed. This procedure uses successive principal components analyses to select variables and create the index. In order to simplify the application of the procedure for non-specialists, the R package SesIndexCreatoR was created. It allows the creation of the index with all the possible options of the procedure, the classification of the resulting index in categories using several classical methods, the visualization of the results, and the generation of automatic reports.


Introduction
When studying social inequalities, it is generally interesting to take into account the socioeconomic status (SES) of an individual, a neighborhood or a region rather than consider only one socioeconomic variable such as educational level or income.However, socioeconomic status is a complex and multidimensional concept which encompasses many aspects such as employment, income, education, housing and social bonds.All of these aspects can themselves be represented by various variables.To synthesize and consider these different aspects, one solution is to create a SES index.
There are already many existing SES indices, especially at the neighborhood level [1]- [9].However, most of them use a small number of variables, combine variables with simple methods (such as Z-score) and/or select variables only from the litterature, which seems inappropriate for the purpose of the Equit'Area Project, a public health program focused on social and environmental health inequalities (http://www.equitarea.org), as detailed elsewhere [10].Thus, a new statistical procedure to create neighborhood socioeconomic indices was developed.Basically, this procedure does not create an index from a set of determined and precise variables, but aims to select, from a large data set, variables which will compose the SES index.It is based on several successive principal component analyses and the whole procedure is detailed in the aforementioned article.It has already been successfully applied in several analyses aiming to study health or environmental inequalities [11] [12].
Compared to other existing approaches to compute indices, our procedure is a slightly more complex to understand and apply, especially for non-statisticians than for some other SES indices; we specifically developed our model in a R package [13], named SesIndexCreatoR.The package is freely available on the website of the Equit'Area project and on CRAN.The site http://www.equitarea.org/documents/packages_1.0-0/ contains the basic functions needed to run the procedure (in its entirety or only in some steps) and to obtain the corresponding SES index.The purpose of this package is to give tools as simple as possible to perform the procedure while keeping the various possibilities it offered, like using different data mining methods, adding illustrative units, or performing only one step of the procedure.Moreover, once the index is created, users can display all the results of the different analyses both in text and graphical output, and generate a report summary.The user may also create categories of this index with different methods (hierarchical clustering with or without k-nearest neighbors, quantiles, or intervals).
In this paper we present and illustrate the use of the SesIndexCreatoR package for Lille agglomeration (a large French metropolitan area).For further examples we recommend reading the works by Padilla et al. as mentioned above.

Data
The example data provided in the SesIndexCreatoR package concerns one large city in France, Lille (Nord Pas de Calais region, northern France), and some adjacent municipalities.The statistical unit is the sub-municipal French census block groups (called IRIS) defined by the National Institute of Statistics and Economic Studies (INSEE).These units have an average of 2000 inhabitants and are constructed to be as homogeneous as possible in terms of socio-demographic characteristics and land use.Census block groups (BGs) are divided into three distinct categories: housing, economical activity and miscellaneous.Housing BGs are the most common, economical activity BGs include at least 1000 employees and at least twice as many employees as residents, and miscellaneous BGs are specific wide areas sparsely populated (leisure parks, port areas, forest, etc.).As activity and miscellaneous BGs have some particular profiles due to the way they are defined, they are treated in the example as illustrative units (meaning that they are not part of the procedure but will have an index value).For confidentiality and distribution reasons, the real BGs idenficators are replaced in the example data set with a simple number from 1 to 234 (which is the number of BGs of the area).
Socioeconomic data are taken from the 1999 national census (source: INSEE) and provide counts of population, households and residences at BG scale covering all the social, economic and demographic aspects.Median income at the BG scale is taken from a second database: the "Revenusfiscaux des ménages" database (source: INSEE-DGI).Using this raw data, 37 variables are defined at the BG scale based on the INSEE definitions.These variables are chosen to be representative of the theoretical concept of SES and in line with the variables most often used in the literature, or that could be considered as linked with the SES concept.
All variables are related to family structure, household type, immigration status, employment, income, education and housing (more details are available in Table 1 and Table 2).Some of the variables are intentionally redundant and represent the same notion, in view to determine which best represents this notion (using the algorithm    implemented in the proposed package).In our example, there are two such groups: 7 variables of unemployment and 3 variables of labor force.We also note there are an unexpectedly high number of missing values for median income but, willing to keep this variable in the analysis, we filled missing values with the average value of the adjacent BGs.

SES Index Creation
The SES index creation procedure is detailed in Lalloué et al. [10].Basically, it follows three successive steps: (1) Study of the redundant variables.As already mentioned, several variables represent the same notion and we want to determine which best represented this notion.Therefore, one variable is selected for each group by applying principal component analysis (PCA) to each of the groups of redundant variables.The selected variable for each group is the one with the largest correlation with the first component of the PCA on the group.
(2) Selection of the variables.A PCA or a multiple factor analysis (MFA) on the remaining variables (i.e., non-redundant variables and variables selected in step ( 1) is used to select the variables with a contribution to the first component larger than the average one, i.e., variables that were best correlated with the first component ; i.e. variables that were best correlated with the first component.The choice of PCA or MFA depends on the willingness to give the same weight in the analysis to each domain (MFA) or not (PCA).
(3) Construction of the index.A final PCA is carried out including the variables selected in step (2) Provided that the first component of this PCA could be interpreted as a "SES component", it is used to calculate the socioeconomic index as the reduced first component.

The SesIndexCreatoR Package
The SesIndexCreatoR package depends on the FactoMineR [14] [15] and class [16].In particular, most of data analysis and visualization functions, such as principal component analysis or hierarchical clustering, used in this package come from FactoMineR.We thus refer the user to the FactoMineR package and its manual for details on PCA and HC functions outputs.The sources and binaries of the package SesIndexCreatoR are available on the Equit'Area website or on CRAN and the installation is standard.
Because the package is also aimed to be used by R novice users, the example data are not included as R dataset but as a text file, in order to show in the package's manual how to import a file.
SesIndexCreatoR is composed of three main functions and several visualizing and internal functions (see Table 3):  SesIndex function creates a socioeconomic index such as defined in the Equit'Area project.It is possible to choose the starting set of variables, the potential redundant groups of variables, the potential supplementary units, the method of selection (PCA or MFA) and the step of the procedure to perform.Results include the final index and all the results of the intermediate steps.

Example
First, the socioeconomic data from the text file are imported in a data frame: R>library("SesIndexCreatoR") R>SesData<-read.table(+ system.file("extdata","SesData.txt",package = "SesIndexCreatoR"), + header=TRUE,sep="\t", row.names=1) The SesData.txt contains 37 socioeconomic variables and 1 type variable (giving the type of BG) for each BG As the SesIndex function needs vectors or lists of variables' names as arguments, we then extract the different vectors and lists needed to call the function (with redundant groups).The first line of the following code chunk allows to extract the names of the variables to analyse as a vector.The remaining lines extract the names of the variables in the two groups of redundant variables (see Table 1) and create a list containing the two vectors of names for the groups of redundant variables.
R> index <-SesIndex(SesData, varnames=varnames, groupvarnames=groupvarnames, + sup=illus) R>plot(index, choice="ind", label="none") Once the index is created, we want to explore the results of the procedure.For instance, among the groups of redundant variables listed in Table 1 (Unemployment and Labor Force), the variables representing the best these groups and selected by our procedure are: R> index$step1$selection [1] "UnemployedTotal" "LabourForce" Or, among the list of variables in Table 1 and Table 2 (except the redundant variables dropped at step 1), the variables selected to compose the SES index for Lille agglomeration are: R> index$step2$selection [1] "ForeignPop" "UnemployedTotal" [3] "InsecureJobs" "SteadyJobs" [5] "SingleParentFamilies" "NoDiplomas" [7] "IndividualHouse" "MultipleDwellingUnits" [9] "ParkingSpace" "NonOwner" [11] "WithoutCar" "TwoOrMoreCars" [13] "SubsidizedHousing" "MedianIncome" R>plot(index, choice="var", step=2) It is also possible to obtain detailed results of the data mining technics, like the correlation coefficients of the variables with the two first components of the second step analysis: The above outputs are especially interesting to understand the procedure of variable selection.We can see in these results that the variables of total unemployment and total labor force were respectively selected from the groups of redundant unemployment variables and labor force variables.Then, for these two groups only these two variables were kept in the next steps.
We can see in the selection from the step 2 that only variables with the highest correlations with the first component were selected.Here, 14 variables out of 29 were kept for the final step and the construction of the SES index.Eventually, the first component of the final step PCA performed on these 14 variables explained more than 67% of the total variance.R>plot(index, choice="var", step=3) Some graphical outputs can be seen in Figures 1-3. Figure 1 is a synthetic view of the projection of the BGs on the first principal components of the PCA performed in step 2 and step 3. Black dots represent active units whereas blue circles represent illustrative units (i.e., BG of the economical activity or miscellaneous types).Due to the number of units, BG labels are not displayed here but are activated by default.The step 3 part of the figure allows to see that BG are mainly along the first component and have not an extremely important variability along the second component.Figure 2 gives the circle of correlations of the PCA performed in step 2. Most of the variables seem to have a good correlation with the first component, both positively and negatively, whereas as the correlations with the second component are mainly positive (except for two variables).A few variables (5) are not well represented on this plane and may have higher correlations with the third or fourth component.On this figure, a first opposition between "variables of deprivation", at the right, and "variables of favor", at the left, can be seen.
Finally, Figure 3 shows the circle of correlations of the PCA performed in step 3.The opposition between the "deprivation" and the "favor" variables is clear, with a high positive correlation between the first component and proportions of non-owner, unemployment, insecure jobs, person without diploma, subsidized housing, ... and a high negative correlation between the first component and proportion of steady jobs, individual houses, ....The first component of this PCA can then be interpreted as a SES component and be used as a SES index.
We now want to create categories from the socioeconomic index.We use a hierarchical clustering followed by a k-nearest neighbor (k-nn) algorithm.We decide to have an automatic number of classes (i.e., to cut the hierarchical clustering tree where the relative loss of inertia is the highest): Others possibilities currently in the SesClassif function are to create classes with hierarchical clustering without k-nn consolidation, with quantiles or with equal range of values.
We can summarize some characteristics of the different categories using simple functions.For instance, it is possible to compare variables average values in each category and the overall mean: R> for (i in 1:3 We can see that the optimal number of categories (according to the inertia criterion) was 3. The description of these categories showed that they are organised by decreasing socioeconomic status.Indeed, category 1 has higher average values of variables like median income or proportion of steady jobs, and lower average values of proportion of unemployed people or proportion of subsidized housing; whereas category 3 has lower values of median income and higher values of unemployment.Figure 4 shows the projection of these categories on the two first axes of the final PCA (note that it is also possible to use directly plot(categories) to have both the dendrogram and the projection of the units).Eventually, we want to export the detailed results of all the three steps of creation of the SES index and of the classification.We also want to export a data file containing the index and the categories.To do so, the SesReport function is used to create .htmlreport (see Appendix).By default, files are created in the current working directory with basename "SesReport" (which can be change as arguments of the SesReport function).R>SesReport(categories)

Conclusions
In this article we presented the SesIndexCreatoR package, designed to easily create socio-economic indices with a reproductible statistical procedure.One originality of this procedure compared to other existing indices lays in selecting the final variables for the index by usage of data mining techniques rather than only information gleaned from a literature review, allowing to discard part of the subjectivity that may influence the choice of the variables.This data driven approach allows the data "speak by themself".
The SesIndexCreatoR package allow applying this procedure in a versatile way, by specifying which steps of the procedure should be runned (for instance only step 2 if the aim is to compare selection of variables between metropolitan areas without create indices, or only step 3 if one wants all the introduced variables to be in the index), adding illustrative units or selecting the method used.Once the index created, several tools are available to visualize, synthetize, explore and export the results in a convenient way for further utilization.
We project to extend the package in the future and among other improvements we foresee to implement others methods of classification, to add more tools to help the interpretation of the results, or to allow other ways of visualization (such as mapping).However, these improvements will be made according to users' returns and needs.
age of 25 in the total population OverAge65 people over the age of 65 in the total population SingleParentFamilies Single-Parent families in the total population HouseHolderAlone Householders living alone in the total population Immigration ForeignForce People in the labor force in the total population Employment and Income LabourForce People in Labor Force in the total population a MenLabourForce Men in labour Force in the male population a WomenLabourForce Women in labour Force in the female population a UnemploymentTotal Unemployment people in the labor force b UnemploymentForeigners Unemployment Foreigners in the labor force b UnemploymentAge1524 Unemployment people in the 15 -24 years old labor force b UnemploymentOverAge50 Over 50 years old unemployment people in the labor force b UnemploymentMen Unemployment people in the male labor force b UnemploymentWomen Unemployment people in the female labor force b UnemploymentMore year People unemployed for more than 1 year in the labor force b SelfEmployed Self-employed (independent workers, employers, etc.) in the labor force InsecureJobs People with unstable jobs in the labor force SteadyJobs People with steady jobs in the labor force MedianIncome Median income per consumption unit (in euros per year) c

AttendingSchool People 6 - 2
15 years old school in the 6 -15 years old population NoDiplomas People with no diploma (and no studying) in the 15 years old and more population BasicGeneralQualifications People with basic or intermediate general or vocation qualifications (and not studying) in the 15 years old and more population GeneralCertificates People with general or vocational maturity certificates (and not studying) in the 15 years old and more population LowerTertiaryEducation People with at least a lower tertiary education (and not studying) in the 15 years old and more population HigherEducationalDegree People with a higher educational degree (and not studying) in the 15 years old and more population Students Student in the 15 years old and more population Main residences larger than 150 m 2 ParkingSpace Main residences with a parking space (garage or other) WithoutCar Households without a car TwoOrMoreCars Households with 2 or more cars

Figure 1 .
Figure 1.Synthetic view of the graphical outputs for individuals.

Figure 2 .
Figure 2. Correlation circle for the second step.

Figure 3 .
Figure 3. Correlation circle for the final step.

Figure 4 .
Figure 4. Plot of the individuals by categories.

Table 1 .
Description of 37 socioeconomic variables available for the Lille agglomeration at the census block group scale, by domain.(Unless stated otherwise, variables are proportions expressed in %; a Redundant group "labor force"; b Redundant group "unemployment"; c Not a proportion).

Table 2 .
Description of the 37 socioeconomic variables available for the Lille agglomeration at the census block group scale, by domain (continued).(Unless stated otherwise, variables are proportions expressed in %).


SesClassif function creates socioeconomic categories, based on a socioeconomic index created by SesIndex function, with different technics such as hierarchical clustering, quantiles or equals subdivisions.Results include both a table with the original data set with class of each unit and the results of the classification technic (cut points, classes particularities,...). SesReport function creates a .htmlfile with a report summarizing the results of the different steps of the creation of a socioeconomic index with the SesIndex function and, if any, the classification of the index using the SesClassif function.This function also allows to create a.csv file containing the original data set and the index and, if any, the classification.
of the Lille municipality and adjacent municipalities, as describe in Section 2.1 Data.Then, the SesDatadataframe has 234 rows representing the BGs and 38 columns representing the variables.