Page 1 of 1
Monte Carlo & Cholesky Decomposition
Posted: October 18th, 2002, 6:53 am
by nipon
I'm trying to simulate stocks (may be 3 to 4 stocks) behaviour base on the monte carlo simulation. I'm not quiet sure how this could be done. is anyone done this before on the excel. Can you send this to me to
nsan5@hotmail.comthank you
Monte Carlo & Cholesky Decomposition
Posted: October 18th, 2002, 8:27 am
by gjlipman
Hi Nipon,I've attached a file which shows how it can be done. I've used cholesky decomposition to get factors, the worked out 4 appropriately correlated random variables. email me if you don't understand something ()(I have fixed up the error in the matrix - thanks Skaca for picking it up.)
Monte Carlo & Cholesky Decomposition
Posted: October 20th, 2002, 3:53 pm
by Skaca
gjlipman,I've found a small error in the decomposition of the matrix (stock 3 and 4 would not have the correct correlation). The corrected file is attached...Skaca
Monte Carlo & Cholesky Decomposition
Posted: October 23rd, 2002, 5:37 am
by tbwong
Pls refer to the VBA code for Cholesky decomposition:Function nCholesky(Correlation) 'Creating the Cholesky Decomposition Factors Dim mRs As Single mRs = nCountRC(Correlation, True) 'Correlation.Rows.Count Dim aCholesky() As Double 'Cholesky Decomposition Matrix ReDim aCholesky(1 To mRs, 1 To mRs) As Double For i = 1 To mRs aCholesky(i, 1) = Correlation(i, 1) Next i For i = 2 To mRs For j = 2 To i If i = j Then aCholesky2 = 0 For k = 1 To j - 1 aCholesky2 = aCholesky2 + aCholesky(i, k) ^ 2 Next k aCholesky(i, j) = Sqr(1 - aCholesky2) Else aCholeskyA = 0 For k = 1 To j - 1 aCholeskyA = aCholeskyA + aCholesky(i, k) * aCholesky(j, k) Next k aCholesky(i, j) = (Correlation(i, j) - aCholeskyA) / aCholesky(j, k) End If Next j Next i nCholesky = aCholeskyEnd FunctionHowever, I think u need to validate if the correlation matrix is positive definite before passing that in. Im havent figure out how to validate it yet. Is anyone can help me out with that???RgdsRocco
Monte Carlo & Cholesky Decomposition
Posted: October 23rd, 2002, 6:43 am
by gjlipman
There is also a very handy bit of code in PWOQF p935 to find the cholesky decomposition of a matrix.A matrix is positive definite if and only if all eigenvalues are positive. Any true correlation matrix will be positive definite - if it isn't positive definite then you have some small inconsistency. That said, if you work out all correlation coefficients using historical data, you may (due to sampling error) get some small negative eigenvalues. Do you have any functions handy to work out the eigenvalues of the matrix? If so, that is possibly the easiest way to check.
Monte Carlo & Cholesky Decomposition
Posted: October 23rd, 2002, 7:15 am
by tbwong
Thanks for the clarification. However, my main concern is actually how do workout eigenvalues of a n*n matrix in excel. Has anyone got an existing program for that?
Monte Carlo & Cholesky Decomposition
Posted: October 23rd, 2002, 8:59 am
by Tanaka
Try the following free Excel add-in named PopTools, it contains what you are looking for, and a lot of other useful stuff:PopToolsTanaka
Monte Carlo & Cholesky Decomposition
Posted: August 10th, 2004, 1:53 pm
by mrmelchi
Monte Carlo & Cholesky Decomposition
Posted: August 11th, 2004, 5:27 am
by yomi
The corrected website for the vba code ishttp://
www.geocities.com/WallStreet/9245/