I am working with data from an experiment where we measured two correlated traits in replicate individuals of the same genotype at four different sites. The two traits are partially regulated by the same pathways (they're methylation of cytosines in different sequence contexts if that helps anyone), so it's not surprising that they are correlated, but we also strongly suspect there maybe correlation with some other unmeasured confounder.
Here is a subset of the data:
# Import data into R.
df <- data.frame(
genotype = c("6191", "6046", "8241", "8227", "9452", "6191", "9452", "6237", "6104", "6231", "6231", "6180", "6231", "6191", "6046", "6231", "6104", "6046", "8241", "6231", "6126", "6237", "6191", "6126", "6231", "8241", "5856", "9452", "6104", "9470"),
site = c("B", "C", "C", "A", "C", "C", "D", "B", "B", "C", "B", "D", "B", "B", "D", "A", "B", "A", "D", "D", "A", "A", "B", "D", "C", "B", "A", "C", "C", "D"),
trait1 = c(-0.4056050, -0.5276847, -0.4070822, -0.5523137, -0.3886427, -0.4417745, -0.4890365, -0.6902847, -0.6573103, -0.5832851, -0.7258661, -0.3142865, -0.7943594, -0.5554425, -0.7154426, -0.9325366, -0.5365588, -0.6726796,-0.5333700, -1.1490379, -0.7341835, -0.5674334, -0.5937559, -0.6678709, -0.9884700, -0.6867066, -0.7534590, -0.5746081, -0.6980742, -0.4437108),
trait2 = c(-1.441314, -1.542336, -1.521273, -1.647513, -1.699523, -1.730442, -1.717863, -2.996804, -1.754690, -1.712154, -2.243960, -1.562110, -2.960188, -2.245098, -2.236504, -3.224924, -2.369385, -2.371202, -1.931709, -2.548280, -2.200219, -2.934834, -1.776365, -1.895126, -3.252790, -2.379290, -3.261246, -1.924550, -2.308284, -1.475468)
)
Trait1 and Trait2 have correlation coefficient of ~0.8:
cor(df$trait1, df$trait2, method = 'spearman')
We are especially interested in how trait 1 varies across genotypes and sites. A basic ANOVA using terms for genotype, environment, and their interaction gives the following:
> (model1 <- aov(trait1 ~ genotype * site, data=df))
Call:
aov(formula = trait1 ~ genotype * site, data = df)
Terms:
genotype site genotype:site Residuals
Sum of Squares 0.6445498 0.0515288 0.1477629 0.1287884
Deg. of Freedom 11 3 9 6
Residual standard error: 0.1465085
24 out of 48 effects not estimable
Estimated effects may be unbalanced
To account for the correlation we have tried including trait 2 as a fixed effect:
> (model2 <- aov(trait1 ~ genotype * site + trait2, data=df))
Call:
aov(formula = trait1 ~ genotype * site + trait2, data = df)
Terms:
genotype site trait2 genotype:site Residuals
Sum of Squares 0.6445498 0.0515288 0.1208514 0.0980477 0.0576523
Deg. of Freedom 11 3 1 9 5
Residual standard error: 0.10738
24 out of 49 effects not estimable
Estimated effects may be unbalanced
When the cofactor is added the sum of squares for the genotype:site interaction and the residuals change. However, the sum of squares for the main effects are identical to seven decimal places. I find that very suspicious. The only reason I can think of for them to be identical is if the effect of trait2 is perfectly orthogonal to the fixed effects of genotype and site, but not the interaction term, which seems very unlikely.
I can't find any errors in how I have formatted the data in previous steps, and I also find it odd that the SS remain identical between two models even if I take arbitrary subsamples of the whole data. That suggests to me that it has something to do with some subtle aspect of the geometry of linear regression.
Can anyone tell me what could explain these identical effects?
PS I realise that model2
might not be the best way to analyse the data if there is a latent factor, but we are interested in understanding these models to help us work out what a possible latent factor might be.
trait2
and the three explanatory variables of the first model: what are they? $\endgroup$