filter.RMT {tawny} | R Documentation |
Used to filter out all eigenvalues below k*. At a later date this will become pluggable so other people can use their own functions and/or provide their own parameters to this function.
filter.RMT(h, hint, ..., type = 'kernel') getRandomMatrix(m, t) mp.theory(Q, sigma, e.values = NULL, steps = 200) mp.density.hist(h, breaks = NULL, cutoff = 0.01) mp.density.kernel(h, ...) ## Default S3 method: mp.density.kernel(h, ...) ## S3 method for class 'returns': mp.density.kernel(h, ...) ## S3 method for class 'covariance': mp.density.kernel(h, ...) ## S3 method for class 'correlation': mp.density.kernel(h, adjust = 0.2, kernel = 'e', ...) # Fit the appropriate MP curve to the data. This will estimate Q and sigma. mp.fit.hist(hist) mp.fit.kernel(hist) # Marcenko-Pastur theoretical minimum and maximum eigenvalues mp.eigen.max(Q, sigma) mp.eigen.min(Q, sigma) # Generate eigenvalues for theoretical MP distribution mp.lambdas(Q, sigma, steps) # This provides the density of the eigenvalues mp.rho(Q, sigma, e.values) r.normalize(h) cor.empirical(h) denoise(hist, lambda.plus = 1.6, h = NULL)
h |
A generic tawny object that represents either a returns stream, covariance matrix or correlation matrix. |
hint |
A hint to the optimizer for fitting a theoretical curve to the empirical distribution |
type |
The type of density calculation to use, either kernel or hist |
m |
Scalar representing the number of assets in a portfolio |
t |
Scalar representing the number of observations |
breaks |
The breaks specification for building a histogram |
cutoff |
A threshold to eliminate eigenvalues below this value. Used to improve the performance when correlations are too high and negative eigenvalues exist. |
adjust |
Option for density to scale bandwidth |
kernel |
Option for density to define what kernel estimator to use |
hist |
Histogram-like object that contains eigenvalues, eigenvectors, and density information |
Q |
Ratio of data points per time series |
sigma |
Standard deviation of entries in h |
e.values |
Eigenvalues |
steps |
Number of steps to use in plotting theoretical MP distribution |
lambda.plus |
The upper eigenvalue bound used to cutoff noisy eigenvalues. The default of 1.6 is based on empirical data and is not optimal. |
... |
Further arguments to pass to mp.density.* function |
The functions described here are the individual components for filtering a correlation matrix using Random Matrix Theory. This is only of interest to those looking to delve deeper into the mechanics of RMT and/or creating custom behavior from these building blocks.
When using the kernel density estimate (the default), it is important to set n to a reasonable number. In the implementation, the kernel estimator's default is used which may not be optimum. For shorter windows it is suitable but larger windows (e.g. greater than 500 days) requires manually setting n. A value that seems to work well is 4096. See density for more information. In the future, this may be changed to include a heuristic to determine a good value for n.
A cleaned version of the eigenvalues is returned by clean.bouchaud. The functions mp.eigen.min/max return scalars while mp.lambdas returns a vector and mp.rho returns either a scalar or a vector.
Brian Lee Yung Rowe
# Fit the appropriate MP curve to the data. This will estimate Q and sigma. # hist is a histogram object h <- getRandomMatrix(1000, 6000) hist <- mp.density.hist(h) o <- optim(c(6,1), mp.fit.hist(hist)) # Calculate and plot the theoretical density distribution rho <- mp.theory(6,1) clean <- filter.RMT(h, c(6,1))