[R-sig-ME] pairwise combinations of subjects

Stevens, Hank h@nk@@teven@ @end|ng |rom m|@m|oh@edu
Sun Jul 14 13:36:36 CEST 2019

I was hoping someone might point to information or examples of this type of

I sometimes encounter data that are derived from interactions between all
pairwise interactions of subjects (e.g., subject a vs. subject b, subject a
vs. subject c, subject b vs. subject c). The response is the result of the
interaction between subjects, and observations are likely to show
correlations within subject. We are interested in the relation between a
fixed effect predictor and the response, and not the effects of subject per
se. For instance,

subj_1   subj_2 . pred  resp
  a        b       1      5
  a        c       1.1 .  4
  b        c       2.5 .  1

where the subj 1 and subj 2 are all the same individuals, but are paired
with a different partner. It seems as though this might be crossed random
effects of subj_1 and subj_2. E.g.,
lmer( resp ~ pred + (1|subj1) + (1|subj2) )

This seems like a design that might be common in breeding....

Many thanks for your thoughts and leads.

Hank Stevens

A more thorough worked example:

df <- expand.grid(gl())
n <- 5
l <- n*(n-1)/2
x <- data.frame( matrix(NA, nr=1, nc=2) )
names(x) <- c("sp1", "sp2")

r <- 1
for(i in 1:(n-1)){
  for(j in (i+1):n){
    x[r,1:2] <- c(i,j)
    r <- r+1

x$y <- (x$sp1 + x$sp2) / (n*2) + runif(l)
x$c <- - (x$sp1 + x$sp2) / (n*2) + runif(l)

## which design, if any?
summary( lm(y ~ c, data=x))
summary( lmer(y ~ c + (1|sp1) + (1|sp2), data=x))

*Dr. Hank Stevens*
Lab website <http://blogs.miamioh.edu/stevens-lab/>
PhD Program in Ecology, Evolution, and Environmental Biology
433 Hughes Hall, Miami University, tel: 513-529-4206

	[[alternative HTML version deleted]]

More information about the R-sig-mixed-models mailing list