Copula Marginal Algorithm
Copula Marginal Algorithm
)
0
with a given
joint distribution which we represent in terms of the cdf
1
X
(r
1
, . . . , r
) P{A
1
r
1
, . . . , A
} . (2)
We call the rst step "separation". This step separates the distribution 1
X
into the pure "individual" information contained in each variable A
n
, i.e. the
marginals 1
, and the pure "joint" information of all the entries of X, i.e. the
copula 1
U
. The copula is the joint distribution of the grades, i.e. the random
variables U (l
1
, . . . , l
)
0
dened by feeding the original variables A
n
into
their respective marginal cdf
l
n
1
(A
n
) , : = 1, . . . , . (3)
Each grade l
n
has a uniform distribution on the interval [0, 1] and thus it can
be interpreted as a "non-linear z-score" of the original variables A
n
which lost
all the "individual" information of the distribution of A
n
and only preserved
its joint information with other A
n
s. To summarize, the separation step S
proceeds as follows
S : (
A
1
.
.
.
A
)1
X
7
1
, . . . , 1
(
l
1
.
.
.
l
)1
U
(4)
The above separation step can be reverted by a second step, which we call
"combination". We start from arbitrary marginal distributions
1
, in general
dierent from the above 1
, and grades U (l
1
, . . . , l
)
0
distributed ac-
cording to a chosen arbitrary copula
1
U
, which can, but does not need to, be
obtained by separation as the above 1
U
. Then we combine the marginals
1
(l
n
) , : = 1, . . . , . (5)
3
To summarize, the combination step C proceeds as follows
C :
1
, . . . ,
1
(
l
1
.
.
.
l
)
1
U
7 (
A
1
.
.
.
A
)
1
X
(6)
3 Traditional copula implementation
In general, the separation step (4) and the combination step (6) cannot be per-
formed analytically. Therefore, in practice, one resorts to Monte Carlo scenarios.
In the traditional implementation of the separation step (4), rst of all we
select a parametric -variate joint distribution 1
0
X
to model X (A
1
, . . . , A
)
0
,
whose marginal distributions 1
0
(r
n,
) , : = 1, . . . , ; , = 1, . . . , J. (7)
The grades scenarios {n
1,
, . . . , n
,
}
=1,...,
now represent simulations from the
parametric copula 1
0
U
of A.
To illustrate the traditional implementation of the separation, 1
0
X
can be
normal, and the scenarios r
n,
can be simulated by twisting independent
standard normal draws by the Cholesky decomposition of the covariance and
adding the expectations. The marginals of the joint normal distribution are
normal, and the normal cdfs 1
0
1
0
1
, . . . , 1
0
{(
n
1,
.
.
.
n
,
)}1
0
U
(8)
where for brevity we dropped the subscript , = 1, . . . , J from the curly brackets,
displaying only the generic ,-th joint -dimensional scenario.
In the traditional implementation of the combination (6), we rst generate
scenarios from the desired copula
1
0
U
, typically obtained via a parametric sep-
aration step, i.e.
1
0
U
1
0
U
and thus n
n,
n
n,
. Then we specify the desired
marginal distributions, typically parametrically
1
0
( n
n,
) , : = 1, . . . , ; , = 1, . . . , J (9)
The joint scenarios { r
1,
, . . . , r
,
}
=1,...,
display the desired copula
1
0
U
and
marginals
1
0
.
To illustrate the traditional implementation of the combination, we can use
the previously obtained normal copula scenarios and combine them with, say,
chi-square marginals with dierent degrees of freedom, giving rise to a multi-
variate correlated chi-square distribution.
We can summarize the traditional implementation of the combination step
as follows
C :
1
0
1
, . . . ,
1
0
{(
n
1,
.
.
.
n
,
)}
1
0
U
7 {(
r
1,
.
.
.
r
,
)}
1
0
X
. (10)
In practice, only a handful of parametric joint distributions is used to ob-
tain the copula scenarios that appear in (8) and (10), because in general it is
impossible to compute the marginal cdfs and thus perform the transformations
n
n,
1
(r
n,
) in (3) and (7). As a result, practitioners resort to elliptical
distributions such as normal or Student t, or a few isolated tractable distribu-
tions for which the cdfs are known, such as in Daul, De Giorgi, Lindskog, and
McNeil (2003).
An alternative approach proposed to broaden the choice of copulas involves
simulating the grades scenarios n
n,
in (10) directly from a parametric copula
1
0
U
, without obtaining them from a separation step (8). However, the paramet-
ric specications that allow for direct simulation are limited to the Archimedean
family, see Genest and Rivest (1993), and few other extensions. Furthermore,
the parameters of the Archimedean family are not immediate to interpret. Fi-
nally, simulating the grades scenarios n
n,
from the Archimedean family when
the dimension is large is computationally challenging.
To summarize, only a restrictive set of parametric copulas is used in practice,
whether they stem from parametric joint distributions or they are simulated
directly from parametric copula specications. CMA intends to greatly extends
the set of copulas that can be used in practice.
4 The copula-marginal algorithm (CMA)
Unlike the traditional approach, CMA does not require the analytical repre-
sentation of the marginals that appear in theory in (3) and in practice in (7).
Instead, we construct these cdfs non-parametrically from the joint scenarios for
1
X
. Then, it becomes easy to extract the copula. This allows us to start from
5
arbitrary parametric or non parametric joint distributions 1
X
and thus achieve
much higher exibility.
Even better, CMA allows us to extract both the marginal cdfs and the
copula from distributions that are represented by joint scenarios with fully gen-
eral, non-equal probabilities. Therefore, we can include distributions 1
ob-
tained from advanced Monte Carlo techniques such as importance sampling,
see Glasserman (2004); or from posterior probabilities driven by the Entropy
Pooling approach, see Meucci (2008); or from "Fully Flexible Probabilities" as
in Meucci (2010).
0
c
cv
Figure 1: Copula-Marginal Algorithm: separation
Let us rst discuss the separation step S. For this step, CMA takes as
input the scenarios-probabilities representation {r
1,
, . . . , r
,
; j
}
=1,...,
of a
fully general distribution 1
X
, see Figure 1, where we display a = 2-variate
distribution with J = 4 scenarios. With this input, CMA computes the grades
scenarios n
n,
as the probability-weighted empirical grades
n
n,
P
I=1
j
I
1
rr
, : = 1, . . . , ; , = 1, . . . , J, (11)
where 1
.
denotes the indicator function for the generic statement , which is
equal to 1 if is true and 0 otherwise, refer again to Figure 1.
With the grades scenarios (11) we are ready to separate both the copula and
the marginals in the distribution 1
X
.
For the copula, we associate the probabilities j
}
=1,...,
.
6
For the marginal distributions, as in Meucci (2006) CMA creates from each
grid of scenarios pairs {r
n,
, n
n,
} a function 1
{r
,u
}
that inter/extra-polates
those values, see Figure 1. This function is now the cdf of the generic :-th
variable
1
(r) 1
{r
,u
}
(r) , : = 1, . . . , . (12)
To summarize, the CMA separation step attains from the distribution 1
X
the scenarios-probabilities representation of the copula 1
U
and the inter/extra-
polation representation of the marginal cdfs 1
1
{r,u}
as follows
S
CMA
: {(
r
1,
.
.
.
r
,
); j
}1
X
7
1
{r
1
,u
1
}
, . . . , 1
{r
,u
}
{(
n
1,
.
.
.
n
,
); j
}1
U
(13)
Notice that CMA avoids the parametric cdfs 1
0
.
For the copula, we take any copula
1
U
obtained with the separation step, i.e.
a set of scenarios-probabilities { n
1,
, . . . , n
,
; j
, where n
n,|
1
( r
n,|
). Then, CMA takes
each grade scenario for the copula n
n,
and maps it into the desired combined
scenarios r
n,
by inter/extra-polation of the copula scenarios n
n,
on the grid
in a manner similar to (12), but reversing the axes
r
n,
1
{ u
, r
}
( n
n,
) , : = 1, . . . , ; , = 1, . . . , J. (14)
Notice that the inter/extra-polation (14) replaces the computation of the inverse
cdf
1
1
as follows
C
CMA
:
1
, . . . ,
1
{(
n
1,
.
.
.
n
,
); j
}
1
U
7 {(
r
1,
.
.
.
r
,
); j
}
1
X
(15)
From a computational perspective, both the separation step (13) and the
combination step (15) are extremely ecient, as they run in fractions of a second
even in large markets with very large numbers of scenarios. Please refer to
the code available at http://symmys.com/node/335 and the appendix for more
details.
7
5 Case study: panic copula
Here we apply CMA to generate a large dimensional panic copula for stress-
testing and portfolio optimization. The code for this case study is available at
http://symmys.com/node/335.
Consider a -dimensional vector of nancial random variables X (A
1
, . . . , A
)
0
,
such as the yet to be realized returns of the = 500 stocks in the S&P 500.
Our aim is to construct a panic stress-test joint distribution
1
X
for X.
To do so, we rst introduce a distribution 1
X
which is driven by two separate
sets of random variables X
(c)
and X
()
, representing the calm market and the
panic-stricken market. From 1
X
we will extract the panic copula, which we will
then glue with marginal distributions tted to empirical data.
Accordingly, we rst dene the joint distribution 1
X
with a few components,
as follows
X
J
(1
B) X
(c)
+B X
()
, (16)
where 1
)
0
are the
calm-market drivers, which are normally distributed with expectation a -
dimensional vector of zeros 0
,
2
) . (17)
The second component, X
()
(A
()
1
, . . . , A
()
)
0
are panic-market drivers inde-
pendent of X
(c)
, with high homogeneous correlations r amongst each other
X
()
N
0
.
.
.
0
1 r
.
.
.
r 1 r
.
.
. r 1
. (18)
The variable B (1
1
, . . . , 1
)
0
triggers panic. More precisely, B selects the
panic downside endogenously a-la Merton (1974)
1
n
1 if A
()
n
<
1
(/)
0 otherwise
(19)
where is the standard normal cdf and / is a low threshold probability.
The parameters (
2
, r, /) that specify the joint distribution (16) have an
intuitive interpretation. The correlation matrix
2
characterizes the dependence
structure of the market in times of regular activity. This matrix can be obtained
by tting a normal copula to the realizations of X that occurred in non-extreme
regimes, as ltered by the minimum volume ellipsoid, see e.g. Meucci (2005)
for a review and the code. The homogeneous correlation level r determines
the dependence structure of the market in the panic regime. The probability /
determines the likelihood of a high-correlation crash event. Therefore, r and /
steer the eect of a non-symmetric panic correlation structure of an otherwise
calm-market correlation j
2
and are set as stress-test parameters.
8
The highly non-symmetrical joint distribution 1
X
dened by (16) is not
analytically tractable. Nonetheless, we can easily generate a large number J
of equal-probability joint scenarios {r
1,
, . . . , r
,
}
=1,...,
from this distribu-
tion, and for enhanced precision impose as in Meucci (2009) that the rst two
moments of the simulations match the theoretical distribution.
StockreturnsX=(X
1
,X
2
) Pani ccopulaU=(U
1
, U
2
)
Equall yweightedportfolioreturnpdf
normal
di stribution
:panic
Figure 2: Panic copula, normal marginals, and skewed portfolio of normal re-
turns
Due to the non-symmetrical nature of the panic triggers (19), this distribu-
tion has negative expectations, i.e.
1
r
n,
< 0. Now we perform a second
step to create a more realistic distribution that compensates for the exposure
to downside risk. To this purpose, we use the Entropy Pooling approach as in
Meucci (2008). Accordingly, we twist the probabilities j
r
n,
0. In practice this amount to solving
the following minimization
{ j
} argmin
{}
P
ln(Jj
) (20)
such that
P
r
n,
0,
P
1, j
0,
see Meucci (2008) for more details. Now the scenarios-probabilities {r
1,
, . . . , r
,
; j
}
represent a panic distribution 1
X
adjusted for risk-premium.
9
Using the separation step of CMA (13), we produce the scenario-probability
representation {n
1,
, . . . , n
,
; j
: U 7U, (22)
10
where is a matrix. Unfortunately, the transformed entries of Uare not
the grades of a copula. This is easily veried because in general (22) transforms
the copula domain, which is the unit cube, into a parallelotope that trespasses
the boundaries of the unit cube. Furthermore, the marginal distribution of the
transformed variable U are not uniform.
In order to perform transformations on copulas, we propose to simply use
alternative, not necessarily uniform, normalizations for the copulas, operate the
transformation on the normalized variables, and then map the result back in
the unit cube.
To be concrete, let us focus on the linear transformation (22). First, we
normalize each grade to have a standard normal distribution, instead of uniform,
i.e. we dene the following random variables
7
n
1
(l
n
) N(0, 1) . (23)
This is a special case of a combination step (6), where
1
. Then we
operate the linear transformation (22) of the normalized variables
: Z 7
Z Z. (24)
Finally, we map the transformed variables
Z back into the unit cube space of
the copula by means of the marginal cdfs of
Z.
l
n
1
2
(
e
7
n
) U([0, 1]) . (25)
This step entails performing a separation step (4) and then only retaining the
copula. This way we obtain the distribution of the grades
1
U
1
U
We summarize the copula transformation process in the following diagram
1
U
T
1
U
C
S
1
Z
T
1
Z
(26)
It is trivial to generalize the above steps and diagram to arbitrary non-linear
transformations T. It is also possible to consider non-normal standardizations
of the grades in the combination step (23), which can be tailored to the desired
transformation T. The theory of the most suitable standardization for a given
transformation is the subject of a separate publication.
In rare cases, the above copula transformations can be implemented analyt-
ically. However, the family of copulas that can be transformed analytically is
extremely small, and depends on the specic transformation. For instance, for
linear transformations we can only rely on elliptical copulas.
Instead, to implement copula transformations in practice, we rely on CMA,
which allows us to perform arbitrary combination steps and separation steps,
which are suitable for fully general transformations of arbitrary copulas.
To illustrate how to transform a copula using CMA, we perform a special
case of the linear transformation in (24), namely a rotation on the panic
11
Pani ccopula Rotatedpaniccopul a
:panic
Figure 3: Copula-Marginal Algorithm for copula transformations: rotation of
panic copula
copula introduced in Section 5. In the bivariate case we can parametrize the
rotations by an angle 0 as follows
cos 0 sin0
sin0 cos 0
. (27)
In Figure 3 we display the result for 0 ,2: the non-symmetric panic scenarios
now aect positively the second security. For more details, documented code is
available at http://symmys.com/node/335.
7 Conclusions
We introduced CMA, or "copula-marginal algorithm", a technique to generate
new exible copulas for risk management and portfolio management.
CMA generates exible copulas and glues them with arbitrary marginals us-
ing the scenarios-probabilities representation of a distribution. CMA generates
many more copulas than the few parametric families used in traditional copula
implementations. For instance, with CMA we can generate large-dimensional,
downside-only panic copulas. CMA also allows us to perform arbitrary trans-
formations of copulas, despite the fact that copulas are only dened on the unit
cube. Finally, unlike in traditional approaches to copula implementation, the
probabilities of the scenarios are not assumed equal. Therefore CMA allows us
to leverage techniques such as importance sampling and Entropy Pooling.
Documented code for CMA is available at http://symmys.com/node/335.
12
References
Brigo, D., A. Pallavicini, and R. Torresetti, 2010, Credit Models and the Crisis:
A Journey Into CDOs, Copulas, Correlations and Dynamic Models (Wiley).
Cherubini, U., E. Luciano, and W. Vecchiato, 2004, Copula Methods in Finance
(Wiley).
Daul, S., E. De Giorgi, F. Lindskog, and A. McNeil, 2003, The grouped
t-copula with an application to credit risk, Working Paper Available at
http://ssrn.com/abstract=1358956.
Durrleman, V., A. Nikeghbali, and T. Roncalli, 2000, Which copula is the right
one?, Working Paper.
Embrechts, P., McNeil A., and D. Straumann, 2000, Correlation: Pitfalls and
alternatives, Working Paper.
Embrechts, P., C. Klueppelberg, and T. Mikosch, 1997, Modelling Extremal
Events (Springer).
Embrechts, P., F. Lindskog, and A. J. McNeil, 2003, Modelling dependence
with copulas and applications to risk management, Handbook of heavy tailed
distributions in nance.
Genest, C., and R. Rivest, 1993, Statistical inference procedures for bivariate
Archimedean copulas, Journal of the American Statistical Association 88,
1034 1043.
Glasserman, P., 2004, Monte Carlo Methods in Financial Engineering
(Springer).
Jaworski, P., F. Durante, W. Haerdle, and T. (Editors) Rychlik, 2010, Copula
Theory and its Applications (Springer, Lecture Notes in Statistics - Proceed-
ings).
Li, D. X., 2000, On default correlation: A copula function approach, Journal of
Fixed Income 9, 4354.
Merton, R. C., 1974, On the pricing of corporate debt: The risk structure of
interest rates, Journal of Finance 29, 449470.
Meucci, A., 2005, Risk and Asset Allocation (Springer) Available at
http://symmys.com.
, 2006, Beyond Black-Litterman in practice: A ve-step recipe to input
views on non-normal markets, Risk 19, 114119 Article and code available at
http://symmys.com/node/157.
, 2008, Fully Flexible Views: Theory and practice, Risk 21, 97102
Article and code available at http://symmys.com/node/158.
13
, 2009, Simulations with exact means and covariances, Risk 22, 8991
Article and code available at http://symmys.com/node/162.
, 2010, Historical scenarios with Fully Flexible Probabilities, GARP
Risk Professional - "The Quant Classroom by Attilio Meucci" December, 40
43 Article and code available at http://symmys.com/node/150.
, 2011, A short, comprehensive, practical guide to copulas, GARP Risk
Professional - "The Quant Classroom by Attilio Meucci" October, 5459 Ar-
ticle and code available at http://symmys.com/node/351.
, Y Gan, A. Lazanas, and B. Phelps, 2007, A portfolio mangers guide
to Lehman Brothers tail risk model, Lehman Brothers Publications.
Nelsen, R. B., 1999, An Introduction to Copulas (Springer).
14
A Appendix
The appendix below can be skipped at rst reading.
A.1 Separation: from joint to copula/marginal
Let us rst introduce some terminology. Consider a set of J numbers {.
} and
the set of all permutations of the rst J integers ({1, . . . , J}).
Sorting {.
= .
:
. (29)
where .
:
is the ,-th smallest number among {.
}.
Sorting {.
}.
To illustrate, consider an example with J 4 entries
{.
5.2
7.4
2.3
1.7
7a
a
1
4
a
2
3
a
3
1
a
4
2
, /
/
1
3
/
2
4
/
3
2
/
4
1
. (31)
Then
.
o1
= .
4
= 1.7 = .
1:4
.
o
2
= .
3
= 2.3 = .
2:4
.
o
3
= .
1
= 5.2 = .
3:4
.
o
4
= .
2
= 7.4 = .
4:4
.
1
5.2 is the /
1
3-rd smallest
.
2
7.4 is the /
2
4-th smallest
.
3
2.3 is the /
3
2-nd smallest
.
4
1.7 is the /
4
1-st smallest
(32)
Now consider a set of scenarios-probabilities {r
1,
, . . . , r
,
; j
} that rep-
resents the fully general joint distribution )
). For the generic :-th entry, rst we sort, generating the sort-
ing/ranking permutations (28) and (30)
{r
n,
}
=1,...,
7a, /. (33)
Then we dene the sorted entries r
n,
and the respective sorted cumulative
probabilities n
,n
using the permutation a in (33) as follows
r
n,
r
n,o
, n
n,
P
s=1
j
o
. (34)
15
Then the :-th empirical cdf 1
=1
j
1
[r
,)
satises
1
(r
n,
) = n
n,
. (35)
Therefore the marginal cdfs at arbitrary points are represented by the inter/extra-
polation of a grid
1
(r) 1
{r
,u
}
(r) . (36)
As for the :-th grade n
n,
1
(r
n,
) it satises n
n,
=
P
rr
j
s
= n
n,b
,
where , is the permutation dened in (33).
Repeating for all the entries : = 1, . . . , of the random variable X
(A
1
, . . . , A
)
0
we obtain scenarios-probabilities representation of the copula
)
U
n
n,b
, j
.. (37)
To illustrate, consider a 2-variate distribution
)
X
{r
n,
}
5.2 3.6
7.4 2.5
2.3 1.9
1.7 6.4
, {j
0.2
0.4
0.3
0.1
(38)
Then for the marginal
{r
n,
}
1.7 1.9
2.3 2.5
5.2 3.6
7.4 6.4
, {n
n,
}
0.1 0.3
0.4 0.7
0.6 0.9
1.0 1.0
(39)
Therefore (35) becomes
1
1
(1.7) = 0.1, 1
1
(2.3) = 0.4, 1
1
(5.2) = 0.6, 1
1
(7.4) = 1.0 (40)
1
2
(1.9) = 0.3, 1
2
(2.5) = 0.7, 1
2
(3.6) = 0.9, 1
2
(6.4) = 1.0 (41)
As for the copula, (37) becomes
)
U
{n
n,
}
0.6 0.9
1.0 0.7
0.4 0.3
0.1 1.0
, {j
0.2
0.4
0.3
0.1
(42)
Commented code for the separation algorithm is available at http://symmys.com/node/335.
A.2 Combination: from copula/marginal to joint
Consider a generic scenario-probabilities representation {n
n,
, j
,
where the number of elements 1
n
in the grid can, but need not be, equal to the
16
number of scenarios J. To select such scenarios several approaches are possible.
For instance, if the quantile function is readily available, one can choose a grid
equally-spaced in probability
j
n,1
1
1
Y
(c)
.
.
.
j
n,|
1
1
Y
(c + (/ 1) ) (43)
.
.
.
j
n,1
1
1
Y
(1 c) ,
where c 1 and is set to solve 1 c c + (1 1) .
Alternatively, an equally-spaced grid between lower and upper quantile
j
n,1
1
1
Y
(c)
.
.
.
j
n,|
j
n,1
+ (/ 1)
n
(44)
.
.
.
j
n,1
1
1
Y
(1 c) ,
where again c 1, the lower and upper quantile are computed by quadrature
and is set to solve 1
1
Y
(1 c) = 1
1
Y
(c) + (1 1)
n
.
Alternatively, { j
n,|
} can be Monte Carlo or empirical scenarios from the
marginal distribution 1
Y
.
Then we compute the grid { n
n,|
, j
n,|
}
|=1,...,1
, where n
n,|
1
Y
( j
n,|
).
Next, we dene the joint scenarios by inter/extra-polation
j
n,
1
{ u
}
(n
n,
) . (45)
The probabilities {j