Copula Processes
Andrew Gordon Wilson, Zoubin Ghahramani
Introduction
Imagine measuring the distance of a rocket as it leaves Earth, and wanting to know how these measurements correlate with one another. How much does the value of the measurement at fifteen minutes depend on the measurement at five minutes? Once we’ve learned this correlation structure, suppose we want to compare it to the dependence between measurements of the rocket’s velocity. To do this, it is convenient to separate dependence from the marginal distributions of our measurements. At any given time, a rocket’s distance from Earth could have a Gamma distribution, while its velocity could have a Gaussian distribution. And separating dependence from marginal distributions is precisely what a copula function does.
While copulas have recently become popular, especially in financial applications , as Nelsen writes, “the study of copulas and the role they play in probability, statistics, and stochastic processes is a subject still in its infancy. There are many open problems…” Typically only bivariate (and recently trivariate) copulas are being used and studied. In our introductory example, we are interested in learning the correlations in different stochastic processes, and comparing them. It would therefore be useful to have a copula process, which can describe the dependencies between arbitrarily many random variables independently of their marginal distributions. We define such a process. As an example, we develop a stochastic volatility model, Gaussian Copula Process Volatility (GCPV). In doing so, we provide a Bayesian framework for the learning the marginal distributions and dependency structure of what we call a Gaussian copula process.
The volatility of a random variable is its standard deviation. Stochastic volatility models are used to predict the volatilities in a heteroscedastic sequence – a sequence of random variables with different variances, like distance measurements of a rocket as it leaves the Earth. As the rocket gets further away, the variance on the measurements increases. Heteroscedasticity is especially important in econometrics; the returns on equity indices, like the S&P 500, or on currency exchanges, are heteroscedastic. Indeed, in 2003, Robert Engle won the Nobel Prize in economics “for methods of analyzing economic time series with time-varying volatility”. GARCH , a generalized version of Engle’s ARCH, is arguably unsurpassed for predicting the volatility of returns on equity indices and currency exchanges . GCPV can outperform GARCH, and is competitive on financial data that especially suits GARCH . Before introducing GCPV, we first discuss copulas and then introduce our copula process. For a review of Gaussian processes, see Rasmussen and Williams .
Copulas
Copulas are important because they separate the dependency structure between random variables from their marginal distributions. Intuitively, we can describe the dependency structure of any multivariate joint distribution through a two step process. First we take each univariate random variable and transform it through its cumulative distribution function (cdf) to get , a uniform random variable. We then express the dependencies between these transformed variables through the -copula . Formally, an -copula is a multivariate cdf with uniform univariate marginals: , where are standard uniform random variables. Sklar precisely expressed our intuition in the theorem below.
Sklar’s theorem Let H be an n-dimensional distribution function with marginal distribution functions . Then there exists an -copula C such that for all ,
If are all continuous then C is unique; otherwise C is uniquely determined on . Conversely, if C is an -copula and are distribution functions, then the function H is an n-dimensional distribution function with marginal distribution functions .
As a corollary, if , the quasi-inverse of , then for all ,
In other words, (2) can be used to construct a copula. For example, the bivariate Gaussian copula is defined as
where is a bivariate Gaussian cdf with correlation coefficient , and is the standard univariate Gaussian cdf. Li popularised the bivariate Gaussian copula, by showing how it could be used to study financial risk and default correlation, using credit derivatives as an example.
By substituting for and for in equation (3), we have a bivariate distribution , with a Gaussian dependency structure, and marginals and . Regardless of and , the resulting can still be uniquely expressed as a Gaussian copula, so long as and are continuous. It is then a copula itself that captures the underlying dependencies between random variables, regardless of their marginal distributions. For this reason, copulas have been called dependence functions . Nelsen contains an extensive discussion of copulas.
Copula Processes
Imagine choosing a covariance function, and then drawing a sample function at some finite number of points from a Gaussian process. The result is a sample from a collection of Gaussian random variables, with a dependency structure encoded by the specified covariance function. Now, suppose we transform each of these values through a univariate Gaussian cdf, such that we have a sample from a collection of uniform random variables. These uniform random variables also have this underlying Gaussian process dependency structure. One might call the resulting values a draw from a Gaussian-Uniform process. We could subsequently put these values through an inverse beta cdf, to obtain a draw from what could be called a Gaussian-Beta process: the values would be a sample from beta random variables, again with an underlying Gaussian process dependency structure. Alternatively, we could transform the uniform values with different inverse cdfs, which would give a sample from different random variables, with dependencies encoded by the Gaussian process.
The above procedure is a means to generate samples from arbitrarily many random variables, with arbitrary marginal distributions, and desired dependencies. It is an example of how to use what we call a copula process – in this case, a Gaussian copula process, since a Gaussian copula describes the underlying dependency structure of a finite number of samples. We can now formally define a copula process.
Note that each , and that is the quasi-inverse of , as it was previously defined.
Gaussian Copula Process is Gaussian copula process distributed if it is copula process distributed and the base measure is a Gaussian process. If there is a mapping such that , then we write .
For example, if we have with and , then in our definition of a copula process, , the standard univariate Gaussian cdf, and is the usual GP joint distribution function. Supposing this GCP is a Gaussian-Beta process, then , where is a univariate Beta cdf. One could similarly define other copula processes.
We described generally how a copula process can be used to generate samples of arbitrarily many random variables with desired marginals and dependencies. We now develop a specific and practical application of this framework. We introduce a stochastic volatility model, Gaussian Copula Process Volatility (GCPV), as an example of how to learn the joint distribution of arbitrarily many random variables, the marginals of these random variables, and to make predictions. To do this, we fit a Gaussian copula process by using a type of Warped Gaussian Process . However, our methodology varies substantially from Snelson et al. , since we are doing inference on latent variables as opposed to observations, which is a much greater undertaking that involves approximations, and we are doing so in a different context.
Gaussian Copula Process Volatility
Assume we have a sequence of observations at times . The observations are random variables with different latent standard deviations. We therefore have unobserved standard deviations, , and want to learn the correlation structure between these standard deviations, and also to predict the distribution of at some unrealised time .
We model the standard deviation function as a Gaussian copula process:
where is a monotonic warping function, parametrized by . For each of the observations we have corresponding GP latent function values , where , using the shorthand to mean .
, because any finite sequence is distributed as a Gaussian copula:
Here we have assumed that each observation, conditioned on knowing its variance, is normally distributed with zero mean. This is a common assumption in heteroscedastic models. The zero mean and normality assumptions can be relaxed and are not central to this paper.
Predictions with GCPV
Ultimately, we wish to infer , where , and are the hyperparameters of the GP covariance function. To do this, we sample from
and then transform these samples by . Letting = , where is the Kronecker delta, , , we have
We also wish to learn , which we can do by finding the that maximizes the marginal likelihood,
Unfortunately, for many functions , (10) and (13) are intractable. Our methods of dealing with this can be used in very general circumstances, where one has a Gaussian process prior, but an (optionally parametrized) non-Gaussian likelihood. We use the Laplace approximation to estimate as a Gaussian. Then we can integrate (10) for a Gaussian approximation to , which we sample from to make predictions of . Using Laplace, we can also find an expression for an approximate marginal likelihood, which we maximize to determine . While we always use Laplace to determine , we compare to a full Laplace solution by also using Markov chain Monte Carlo to sample from .
Let us now relate the above to the Gaussian copula in (9). The prior . The posterior can be estimated as the covariance matrix of the Laplace approximation for . Also, since each component of is transformed separately, such that , we have
One can use this to simulate from the joint distribution over the deviations.
The goal is to approximate (11) with a Gaussian, so that we can evaluate (10) and (13) and make predictions. In doing so, we follow Rasmussen and Williams in their treatment of Gaussian process classification, except we use a parametrized likelihood, and modify Newton’s method.
First, consider as an objective function the logarithm of an unnormalized (11):
where is the diagonal matrix .
If the likelihood function is not log concave, then may have negative entries. Vanhatalo et al. found this to be problematic when doing Gaussian process regression with a Student-t likelihood. They instead use an expectation-maximization (EM) algorithm for finding , and iterate ordered rank one Cholesky updates to evaluate the Laplace approximate marginal likelihood. But EM can converge slowly, especially near a local optimum, and each of the rank one updates is vulnerable to numerical instability. With a small modification of Newton’s method, we often get close to quadratic convergence for finding , and can evaluate the Laplace approximate marginal likelihood in a numerically stable fashion, with no approximate Cholesky factors, and optimal computational requirements.
At a maximum, the negative Hessian of the objective function, , is positive definite. On each iteration of Newton’s method, we form by setting all negative entries of to zero. Since is positive definite, and the eigenvalues of are greater than or equal to the eigenvalues of , is always positive definite. Using in place of decreases the Newton step size, and changes the direction of steps. We are always stepping towards a local maximum, and will converge, barring rare pathologies.
where is evaluated at , and is a numerically stable evaluation of .
Given training observations, the cost of each Newton iteration is dominated by computing , which takes operations. The objective function typically changes by less than after 3 iterations. Once Newton’s method has converged, it takes only operations to draw from and make predictions.
2 Markov chain Monte Carlo
We use Markov chain Monte Carlo (MCMC) to sample from (11), so that we can later sample from to make predictions. Sampling from (11) is difficult, because the variables are strongly coupled by a Gaussian process prior. We use a new technique, Elliptical Slice Sampling , and find it extremely effective for this purpose. It was specifically designed to sample from posteriors with correlated Gaussian priors. It has no free parameters, and jointly updates every element of . For our setting, it is over 100 times as fast as axis aligned slice sampling with univariate updates.
To make predictions, we take samples of , {}, and then approximate (10) as a mixture of Gaussians:
Each of the Gaussians in this mixture have equal weight. So for each sample of , we uniformly choose a random and draw a sample. In the limit , we are sampling from the exact . Mapping these samples through gives samples from .
After one and one operation, a draw from (20) takes operations.
3 Warping Function
This is monotonic, positive, infinitely differentiable, asymptotic towards zero as , and tends to as . In practice, it is useful to add a small constant to (21), to avoid rare situations where the parameters are trained to make extremely small for certain inputs, at the expense of a good overall fit; this can happen when the parameters are learned by optimizing a likelihood. A suitable constant could be one tenth the absolute value of the smallest nonzero observation.
By inferring the parameters of the warping function, or distributions of these parameters, we are learning a transformation which will best model with a Gaussian process. The more flexible the warping function, the more potential there is to improve the GCPV fit – in other words, the better we can estimate the ‘perfect’ transformation. To test the importance of this flexibility, we also try a simple unparametrized warping function, . In related work, Goldberg et al. place a GP prior on the log noise level in a standard GP regression model on observations, except for inference they use Gibbs sampling, and a high level of ‘jitter’ for conditioning.
Experiments
We then sample from using the Laplace approximation (19). We also do this using MCMC (20) with , after discarding a previous samples of as burn-in. We pass these samples of through and to draw from and , and compute the sample mean and variance of . We use the sample mean as a point predictor, and the sample variance for error bounds on these predictions, and we use samples to compute these quantities. For GCPV we use Laplace and MCMC for inference, but for GP-EXP we only use Laplace. We compare predictions to GARCH(1,1), which has been shown in extensive and recent reviews to be competitive with other GARCH variants, and more sophisticated models . We use the Matlab Econometrics Toolbox implementation of GARCH.
We make forecasts of volatility, and we predict historical volatility. By ‘historical volatility’ we mean the volatility at observed time points, or between these points. Uncovering historical volatility is important. It could, for instance, be used to study what causes fluctuations in the stock market, or to understand physical systems.
To evaluate our model, we use the Mean Squared Error (MSE) between the true variance, or proxy for the truth, and the predicted variance. Although likelihood has advantages, we are limited in space, and we wish to harmonize with the econometrics literature, and other assessments of volatility models, where MSE is the standard. In a similar assessment of volatility models, Brownlees et al. found that MSE and quasi-likelihood rankings were comparable.
We simulate observations from , using , at . We call this data set TRIG. We also simulate using a standard deviation that jumps from to and back, at times . We call this data set JUMP. To forecast, we use all observations up until the current time point, and make 1, 7, and 30 step ahead predictions. So, for example, in TRIG we start by observing , and make forecasts at . Then we observe and make forecasts at , and so on, until all data points have been observed. For historical volatility, we predict the latent at the observation times, which is safe since we are comparing to the true volatility, which is not used in training; the results are similar if we interpolate. Figure 1 panels a) and b) show the true volatility for TRIG and JUMP respectively, alongside GCPV Laplace, GCPV MCMC, GP-EXP Laplace, and GARCH(1,1) predictions of historical volatility. Table 1 shows the results for forecasting and historical volatility.
In panel a) we see that GCPV more accurately captures the dependencies between at different times points than GARCH: if we manually decrease the lengthscale in the GCPV covariance function, we can replicate the erratic GARCH behaviour, which inaccurately suggests that the covariance between and decreases quickly with increases in . We also see that GCPV with an unparametrized exponential warping function tends to overestimates peaks and underestimate troughs. In panel b), the volatility is extremely difficult to reconstruct or forecast – with no warning it will immediately and dramatically increase or decrease. This behaviour is not suited to a smooth squared exponential covariance function. Nevertheless, GCPV outperforms GARCH, especially in regions of low volatility. We also see this in panel a) for . GARCH is known to respond slowly to large returns, and to overpredict volatility . In JUMP, the greater the peaks, and the smaller the troughs, the more GARCH suffers, while GCPV is mostly robust to these changes.
2 Financial Data
The returns on the daily exchange rate between the Deutschmark (DM) and the Great Britain Pound (GBP) from 1984 to 1992 have become a benchmark for assessing the performance of GARCH models . This exchange data, which we refer to as DMGBP, can be obtained from www.datastream.com, and the returns are calculated as , where is the number of DM to GBP on day . The returns are assumed to have a zero mean function.
We use a rolling window of the previous 120 days of returns to make 1, 7, and 30 day ahead volatility forecasts, starting at the beginning of January 1988, and ending at the beginning of January 1992 (659 trading days). Every 7 days, we retrain the parameters of GCPV and GARCH. Every time we retrain parameters, we predict historical volatility over the past 120 days. The average MSE for these historical predictions is given in Table 1, although they should be observed with caution; unlike with the simulations, the DMGBP historical predictions are trained using the same data they are assessed on. In Figure 1c), we see that the GARCH one day ahead forecasts are lifted above the GCPV forecasts, but unlike in the simulations, they are now operating on a similar lengthscale. This suggests that GARCH could still be overpredicting volatility, but that GCPV has adapted its estimation of how and correlate with one another. Since GARCH is suited to this financial data set, it is reassuring that GCPV predictions have a similar time varying structure. Overall, GCPV and GARCH are competitive with one another for forecasting currency exchange returns, as seen in Table 1. Moreover, a learned warping function outperforms an unparametrized one, and a full Laplace solution is comparable to using MCMC for inference, in accuracy and speed. This is also true for the simulations. Therefore we recommend whichever is more convenient to implement.
Discussion
We defined a copula process, and as an example, developed a stochastic volatility model, GCPV, which can outperform GARCH. With GCPV, the volatility is distributed as a Gaussian Copula Process, which separates the modelling of the dependencies between volatilities at different times from their marginal distributions – arguably the most useful property of a copula. Further, GCPV fits the marginals in the Gaussian copula process by learning a warping function. If we had simply chosen an unparametrized exponential warping function, we would incorrectly be assuming that the log volatilities are marginally Gaussian distributed. Indeed, for the DMGBP data, we trained the warping function over a 120 day period, and mapped its inverse through the univariate standard Gaussian cdf , and differenced, to estimate the marginal probability density function (pdf) of over this period. The learned marginal pdf, shown in Figure 1d), is similar to a Gamma(4.15,0.00045) distribution. However, in using a rolling window to retrain the parameters of , we do not assume that the marginals of are stationary; we have a time changing warping function.
While GARCH is successful, and its simplicity is attractive, our model is also simple and has a number of advantages. We can effortlessly handle missing data, we can easily incorporate covariates other than time (like interest rates) in our covariance function, and we can choose from a rich class of covariance functions – squared exponential, Brownian motion, Matérn, periodic, etc. In fact, the volatility of high frequency intradaily returns on equity indices and currency exchanges is cyclical , and GCPV with a periodic covariance function is uniquely well suited to this data. And the parameters of GCPV, like the covariance function lengthscale, or the learned warping function, provide insight into the underlying source of volatility, unlike the parameters of GARCH.
Finally, copulas are rapidly becoming popular in applications, but often only bivariate copulas are being used. We introduced a copula process where one can learn the dependency structure between arbitrarily many random variables independently of their marginal distributions. We hope the Gaussian Copula Process Volatility model will encourage other applications of copula processes. More generally, we hope our work will help bring together the machine learning and econometrics communities.
Acknowledgments: Thanks to Carl Edward Rasmussen and Ferenc Huszár for helpful conversations. AGW is supported by an NSERC grant.