Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Computational Finance Zvi Wiener 02-588-3049 http://pluto.mscc.huji.ac.il/~mswiener/zvi.html CF-3 Bank Hapoalim Jun-2001 Plan 1. Hypothesis test 2. Maximal Likelihood estimate 3. Multidimensional VaR, contour plots 4. Monte Carlo type methods Zvi Wiener CF3 slide 2 Hypothesis tests Given a population, we would like to perform a test in order to accept or reject the claim that it is distributed according to some rule (for example normal or normal with some mean and standard deviation). Zvi Wiener CF3 slide 3 Pearson goodness of fit test Is based on calculating the sample moments and then comparing the number of observations in more or less equally full bins. The comparison of actual number of points versus the expected frequency allows to estimate the likelihood of the distribution to belong to the suspected class. Zvi Wiener CF3 slide 4 Pearson goodness of fit test For large samples the following Q statistics follows a Chi Square distribution with m-1 degrees of freedom. Here m – the number of bins. fk – is the actual number of points in bin k, ek is the expected number of points. ( f k ek ) 2 Q ek k 1 m Zvi Wiener CF3 slide 5 The Kolmogorov-Smirnov test Here we compare the maximal distance between actual and proposed cumulative distribution. 1. Numerical Recepies in C, second edition, p. 623-625. 2. Mathematica in Education and Research Journal, vol. 5:2, 1996, p. 23-30 by David K. Neal. Zvi Wiener CF3 slide 6 The Kolmogorov-Smirnov test Define test statistics by D n sup F ( x) G( x) Here n is the number of sample points, F(x) the sample and G(x) the expected cumulative distribution. For large n distribution of D converges to a distribution Y (see Degroot 1986). P(Y t ) 2 (1) e i 2i 2t 2 i 1 Zvi Wiener CF3 slide 7 The Kolmogorov-Smirnov test data -2 -1 hypothesis 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 1 2 -2 -1 1 2 difference 0.08 0.06 0.04 0.02 -2 -1 1 2 -0.02 -0.04 Zvi Wiener CF3 slide 8 Maximal Likelihood Zvi Wiener CF3 slide 9 Example Your portfolio is exposed to two independent (correlation =0) risk factors. Each one is uniformly distributed between –1 and 1 for a given time horizon. What is your VaR95% for the same horizon? Zvi Wiener CF3 slide 10 Example Probability density B A Zvi Wiener CF3 slide 11 2 dimensional risk B 1 -1 1 A -1 Probability of 5% Zvi Wiener CF3 slide 12 Example The total probability is 1, the area of the rectangle is 4, so the height is 0.25. We are looking for x, such that 1 21 x 1 0.95 2 4 x=0.6325, and VaR95%=2-x=1.3675 Zvi Wiener CF3 slide 13 Ovals Consider a portfolio managed versus benchmark. The benchmark has duration T and includes only government bonds (no credit risk). A manager has two degrees of freedom. He can choose non-government bonds and have a duration mismatch. Denote the actual duration by T+q and by a – % of the assets invested in non-government bonds. Zvi Wiener CF3 slide 14 Ovals Denote by r – the current yield on treasuries Denote by L – LIBOR (for simplicity we assume a flat term structure). Denote by dr and dL the possible change in each risk factor during a short period of time. Zvi Wiener CF3 slide 15 Ovals The value of the benchmark today is 1. rT rT Benchmark 0 e e quantity discount factor The value of the benchmark tomorrow will be rT ( r dr )(T dT ) Benchmark1 e e For short time intervals we ignore dT. Zvi Wiener CF3 slide 16 Ovals Similarly the dollar P&L of the portfolio will be P1 P0 ae dL (T q ) (1 a)e dr (T q ) We ignore convexity and carry effects. To measure relative performance we use P1 P0 ae B1 B0 Zvi Wiener dL (T q ) CF3 (1 a)e drT e dr (T q ) slide 17 Assume that dr and dL are jointly normal and use delta approach. Then the gradient vector is T (1 a)(T q) grad a(T q) One should also check the impact of the second derivative. For a given variance covariance matrix of the risk factors one can easily construct the level curves of the total risk on the q, a plane. Zvi Wiener CF3 slide 18 Assuming correlation of 26% between dr and dL we have: portf / benchm grad ..grad The resulting contour plot shows the levels of risk for any potential position as seen according to today’s data. Zvi Wiener CF3 slide 19 VaR=1bp Ovals 0.6 VaR=2bp 0.4 0.2 spread 0 -0.2 -0.4 -0.6 0 Zvi Wiener 0.1 0.2 0.3 CF3 0.4 0.5 slide 20 Plan 1. Monte Carlo Method 2. Variance Reduction Methods 3. Quasi Monte Carlo 4. Permuting QMC sequences 5. Dimension reduction 6. Financial Applications simple and exotic options American type prepayments Zvi Wiener CF3 slide 21 Monte Carlo 1 0.5 -1 0.5 -0.5 1 -0.5 -1 Zvi Wiener CF3 slide 22 Monte Carlo Simulation 15 10 5 10 20 30 40 -5 -10 -15 Zvi Wiener CF3 slide 23 Introduction to MC The idea is very simple 1 0 N 1 f ( x)dx f ( xi ) N i 1 Hopefully due to the strong law of large numbers the approximation is good. Zvi Wiener CF3 slide 24 Introduction to MC 1 0 N 1 f ( x)dx f ( xi ) N i 1 How to determine a well distributed sequence? How one can generate such a sequence? How to measure precision? Zvi Wiener CF3 slide 25 Speed of Convergence I f ( x)dx [ 0 ,1]s From the central limit theorem the error of approximation is distributed normal with mean 0 and standard deviation N 2 f ( x) I dx 2 [ 0 ,1]s Zvi Wiener CF3 slide 26 Regular Grid An alternative to MC is using a regular grid to approximate the integral. Advantages: The speed of convergence is error~1/N. All areas are covered more uniformly. There is no need to generate random numbers. Disadvantages: One can’t improve it a little bit. It is more difficult to use it with a measure. Zvi Wiener CF3 slide 27 Variance Reduction Let X() be an option. Let Y be a similar option which is correlated with X but for which we have an analytic formula. Introduce a new random variable X ( ) X ( ) Y ( ) Y Zvi Wiener CF3 slide 28 Variance Reduction The variance of the new variable is var[ X ] var[ X ] 2 cov[ X , Y ] var[Y ] 2 If 2cov[X,Y] > 2var[Y] we have reduced the variance. Zvi Wiener CF3 slide 29 Variance Reduction The optimal value of is cov[ X , Y ] var[Y ] * Then the variance of the estimator becomes: var[ X * ] (1 XY )var[ X ] 2 Zvi Wiener CF3 slide 30 Variance Reduction Note that we do not have to use the optimal * in order to get a significant variance reduction. Zvi Wiener CF3 slide 31 Multidimensional Variance Reduction A simple generalization of the method can be used when there are several correlated variables with known expected values. Let Y1, …, Yn be variables with known means. Denote by Y the covariance matrix of variables Y and by XY the n-dimensional vector of covariances between X and Yi. Zvi Wiener CF3 slide 32 Multidimensional Variance Reduction Then the optimal projection on the Y plane is given by vector: * TXY Y1 The resulting minimum variance is var[ X * ] (1 RXY )var[ X ] 2 where RXY 2 Zvi Wiener XY T XY 1 Y var[ X ] CF3 slide 33 Variance Reduction • Antithetic sampling • Moment matching/calibration • Control variate • Importance sampling • Stratification Zvi Wiener CF3 slide 34 Monte Carlo • Distribution of market factors • Simulation of a large number of events • P&L for each scenario • Order the results • VaR = lowest quantile Zvi Wiener CF3 slide 35