# Assessing correlation/similarity in shape and position of two datasets

I have data-sets within which position and shape (curves, relative increase/decrease at any given x-value) are the defining characteristics, such as:

And a simulation which attempts to recapture the process giving rise to these datasets, producing data such as:

Simulation A

Simulation B

Containing the same number of points. Simulation A closely resembles the real-data while Simulation B shows a generalised trend but lacks a lot of the detail - and would be deemed a reasonably poor fit.

Notably, any of the features should occur at the same x-position in the simulation (when a good-fit is obtained) and the real-data.

What would be an appropriate statistical and quantitative way to assess the correlation and/or similarity between the data-sets above?

While the intensity of curves remain correct relative to others within the same profile, the absolute y-values are often different between the datasets and thus using a two-sample KS-test (or equivalent) is not particularly useful - and any solution would need to be independent of y-value (if at all possible). I've thought about using linear or ranked correlation (Pearson's, Spearman) but am having a difficult time understanding how these work and thus whether or not they are applicable when position/shape matter and when dealing with data that is not necessarily linear.

First of all, do you compute correlation on this signal? the rate of variations?

Then, Pearson and Spearman correlation between $$(X_t)$$ and $$(Y_t)$$ do not consider the time dimension $$t$$, i.e. by shuffling the realizations $$(X_{t_i},Y_{t_i})$$ you can end up with very different signals having the same correlation.

If you work directly on these curves, you can measure their (dis)similarity with dynamic time warping (cost of transforming one into the other by non-linear distortion on time). It may be suited to your needs.

If you want something more 'statistical' (but essentially the same than dynamic time warping in this 1d case (solved using dynamic programming)), you can consider that your realizations have unit mass and are located in $$(x,y)$$. You want to transport the mass from the realizations of graph A to the realizations of graph B in order to minimize the cost of transport. If you use a metric between the point $$(x,y)$$ location, this cost gives you a metric, the optimal transport metric / Wasserstein metric / Earth Mover Distance which can be computed in $$O(n \log n)$$ in this case (since 1d), where $$n$$ is the number of realizations.

• Thank you for clearing that up RE: Pearson + Spearman. My understanding of DTW is that it's applied to out-of-phase datasets (variation in x-axis). My data however should not vary in x-axis - it should have the same number of points overall and any features such as curves should appear in the same location as the real data (if a good-fit is obtained). They will differ/vary in y-axis value but this is not majorly important. Would it still be applicable regardless as a measurement of 'similarity'? Commented May 3, 2016 at 10:53
• And yes - work is done directly on these signals. Commented May 3, 2016 at 10:53
• You're right about DTW, in your case it will not do much better than a $L_p$. There is a research field called 'statistical shape analysis' en.wikipedia.org/wiki/Statistical_shape_analysis where one of the idea is to use diffeomorphism between shapes to measure the (dis)similarity. But, I'm not an expert in that, sorry.
– mic
Commented May 3, 2016 at 11:02
• Thanks once again. I suspect the fact that y-values in the real-data are unreliable (and thus I can't just normalise signals) will make this a very difficult task but I thought it worth asking nonetheless. Commented May 3, 2016 at 11:04