File
pca.m
Name
pca
Synopsis
pca - Calculates the covariance matrix of the returns for different assets and its eigenvalues and eigenvectors.
Introduction
Increased commonality among the asset returns of banks, brokers, insurers, and hedge funds can be empirically detected by using PCA to decompose the covariance matrix of the four index returns. Given the covariance matrix, the 4 eigenvalues can be estimated along with the 4 eigenvectors. The authors use the above PCA analysis on 36-month rolling windows of returns and track the relative magnitudes of the four eigenvalues as well as the eigenvector exposures of the two eigenvectors corresponding to the two largest eigenvalues. The idea is that systemic risk is higher when the largest eigenvalue explains most of the variation of the data; and the commonality between the 4 types of institutions can be seen by the corresponding entries in the eigenvectors corresponding to the largest eigenvalues: if, for example, the eigenvector corresponding to the largest eigenvalue has similar entries, then all 4 types of institutions have similar exposure to this principal component.
License
=============================================================================
Copyright 2011, Dimitrios Bisias, Andrew W. Lo, and Stavros Valavanis
COPYRIGHT STATUS: This work was funded in whole or in part by the Office of
Financial Research under U.S. Government contract TOSOFR-11-C-0001, and is,
therefore, subject to the following license: The Government is granted for
itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
worldwide license to reproduce, prepare derivative works,
distribute copies to the public, perform and display the work.
All other rights are reserved by the copyright owner.
THIS SOFTWARE IS PROVIDED "AS IS". YOU ARE USING THIS SOFTWARE AT YOUR OWN RISK. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS, OR THE UNITED STATES GOVERNMENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================
Inputs
Outputs
Code
% Run warning message
warning('OFRwp0001:UntestedCode', ...
['This version of the source code is very preliminary, ' ...
'and has not been thoroughly tested. Users should not rely on ' ...
'these calculations.']);
%
% Parameters:
% asset_Returns The time series of asset returns. A nxk matrix. Rows are
% the different dates. Columns are the different assets
% Output:
% Sigma The covariance matrix of the asset returns
% eigenvalues The eigenvalues of the covariance matrix
% eigenvectors A matrix with the corresponing eigenvectors of the
% covariance matrix as its columns
% Calculate the covariance matrix
Sigma = cov(asset_returns);
% Find the eigenvalues and eigenvectors
[eigenvectors lambda] = eig(Sigma);
eigenvalues = diag(lambda);
Examples
NOTE: Numbers used in the examples are arbitrary valid values.
They do not necessarily represent a realistic or plausible scenario.
asset_returns = ...
[-0.0805,-0.0510, 0.0438, 0.0614;
-0.1051,-0.1011,-0.0079, 0.0591;
-0.1108,-0.0928, 0.1030, 0.0155;
0.1055, 0.1013,-0.0990,-0.0790;
-0.0816, 0.0644,-0.2163, 0.0651];
[Sigma, eigenvalues, eigenvectors] = pca(asset_returns);
References