Using PCA to Find Low-Variance Portfolio Spreads
Summary
The document outlines a PCA workflow for studying relationships among selected assets and constructing portfolio spreads. It recommends converting price histories to log returns and centering the observations, then calculating a covariance matrix; a correlation matrix is an alternative when the goal is to reduce the influence of differing volatilities. An eigenvalue solver such as Jacobi rotation can then provide eigenvalues and eigenvectors.
The discussion distinguishes principal directions: the largest eigenvalue describes the direction with the most variance, while the smallest identifies a low-variance component that may be useful when seeking a stable spread. The corresponding eigenvector supplies portfolio coefficients for the assets. The question’s initial procedure contains a selection error: it proposes taking the largest absolute eigenvalue despite naming the result a minimum-variance portfolio. The answer clarifies the intended interpretation, but offers no empirical validation or detailed guidance on cointegration testing, return scaling, or whether a low-variance spread will remain stable out of sample.
Key ideas
- PCA should be applied to centered return observations rather than raw price levels when constructing return-based spreads.
- Covariance preserves volatility differences, while correlation standardizes them.
- The largest eigenvalue corresponds to the highest-variance principal direction.
- The smallest eigenvalue identifies a low-variance direction, whose eigenvector gives asset coefficients.
- A low-variance PCA portfolio is not by itself proof of cointegration or a reliable trading signal.
Tags
Full text
# Step-by-Step PCA algorithm (checking correctness without math packages) # Step-by-Step PCA algorithm (checking correctness without math packages) I would appreciate if someone could correct me if i am wrong in my suggestion. I am using PCA to : - find measure of cointegration between selected assets - find the eigenvector and its portfolio with a market-neutral position (min variance) Unfortunately i am not sure whether i am doing it the right way. Here is my algorithm : - getting the base matrix N x M : N - number of assets, M - number of history samples - getting simple covariance matrix : Cov = E[(X - E[X])(Y - E[Y])] - solving eigenproblem using Jacobi's Rotation method : [example][1] - finding the index of the biggest eigenvalue by module : MinVariance = Min(Abs(eigenvalue)) - eigenvector can be found as a column in the rotation matrix by index of eigenvalue The question is : did i miss something in this list of actions according to my initial purposes mentioned above? > I am asking because i already calculated these weights for selected currencies but they look odd to me because e.g. EURUSD and GBPUSD seem to be opposite to each other when everyone knows that they are highly correlated and moves together most of the time http://c.mql5cdn.com/3/28/USDCHFM1.png Here is my implementation of PCA on a C++ similar language called MQL http://www.mql5.com/ru/forum/16512/page3#comment_732844 (see attachment) ## Answer by Anonymous (score 1, accepted) https://quant.stackexchange.com/a/15845 To close this question. Steps used, in short : - get matrix N x M where N - number of assets, M - number of history samples - normalize all samples using logarithms and mean to have returns instead of some asset specific values - obtain covariance matrix, or correlation, if you want to avoid influence of volatility - solve eigenproblem using SVD and Jacobi's rotation on covariance matrices - Jacobi rotation returns two matrices - eigenvectors and eigenvalues Understanding results : - eigenvalue stands for variance of the portfolio's spread - choosing max eigenvalue means selecting direction of entire portfolio - choosing min eigenvalue means selecting periodic, noise or error component of portfolio with min variance - each value in eigenvector is weighting coefficient for relevant asset in portfolio which asset needs to be multiplied by to get back to initial course - eigenvector is a column in rotation matrix taken by index of selected eigenvalue Resources : - The best step-by-step tutorial on PCA is http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf - The best theoretical explanation of PCA is https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/ - Implementation in C# http://crsouza.blogspot.com/2009/09/principal-component-analysis-in-c.html - Implementation in R http://www.statmethods.net/advstats/factor.html
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.