- Operating System: Microsoft Windows 11
- brms Version: 2.16.1
Hello!
I am having the same problem that Rhainer had, here. It was never resolved, and so I am writing to the brms community for help.
I’m trying to fit a repeated measures animal model to estimate repeatability. In my simple model, I’d include a behavioral response variable Resp
, fixed factor Sex
, relatedness matrix covmat
, and individual ID
. Normally, when specifying brms models, I’d link ID
to the animal covmat
using the ‘gr’ term:
model <- brm(
Resp ~ Sex + (1|gr(ID,cov=A)),
data=data,
data2=list(A=covmat),
family = gaussian(),
warmup = 100, iter = 5000,
However, when trying to incorporate a second ID
random effect term, to account for fixed among-individual differences (permanent environment effects), this is where my models fail. Below is my very simple model incorporating ID_pe
and the error message I receive:
model <- brm(
Resp ~ Sex + (1|gr(ID,cov=A)) + (1|ID_pe), # ID_pe is the permanent environmental effects
data=data,
data2=list(A=covmat),
family = gaussian(),
warmup = 100, iter = 5000,
chains = 1, cores = 1,thin=1)
Error: Levels of the within-group covariance matrix for 'ID' do not match names of the grouping levels.
As Rhainer did in his post, I checked to ensure my group names matched between my covariance matrix and my phenotype data–and they do.
One possible solution is unlinking the animal covmat from the animal ID term. When I run my model as specified in this tutorial, the model runs. Code:
model <- brm(
Resp ~ Sex + (1|ID) + (1|ID_pe), # no grouping term linking ID to animal covmat
data=data,
data2=list(A=covmat),
family = gaussian(),
warmup = 100, iter = 5000,
chains = 1, cores = 1,thin=1)
My questions are therefore:
- What could be causing the mismatch of group level names?
And perhaps I don’t need to know the answer to number 1 if:
- Is this second way of model specification equivalent to the first? That is, by not explicitly linking ID to the covariance matrix
covmat
, will I still be able to estimate additive genetic variance?
Much thanks to the community in advance,
Tracy