# Correlations between distance matrices with multiple factors

I have some data for the relatedness of different individuals, the distance between them and whether they belong to the same group.

I want to know: is there a significant effect of group identity on the effect of distance on relatedness. In other words, are group members more closely related than you would expect given their distance?

I found that it is possible to test whether there is a correlation between distance and relatedness using a mantel test, but haven't found anything similar that also allows inclusion of additional factors. Does anyone know if something like this exists?

$$R_i = \beta _0 + \beta _1D_i + \beta _2G_i + \beta _3G_i\times D_i + \epsilon_i,$$
where i would be a pair of two individuals $$R_i$$ - the measure of their relatedness $$D_i$$ - the distance between them, $$G_i$$ - a dummy variable which is one if both belong to the same group and zero if they dont. The interaction term $$G_i\times D_i$$ is what I would look at. If its coefficient $$\beta _3$$ is significantly different from zero and all the assumptions that underlie the OLS do not appear to be violated this would be evidence that group identity affects the relationship between relatedness and distance.