**Have a Question?**

**Phone:** +1 (888) 427-9486

+1 (312) 257-3777

Contact Us

# Principal Component Analysis (PCA) 102

This is the second entry in our **principal components analysis in Excel**(PCA) series. In this tutorial, we will resume our discussion on dimension reduction using a subset of the principal components with a minimal loss of information. We will use NumXL and Excel to carry out our analysis, closely examining the different output elements in an attempt to develop a solid understanding of PCA, which will pave the way to a more advanced treatment in future issues.

In this tutorial, we will continue to use the socioeconomic data provided by Harman (1976). The five variables represent total population (“Population”), median school years (“School”), total employment (“Employment”), miscellaneous professional services (“Services”), and median house value (“House Value”). Each observation represents one of twelve census tracts in the Los Angeles Standard Metropolitan Statistical Area.

## Process

Now we are ready to conduct our principal component analysis in Excel. First, select an empty cell in your worksheet where you wish the output to be generated, then locate and click on the principal component (PCA)icon in the NumXL tab (or toolbar).

The Regression Wizard will appear.

Select the cells range for the five input variable values.

**Notes:**

- The cells range includes (optional) the heading (Label) cell, which would be used in the output tables where it references those variables.
- The input variables (i.e. X) are already grouped in columns (each column represents a variable), so we don’t need to change that.
- Leave the “Variables Mask” field blank for now. We will revisit this field in later entries.

Next, select the “Options” tab.

Initially, the tab is set to the following values:

- “Standardize Inputs” is checked. Leave this option checked.
- “Principal Component Output” is checked. Uncheck it.
- The significance level (aka. ) is set to 5%.
- “Input Variables” is unchecked. Check this option.
- Set “No. of PCs included” to 3. This action can be done now or altered later in the output tables, as our formulas are dynamic.
- Under “Input Variables”, check the “Values” option, so the generated output tables include a fitted value for the input variables using a reduced set of components.

Now, click the “Missing Values” tab.

In this tab, you can select an approach to handle missing values in the data set (X and Y). By default, any missing value found in any observation would exclude the observation from the analysis.

This treatment is a good approach for our analysis, so let’s leave it unchanged.

Now, click “OK” to generate the output tables.

## Analysis

### 1. Statistics

In this table, we show the percentage of variance of each input variable accounted for (aka final communality) using the first three (3) factors. Unlike the cumulative proportion, this statistic is related to one input variable at a time.

Using this table, we can detect which input variables are poorly presented (i.e. adversely affected) by our dimension reduction. In this example, the “median school years” has the lowest value, yet the final communality is still around 92%.

### 2. Loadings

In the loading table, we outline the weights of the principal component in each input variable:

To compute the values of an input variable using PC values, we use the weights above to linearly transform them back. For example, the population factor is expressed as follows:

**Notes**

- This table is basically the transposed table (row turned into columns) that we saw in the variables’ loadings for PCs.
- The sum of squares of each row must be 1.
- are are uncorrelated, so to compute the variance of (Standardized),using the first k-components:

Where

- is the loading of the k-th principal component for the input variable.
- is the variance of the k-th principal component.
- is the estimate for the standardized input variable using the first k-components.

- By definition, the is the final communality.
- The variance of the fitted input variable in the original scale (non-standardized) is expressed as follows:

- Reducing the dimension, in essence, reduces the variance of the input variables (low pass filter).
- What about the correlation among original variables? How are they affected by reducing the dimensions?

Where

- is the standardized fitted i-th variable using the first k-principal components
- is the original standardized i-th input variable.
- is the original i-th input variable.
- is the non-standardized fitted i-th input variable using the first k-principal component.

The correlation between the fitted variables (i.e. reduced dimensions) may be slightly different depending on the variance of the dropped factors and the loading of those factors in each variable.

- How about covariance between the variables (non-standardized)?

In sum, the relative change in covariance is equal to the change in correlation between the two variables.

**Note:**Reducing the number of factors alters the statistical characteristics of the underlying data set, so extreme care must be taken.

### Fitted Values

Using the first three (3) principal components, NumXL calculates the fitted value for each input variable:

**Note:** Although the principal components analysis in Excel uses the standardized version of the input variables, it computes the fitted values in the original non-standardized format.

Let’s plot population (highest final communality) and median school years (lowest final communality) for the original data and for the fitted one.

## Conclusion

In this tutorial, we examined the dimension reduction proposition from 5 PCs to 3 PCs without significant loss of information.

### What do we do now?

In the first two tutorials, we focused on delivering the key ideas behind the principal component analysis and, to some extent, the rationale behind the dimension reduction proposition. The cross-section socio-economic sample data, although not a time series, served to demonstrate the theory and to show NumXL’s different output tables.

In the third entry of this series, we are ready to look into a set of correlated time series, apply PCA technique to derive a reduced core set of uncorrelated drivers. Next, we forecast the values (mean and standard error) for the uncorrelated drivers, and using the PCA Loadings, imply the corresponding forecast (mean and error) for each input variable.

Attachment | Size |
---|---|

principal-component-analysis-102.xlsx | 18.9 KB |

principal-component-analysis-102.pdf | 529.3 KB |