PDA

View Full Version : Help with Monte Carlo Simulation - Please!


Mad Actuary
07-13-2005, 08:45 AM
I am looking at currency flucuations with respect to the Cdn $. Specifically what the probability of all the major currencies all depreciating at the same time with respect to the Cdn$. If currencies were all independent, my calc should be Pr(US)*Pr(EURO)*Pr(Yen)*etc. Problem is, currencies are not independent. How can I calculate this? I have probabilites on each currency alone deprec. from historical data and also the probability of all currencies moving together, but my boss is wondering if we can pull it all together to provide, in one number, the probability of all currencies depreciating together 5% or 10%. Can this be done? Or am I way off? Any help would be greatly appreciated. Thanks

One approach is this:
If you develop the marginal densities for each of the currencies and a correlation matrix for the currencies, you can use the Normal copula and Monte Carlo Simulation to generate a large sample easily. From that sample, you can estimate the probability of just about any event you want. See Wang, "Aggregation of Correlated Risk Portfolios: Models & Algorithms". You can get this paper here: http://www.casact.org/cotor/wang.htm

Brad

I've decided to try the Monte Carlo simulation suggested above, though it is a bit above my head. I am wondering if anybody can clear up some of this for me. In the Wang paper, page 13-14, Step 2 of the algorithm's it mentions to generate a column vector of indep. standard normal variables. I assume this a random vector of any values from the normal table? If not, what exactly does this mean? Do I get the data from my data set of 8 currencies?

Also, how do I compute the marginal densities of my currency data?

Brad Gile
07-13-2005, 09:38 AM
I've decided to try the Monte Carlo simulation suggested above, though it is a bit above my head. I am wondering if anybody can clear up some of this for me. In the Wang paper, page 13-14, Step 2 of the algorithm's it mentions to generate a column vector of indep. standard normal variables. I assume this a random vector of any values from the normal table? If not, what exactly does this mean? Do I get the data from my data set of 8 currencies?

Also, how do I compute the marginal densities of my currency data?

1. To generate a column of standard normal values,simply generate values of NormSinv(X), where the X values are Uniformly distributed on (0,1) generated either by the Excel Rand function or the VBA Rnd function (preferred).

2. Marginal densities-actually, you want the marginal cumulative distributions. These distributions can be estimated by fitting to your data set or you can just use a discrete one directly from probabilities calculated from your data.


HTH,
Brad

campbell
07-13-2005, 09:47 AM
Something that may be a little easier:

Try the Excel add-in NTRand:
http://www.numtech.com/NtRand/

It will generate correlated random variates... if that's what you want. You give it mean, std dev., and correlation matrix, and it will do the rest. The package even comes with an example spreadsheet where it's set up.

The name of the function that does this in the package is NtRandMultiNorm. The example should appear in the spreadsheet NtRand3.xls, I believe.

Mad Actuary
07-13-2005, 09:50 AM
Thanks Alot Brad!
I assumed it would be randomly generated numbers and I did use the random function. I guess my question regarding marginal cdf's is at Step 4 (pg 15-Wang paper) in the simulation algorithm. I'm assuming everything I did previously is correct and I now have many values for u. Step 4 sets X=Finv(u). Since I don't have the Finv function I was wondering how I calculate my X's using my raw data? Am I right in assuming that once I have a data set of X's, to answer my original question I simply calculate how many of my simulations are greater than a 5% change?

I'm sorry these questions are trivial but it's been some time since I've worked with probability functions and my brain is slow to remember.

Mad Actuary
07-14-2005, 09:34 AM
Could somebody confirm if my reasoning makes sense or if I'm off on this!
I calculated a B triangle matrix from my correlation matrix. Generate a bunch of random values from the normal distribution in a vector(Y) and multiplied B*Y=Z as mentioned in the Wang paper. However, instead of calculating u's from normal tables and then using the u's and F(inv) function to calculate my X's, I simply used my calculated Z's to produce X's by X=mu+Z*stdev. I'm hoping this is the proper method. My logic being that, u=phi(Z) and X=F(inv)(u), therefore F(inv)(u)=phi(inv)(u)=phi(inv)(phi(Z))=Z

Can somebody confirm if this ok? Thank You!

Brad Gile
07-14-2005, 09:47 AM
Could somebody confirm if my reasoning makes sense or if I'm off on this!
I calculated a B triangle matrix from my correlation matrix. Generate a bunch of random values from the normal distribution in a vector(Y) and multiplied B*Y=Z as mentioned in the Wang paper. However, instead of calculating u's from normal tables and then using the u's and F(inv) function to calculate my X's, I simply used my calculated Z's to produce X's by X=mu+Z*stdev. I'm hoping this is the proper method. My logic being that, u=phi(Z) and X=F(inv)(u), therefore F(inv)(u)=phi(inv)(u)=phi(inv)(phi(Z))=Z

Can somebody confirm if this ok? Thank You!

Sounds like you are assuming that each of the currencies is normally distributed. If so, what you describe sounds right, and it should produce a "reasonable" answer unless your underlying data are heavily skewed.

One thing you will want to do as a check after you have generated a large sample is to calculate the correlation matrix of the sample and compare that to the underlying correlation matrix that you assumed. The two should be in close agreement.


Brad

Mad Actuary
07-14-2005, 09:48 AM
I am assuming normal distributions for each currency as they don't appear to be skewed. Thanks for all your help Brad!

campbell
07-14-2005, 10:50 AM
Of course, you would not have to do a Cholesky decomposition yourself if you used NtRand (my post earlier).

And I agree with Brad that you should check that the sample correlation matrix (and means and std. devs) match well with your desired parameters. It can also give you a little handle of what kind of sample error you're getting, or if you screwed up anywhere in your calculations.