Hi everyone,
I’m fairly new to Bayesian modelling and brms ,and this is my first time posting. My aim is to estimate whether there are among-individual correlations between an animals activity when measured in Context 1 and when measured in Context 2. Each individual has 2 repeats for Context 1 and 6 repeats for Context 2. A simplified version of my dataset is as follows:
ID Context1.Activity Context2.Activity Experimental.day
1 35 NA 1
1 NA 51 2
1 14 NA 3
1 NA 18 4
2 46 NA 1
2 NA 50 2
2 21 NA 3
2 NA 12 4
To estimate the among-individual correlations I am aiming to use a multivariate model (I have excluded other predictors from the example code below for simplification).
context1.act <- bf(Context1.Activity ~ Experimental.day + (1|a|ID) , family = gaussian)
context2.act <- bf(Context2.Activity ~ Experimental.day + (1|a|ID) , family = gaussian)
Model<- brm(context1.act + context2.act + set_rescor(FALSE),
data = dat,
cores = 4,
chains = 4,
warmup = 1000,
iter = 10000)
However, due to the NA’s in the data I get the following error:
Rows containing NAs were excluded from the model. Error: All rows of 'data' were removed via 'subset'. Please make sure that variables do not contain NAs even in rows unused by the subsetted model. Please also make sure that each subset variable is TRUE for at least one observation.
I understand that Stan will remove any rows that contain NAs. I have seen that a possible solution to this may be using mi()
. However, I’m not sure how to specify this in my case. Further, I’m still not exactly sure what mi()
does here. Any help would be greatly appreciated!
Thanks in advance.