[This email might, or might have not, bounced, so I'm sending it a second time. Apologies if you receive multiple copies]
Hi All,
I am possibly not up to date on using R mixed models when my random covariate is a Kinship matrix (from genetic data, not pedigree).
I have a data frame (called my.data), with m rows and 126 columns. The columns are the phenotypes (quantitative) and a number of covariates, plus the genotype (coded as x/y, where y and y are microsatellite lengths). Independently I have a m by m matrix of kinship values, derived from the genetic data.
All looks like:
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.5438596 0.4035088 0.3750000 0.3618421 0.3728070 0.3771930
[2,] 0.4035088 0.5614035 0.3903509 0.4298246 0.3925439 0.3925439
[3,] 0.3750000 0.3903509 0.5438596 0.3399123 0.3179825 0.3991228
[4,] 0.3618421 0.4298246 0.3399123 0.5219298 0.3771930 0.3662281
[5,] 0.3728070 0.3925439 0.3179825 0.3771930 0.5175439 0.3662281
[6,] 0.3771930 0.3925439 0.3991228 0.3662281 0.3662281 0.5833333
I tried in lme4 the following:
lmer(all$bw ~ all$MSA + all$temp + all$sex + all$dt + (1|Kinship))
returns
Error in `[[<-.data.frame`(`*tmp*`, i, value = c(233L, 174L, 161L, 162L, :
replacement has 384120 rows, data has 485
I tried in nlme this:
lme(all$bw ~ all$MSA + all$temp + all$sex + all$dt, random = ~ 1|Kinship, na.action = na.omit)
Error in eval(expr, envir, enclos) : object 'bw' not found
If I put the kinship in my.data
my.data$K = Kinship
lme(bw ~ MSA + temp + sex + dt, random = ~ 1|K, data = my.data, na.action = na.omit)
Error in `row.names<-.data.frame`(`*tmp*`, value = origOrder) :
invalid 'row.names' length
Obviously using a m by m matrix is not a good way of specifying a random effect. Given my data, which is not going to change, is there a way of using the K matrix as a random covariate? alternatively, which packages would allow me to do so? Finally, I will admit it openly, from the start. I am after a p-value, ideally from an anova, to see if the different genotypes at each locus have an effect or not.
Best
F