4
$\begingroup$

This question relates to Financial Machine Learning, and more specifically to competitions like Numerai.

In this competition we have a dataset X and a target y (return over a given horizon). The dataset contains some features (say feature_0 to feature_n) and time. Different stocks are available each time.

One important metric is the correlation bewteen features and the target. Correlation can be either spearman or pearson. We can observe past correlations. I was wondering if there is a standard way to model this kind of correlation over time.

The correlations seems very random, changing signs quite often, oscillating around 0. I was thinking about some mean reverting process, centered at some value near 0. I was thinking about an OU process with a small drift and a high reversion coefficient.

However, as they are correlations, they would be capped by -1 / +1. I don't know how to deal with this. As the correlation are oscillating around 0, I am tempted to ignore this constraint. But it might be better to add some logistic function somewhere.

Any idea of a standard approach to model correlation over time ?

$\endgroup$

2 Answers 2

4
$\begingroup$

One idea could be the following.

Let $\eta:\mathbb{R}_+\times\Omega\rightarrow\mathbb{R}$ be some diffusion process taking values over the whole real line: $$\eta_t=\eta_0+\int_0^t\alpha_t\text{d}t+\int_0^t\beta_t\text{d}W_t$$ for some adapted process $\alpha,\beta$ and where $W$ is a Brownian Motion. Let $F:\mathbb{R}\rightarrow[0,1]$ be the cumulative distribution function (CDF) for some random variable taking values in $\mathbb{R}$ and $f$ its probability density functions (PDF). Define the process $\varrho:\mathbb{R}_+\times\Omega\rightarrow\mathbb{R}$ as follows: $$\varrho_t=2F(\eta_t)-1$$ Then $\varrho_t\in[-1,1]$ and the process $\varrho$ satisfies the SDE: \begin{align} \text{d}\varrho_t &=2f(\eta_t)\text{d}\eta_t+f^\prime(\eta_t)\text{d}[\eta,\eta]_t\\ &=\left(2f(\eta_t)\alpha_t+f^\prime(\eta_t)\beta^2_t\right)\text{d}t+2f(\eta_t)\beta_t\text{d}W_t \end{align}

Your intuiton is right, I would choose $\eta$ to be an OU process starting at zero ($\eta_0=0$) and also centred at 0 such that: $$\text{d}\eta_t=-\alpha\eta_t\text{d}t+\beta\text{d}W_t$$ Then take $F,f$ to be the CDF, PDF resp. for the standard normal distribution that is $F\equiv\Phi$ and $f\equiv\varphi$. Note that in this case we have: \begin{align} \varrho_t=\text{erf}\left(\frac{\eta_t}{\sqrt{2}}\right) \end{align} where $\text{erf}$ is the Gaussian error function. Recall that $\varphi^\prime(x)=-x\varphi(x)$ hence: \begin{align} \text{d}\varrho_t &=2\varphi(\eta_t)\left(-\left(\alpha+\frac{\beta^2}{2}\right)\eta_t\text{d}t+\beta\text{d}W_t\right) \end{align} Let us define the mean and standard deviation from $\eta$ as: $$\mu(t)=0,\qquad\sigma(t)=\frac{\beta^2}{2\alpha}(1-e^{-2\alpha t})$$ Then the distribution of $\varrho_t$ for given $t$ is a "stretched" uniform: $$\mathbb{P}(\varrho_t\leq p) =\Phi\left(\frac{1}{\sigma(t)}\Phi^{-1}\left(\frac{p+1}{2}\right)\right)$$ In particular:

  • $\mathbb{P}(\varrho_t\leq0)=0.5$.
  • If $\sigma(t)=1$ then $\varrho_t$ is uniformly distributed.

Below I have plotted the distribution of $\varrho_t$ for different values of $\sigma(t)$ to get a flavour of what you can achieve. By increasing the vol, you progressively move from a degenerate distribution with all mass at $\varrho_t=0$ to a binary distribution where as $\sigma(t)\rightarrow\infty$ you get $\varrho_t=-1$ or $1$. The first and second moments are: \begin{align} &\mathbb{E}(\varrho_t)=0\\ &\mathbb{E}(\varrho_t^2)=\frac{4}{\pi}\text{arctan}\sqrt{1+2\sigma^2(t)}-1 \end{align}

Because $\sigma(t)$ changes with time, you might want to replace $\beta$ by a deterministic function $\beta(t)$ in the SDE for $\eta$ and use that to control the behaviour of $\sigma(t)$ i.e. ensure it remains close to some target value $\sigma_0$.

                                    

$\endgroup$
3
$\begingroup$

We probably need more information about the shocks.

But for example if your shocks are gaussian you can just define a joint variance-covariance matrix. You should apply it to the covariance matrix and from that compute the correlation matrix. Here's an example correlating 3 random normal variables.

Let:

$$ \bf Y \sim \mathcal N(0, \Sigma) $$

where $\textbf{Y} = (Y_1,\dots,Y_n)$ is the vector of normal random variables, and $\Sigma$ the given covariance matrix.

The process is:

  1. Simulate a vector of uncorrelated Gaussian random variables, $\bf Z $
  2. Then find a square root of $\Sigma$, i.e. a matrix $\bf C$ such that $\bf C \bf C^\intercal = \Sigma$.

Then the target vector is given by $$ \bf Y = \bf C \bf Z. $$

Here is a dummy matlab code:

N = 500000
u_1 = normrnd(zeros(N,1),1);
u_2 = normrnd(zeros(N,1),1);
u_3 = normrnd(zeros(N,1),1);
u_4 = normrnd(zeros(N,1),1);

rv = [u_1 '; u_2'; u_3'; u_4'];


VarCov = [Some positive semi-definite matrix here 4x4];

ch = chol(VarCov);
result = ch * rv;

Then just divide each entry of the result matrix by the product of the standard deviations to get a correlation matrix.

$\endgroup$
3
  • 2
    $\begingroup$ I am not sure to follow. I was wondering what kind of stochastic process can model a given correlation over time. $\endgroup$ Commented Jul 3, 2023 at 13:16
  • $\begingroup$ Correlated stochastic processes of course. Just as the ones on the example above. $\endgroup$
    – phdstudent
    Commented Jul 3, 2023 at 16:34
  • 2
    $\begingroup$ Maybe I am missing something but I would expect the time to appear somewhere... $\endgroup$ Commented Jul 6, 2023 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.