yanyachen / fincovregularization Goto Github PK
View Code? Open in Web Editor NEWCovariance Matrix Estimation and Regularization for Finance
License: GNU General Public License v2.0
Covariance Matrix Estimation and Regularization for Finance
License: GNU General Public License v2.0
When using the RiskParity function to calculate the weight, I found that when I adjusted the order of the column in the portfolio, the calculation results were different. What is the cause of this?
Thanks.
Hi @yanyachen,
I ran into this issue with the RiskParity
function: it seems not to give the proper solution because the risk contributions are often different. See the example below:
> set.seed(123)
> N <- 10
> V <- matrix(rnorm(N^2), nrow = N)
> Sigma <- cov(V)
> Sigma
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.90970402 0.57189548 -0.36040701 0.33848349 -0.35996343 0.07397388
[2,] 0.57189548 1.07759637 -0.54819970 0.14851410 -0.28320034 0.09677007
[3,] -0.36040701 -0.54819970 0.86640579 -0.21461746 0.02283195 -0.41904942
[4,] 0.33848349 0.14851410 -0.21461746 0.27804782 0.04254683 0.04562792
[5,] -0.35996343 -0.28320034 0.02283195 0.04254683 1.17184557 0.14731463
[6,] 0.07397388 0.09677007 -0.41904942 0.04562792 0.14731463 0.73349814
[7,] -0.20064108 0.07950125 0.37481303 -0.30752186 -0.35873804 -0.10511911
[8,] 0.62395270 0.47961483 -0.34824164 0.21937911 -0.35186843 0.12919759
[9,] -0.07227240 -0.10564689 0.39166263 -0.06609896 0.01954409 -0.05439291
[10,] -0.20514629 -0.32292043 0.23321381 0.08893636 -0.20078316 -0.61805678
[,7] [,8] [,9] [,10]
[1,] -0.20064108 0.6239527 -0.07227240 -0.20514629
[2,] 0.07950125 0.4796148 -0.10564689 -0.32292043
[3,] 0.37481303 -0.3482416 0.39166263 0.23321381
[4,] -0.30752186 0.2193791 -0.06609896 0.08893636
[5,] -0.35873804 -0.3518684 0.01954409 -0.20078316
[6,] -0.10511911 0.1291976 -0.05439291 -0.61805678
[7,] 0.87683045 0.2829227 0.19963360 -0.30853439
[8,] 0.28292270 0.9910352 -0.12847576 -0.38090856
[9,] 0.19963360 -0.1284758 0.29976891 -0.01999857
[10,] -0.30853439 -0.3809086 -0.01999857 1.14251522
> portfolio_weights <- RiskParity(Sigma)
> portfolio_weights
[1] 0.0884 0.0679 0.0828 0.0925 0.1069 0.1939 0.1566 0.0071 0.0161 0.1879
> risk_contributions <- portfolio_weights * (Sigma %*% portfolio_weights)
> risk_contributions
[,1]
[1,] 0.0026414012
[2,] 0.0023111850
[3,] 0.0008561889
[4,] 0.0028117478
[5,] 0.0013385436
[6,] 0.0015615829
[7,] 0.0025180352
[8,] 0.0003146647
[9,] 0.0005750063
[10,] 0.0017862258
I believe this issue might be caused by your choice of initial value:
FinCovRegularization/R/RiskParity.R
Line 26 in cd3ff5b
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.