I am trying to find pairs of predictor variables that give a good structure map for a dataset of chemical compounds. Structure maps in chemistry are 2D-plots, in which two independent predictor variables change along the X and Y axes, while the values of the target variable are shown either by a color if it is continuous or by different symbols if it is discrete.

A good structure map is such that clearly shows separation of data points into different clusters if the target variable is discrete or shows a trend if it is continuous.

My target variable is continuous, so I want to detect a trend.

Two examples of relatively good structure maps for my dataset are as follows.

enter image description here

The value of the target variable is shown in a color bar. It is clear from the left figure that if I simultaneously increase X and Y values, I get compounds with larger value of the target variable. Also, in the figure on the right, it is easy to find regions where the target variable is large, small or average.

The data on bad structure maps are randomly scattered throughout the plot, so it is not possible to see how to tweak the values of predictor variables to get the desired target value. Two examples are below.

enter image description here

Predictor variables X and Y can be characteristics of a certain atom in the compound (e.g. its radius or ionization potential) or any linear or non-linear combination of such characteristics which makes the number of such variables very large.

My question is: Instead of examining these plots visually, which statistical tests can I run on them to select those where the data are not scattered randomly but show some trend in behavior of the target variable?

What I have tried so far is:

  1. Run a linear regression Y ~ X
  2. Projected the data to the regression line
  3. Made a one-dimensional plot where X-axis is the regression line, and Y-axis is the value of the target variable
  4. Calculated the Spearman correlation coefficient of the data projected onto the regression line.

My thinking was, whether I could detect a line along which the target variable changes monotonically.

I tested it on a few plots, and it looks like working: the Spearman coefficient is > 0.75 for good maps and lower than 0.5 for bad ones but I am not sure if this is a correct way to solve this problem.

I also calculated the distance correlation $dcor([X,Y],target)$ and the randomized dependence coefficient between the set of predictor variables $[X,Y]$ and the target variable. The distance correlation is high for good maps and low for bad maps and gives similar values to the coefficient that I am getting with the Spearman correlation along the regression line that I describe above. The randomized dependence coefficient is high for almost all maps, good and bad, though somewhat lower for bad maps, and low for only very bad maps.

Are there any established statistical tests for detecting trends in two-dimensional data?

  • $\begingroup$ Am I missing something obvious, or is this a multiple regression problem: $Target \sim x + y + x \times y$? $\endgroup$
    – Eoin
    Commented Jul 12, 2019 at 10:57

1 Answer 1


OK, I might have misunderstood, but I think your problem is a straightforward case of multiple regression.

An example in R, using the iris dataset:

ggplot(iris, aes(Sepal.Length, Petal.Width, color=Sepal.Width)) + geom_point() + scale_color_gradientn(colours = rainbow(5))

enter image description here

You can use $R^2$, the variance explained by your model, as a measure of the combined influence of the predictors on the target.

m = lm(Sepal.Width ~ Sepal.Length * Petal.Width, data=iris)
# [1] 0.2830045 # 28% of the variance in Sepal.Width is explained by the predictors.
  • $\begingroup$ I am not a statistician. Do I understand correctly that you are checking if the target is linearly correlated with $x \times y$? Will it also work if the target is a different function of $x$ and $y$, not related to their product? $\endgroup$ Commented Jul 12, 2019 at 11:22
  • $\begingroup$ To your second question, yes. If your target is linearly correlated with x, y, $x \times y$, or any weighted sum of these things, multiple regression will capture this. Explaining regression is beyond the scope of this question, but see, e.g., here $\endgroup$
    – Eoin
    Commented Jul 12, 2019 at 12:23

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.