I'm trying to generate a set of conditional samples from a Gaussian copula. However, after implementing (what it seemed to me the right process), I'm observing a weird behavior of the conditioned variables.

Lets say, there are 3 variables: $X_1$, $X_2$ and $X_3$. Each of them is defined by its parametric cumulative density function: $F_{X_1}$, $F_{X_2}$ and $F_{X_3}$ and by a correlation matrix $\mathbf{ \rho } \in \mathbb{R}^{3x3}$.

Drawing samples of a random gaussian copula would involve:

  1. Draw N samples from a $Z = MVN([0,0,0], \Sigma = \rho)$, where $Z = \{Z_1, Z_2, Z_3\}$
  2. Convert those variables to a unit cube: as $ U_i = F_{N(0,1)}(Z_i)$, being $F_{N(0,1)}$ the cdf of a standard normal distribution.
  3. Back-transform them to each of the marginals as : $Sample_i = F_{X_i}^{-1}(U_i)$.

Now, I tried to extend it to the case in which one of the samples is conditioned, for example, $X_3 = X_3^{cond}$:

  1. First I transformed the conditional value to a standard Gaussian: $ Z_3^{cond} = F_{N(0,1)}^{-1}(F_{X_3}(X_3^{cond}))$
  2. Generate a set of N samples from a conditional multivariate normal (initially $\mu = [0,0,0]$ and $\rho = \Sigma$) : $Z_i = MVN(\hat{\mu}, \hat{\Sigma})$ where $i=1,2$ and $\{\hat{\mu}, \hat{\Sigma}\}$ are the mean and covariance matrix of the conditional gaussian distribution. Which can be calculated as: $$\hat{\mu} = \Sigma_{12} \cdot \Sigma_{22}^{-1} \cdot Z_3^{cond} $$ $$ \hat{\Sigma} = \Sigma_{12} - \Sigma_{12} \cdot \Sigma_{22}^{-1} \cdot \Sigma_{21}$$ when we split the correlation matrix in $ \rho = \begin{bmatrix} \Sigma_{11} & \Sigma_{12} \\ \Sigma_{21} & \Sigma_{22} \end{bmatrix} $. This multivariate distribution will generate normally distributed samples with the provided correlation matrix and with the condition that $Z_3 = Z_3^{cond}$.
  3. Then proceed as in the normal gaussian copula: Convert the 2 free variables to the unit cube, $ U_i = F_{N(0,1)}(Z_i)$ and back transform them to their marginal distributions $Sample_i = F_{X_i}^{-1}(U_i)$.

An example of this process can be provided as: $$ X_a \sim N(\mu = 100, \sigma = 30) $$ $$ X_b \sim Lognormal(s = 0.5, loc = 1, scale = 100)^* $$ $$ X_c \sim N(\mu = 30, \sigma = 10) $$

$$ \rho = \begin{bmatrix} 1 & 0.2 & 0.5 \\ 0.2 & 1 & 0.9 \\ 0.5 & 0.9 & 1 \\ \end{bmatrix} $$ *Note: Notation as in python scipy https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html

By conditioning $X_c = 10 $ and drawing 5000 samples as previously described. I observed that the correlation between $X_a^{sample}$ and $X_b^{sample}$ has turned negative, $\rho_{X_a^{sample}, X_b^{sample}}^{spearman} = - 0.662$

Here there are two images showing the joint distribution X_a and X_b by sampling the copula without conditioning and conditional to X_c = 10

Joint distribution X_a and X_b from an Un-Conditional Copula sample

Joint distribution X_a and X_b from a Conditional Copula sample X_c = 10

My question is: Is there something wrong in this procedure to sample a conditional gaussian copula?

This negative correlation is coming from the conditioning of the correlation matrix: $ \hat{\Sigma} = \Sigma_{12} - \Sigma_{12} \cdot \Sigma_{22}^{-1} \cdot \Sigma_{21}$ which in the example provided would be $ \hat{\Sigma} = \begin{bmatrix} 1 & 0.2 \\ 0.2 & 1 \end{bmatrix} - \begin{bmatrix} 0.5 \\ 0.9 \end{bmatrix} \cdot [1] \cdot \begin{bmatrix} 0.5 & 0.9 \end{bmatrix} = \begin{bmatrix} 0.75 & - 0.25 \\ - 0.25 & 0.19 \end{bmatrix} $

The conditioned correlation matrix is independent on the conditioned value, and only on the structure of the original correlation matrix $\rho$. However, this correlation is amplified when transforming the data, and it doesn't seem intuitive to me.

Samples from this MVN were later transformed assuming it was coming from a set of marginal standard normal $F_{N(0,1)}$ to keep the "drag" imposed by the condition $X_c = 10$. However, it is not clear to me wether this should be like this, perhaps the problem is there.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.