# Making sense of PCA and K-means clustering applied to panel data

Following the excellent example of the PCA explanation here, I would like to ask help for drafting a layman explanation of how to apply PCA and cluster analysis in a real example with panel data. The result would be of great use if we manage to draw a series of sequential steps describing the application of these powerful instruments for a real world example, without getting too deep into the math of all this.

We have the following problem to figure out:

• We have data set collecting 20 years records of episodes of violence among teenagers at school. These episodes were recorded from x schools in y cities in z countries;

• For each school, we collected a series of information, let's say n (>200) variables describing the schools and their population (mainly demographic and socioeconomic data).

Our final goal is to understand what are the main factors (among the n variables) that are more likely to determine the number of violent episodes.

A relatively simple analysis, would be to set up a panel regression controlling for year and school/city/country fixed effect. The n variables are, however, highly correlated and it would be impossible to avoid multi-collinearity problems without performing a dimension reduction procedure.

I am listing now a series of logical steps I would put in place (numbers), followed by a series of doubts I have for each of them (letters):

1. Normalization of the variables. a) Should this be performed for the whole panel or by school/city/country? b) Should the variables always be centered in zero?

2. PCA. a) Should the PCA be performed separately for each of the school/city/country or for each of the years in the period considered, for an average value, or, conversely, for the whole number of observations? b) Should the dependent variable (number of events per school per year) be included in the PCA?

3. Cluster analysis (K-means) highlighting on the one hand the cluster of variables and, on the other, the spatial clusters of schools. a) Should the dependent variable be included? b) Should the panel be stratified by year or collapsed to a mean value for each of the n variables for each school?

4. Set up a panel regression model using the PC's as regressors. a) Should year and school/city/country fixed effect still be included? b) How should the PC's coefficients be interpreted?

I hope this makes sense. Thanks.