I'm using daily settlement data to get yield levels for a couple of products. From this data I am doing PCA on a rolling collection of the yield levels. I have been using sci-kit learn's PCA function, but I also see the issue when doing my own PCA through Numpy. So as far as I know it's not an issue of the libraries.

After I get the vectors I solve the linear equations such that the first two principle components sum to 0. This is done by setting one of the weights = 1.0

Here's an example. I have data for 150 settlements and I calculate the PC's using data from day 0-100, then I recalculate 10 days later on data 10-110, etc.

When I do this I get a graph of the PC's

Graph of PC's

And here are the corresponding weights.


Relevant math: After performing the PCA I get the components matrix $~ \left( \begin{array}{ccc} a & b & c \\ d & e & f \\ g & h & i \end{array} \right) $ From here I take the first two vectors $[a, b, c]$ and $[d, e, f]$. Which I then turn into the equation $Ax = B$ that looks something like this $~ \left( \begin{array}{ccc} a & c \\ d & f \end{array} \right) \left(\begin{array}{ccc} x_1 \\ x_3 \end{array} \right) = \left(\begin{array}{ccc} b \\ e \end{array} \right)$

As you can see the $x_1$, $x_3$ weights start to blow up at some point which doesn't really make sense given the nature of the data.

Does anybody have any insight to my problem?

  • $\begingroup$ When you say "a couple" do you actually mean 2? Your second and third components look to be extremely highly (negatively) correlated, suggesting you could have some sort of linear dependence. $\endgroup$
    – will
    May 13, 2017 at 10:58

1 Answer 1


A couple quick thoughts.

  1. Do the PCA on changes or log-changes in your series. That is often how PCA is conducted in fixed-income settings.
  2. You're large move in wights corresponds to outlier moves in the blue series. Given the assumptions of a PCA, I would consider whether your dataset has suffered from any breakpoints, regime changes or other rare events
  3. Think about smoothing your weights (with some priors). Remember that you are trying to explain the interaction of three fixed income instruments (which are driven by economies, politics, and market forces) by only 9 parameters. You need to match your analysis with reasonable expectations on its performance.
  • 3
    $\begingroup$ Agree with 2 & 3. But lots of people use PCA on levels for RV purposes. $\endgroup$
    – Helin
    Aug 22, 2015 at 8:18
  • $\begingroup$ @closedloop I have tried the PCA on changes/log-changes before this post, I probably should have mentioned that. I'm doing it on levels because, for the most part, yields are already normalized and it makes more sense for what I am trying to model. As for 2, these are future contracts and I'm guessing my rolling algorithm might be causing some strange discontinuities that I will have to investigate. 3. Do you have any literature on weight smoothing in a PCA framework that you would recommend? $\endgroup$
    – meh
    Aug 25, 2015 at 13:50
  • $\begingroup$ @meh I'd look at the papers describing Black-Litterman or anything on Bayesian PCA. $\endgroup$
    – closedloop
    Aug 25, 2015 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.