linear model to predict pairwise differences in R? I would like to set up a model where the predictor variables and response variables are pair-wise differences between the subjects. More specifically, I have a set of biological populations and I want to see whether the genetic divergence between any 2 populations significantly predicts the difference in a continuous trait value between those 2 populations. [So each biological population is really an individual subject, not a statistical population]. The model needs to predict pairwise differences because the predictor variable (a measure of genetic distance between populations) is only meaningful in a pairwise context.
Is there a way to set up a glm that models pairwise differences in R? Or should I just calculate the pairwise differences outside the model, and then apply the model to the population of differences? The latter option seems simpler but I am concerned there would be independence issues.
Many thanks for your help, I have not found any relevant info for this.
 A: There most definitely would be independence issues if you used all pairwise differences among your observations as independent data points in a GLM. Think about it this way- if you have N independent observations, you will have (N^2 - N)/2 pairwise comparisons. For N=10, that gives you 45 pairwise comparisons. For N=20, that gives you 190 pairwise comparisons. Clearly, you cannot produce (N^2 - N)/2 independent observations from N original observations, so you have a non-independence problem. 
To deal with your problem, you might try the method 'multiple regression on distance matrices' implemented in the MRM function from the R package ecodist. An interesting application of this method can be found here.
Lichstein, J.W. (2007). Multiple regression on distance matrices: a multivariate spatial analysis tool. Plant Ecol., 188, 117–131.
Goslee, S.C. & Urban, D.L. (2007). The ecodist package for dissimilarity-based analysis of ecological data. J. Stat. Softw., 22, 1–19. 
A: Small addendum to the @slow-loris's answer: for situations like @g-spea's describes, namely to assess the correlation between two matrices of pair-wise distances/differences, a Mantel test is commonly used. You can perform it with function mantel() in the R package vegan or in ecodist. By skimming Lichstein's paper it looks like MRM builds on the partial Mantel test and improves on it, but for two matrices MRM should be equivalent to a standard Mantel test. Indeed, in the following example:
library(ecodist)
data(graze)
MRM(dist(LOAR10) ~ dist(sitelocation), data=graze, nperm=10)
# compared to:
mantel(dist(LOAR10) ~ dist(sitelocation), data=graze)

The value or R^2 provided by MRM() is the square of Mantel's correlation coefficient r provided by mantel(). While mantel() only provides the Mantel's r and the p values associated to it, MRM() also seems to provide regression coefficients (intercept and slope).
