I’m currently working on a dataset that requires setting varying effects that account for a particular sort of group-level variation. Here is a toy example of my issue:
Assume that I have a dataset where three researchers (A, B, C) collect data on the levels of English proficiency (on a continuous scale from 0 to 10) and the grades the students get in English class (continuous, 1 to 4). The goal is to predict students’ grades by their proficiency. The three researchers survey students in four schools - sometimes the same school is surveyed twice or even three times. Afterwards, we notice that all researchers have measured students’ proficiency in individual schools differently than their colleagues, yet it is not clear if there is a systematic effect. In other words, we have strong random outliers in individual school-researcher combinations but since not all schools have been surveyed by every researcher equally, we cannot determine whether either one particular measurement is an outlier. The following code creates a toy dataset of the problem:
df = data.frame(
'grade' = c(2, 4, 1, 2, 4, 5, 6, 1, 2, 2),
'proficiency' = c(5, 9, 2, 10, 2, 3, 4, 10, 8, 9),
'school' = c('I', 'II', 'III', 'IV', 'II', 'III', 'I', 'II', 'III', 'IV'),
'researcher' = c('A', 'B', 'C', 'A', 'A', 'B', 'C', 'C', 'A', 'B')
)
In this dataset, reseacher A is an outlier in school II and III but not in school IV. So the effect is both tied to the researcher but not in general but regarding certain schools (A measured too low in school II, too high in school III, and okay in school IV).
My question therefore is how I specify varying effects in brms in such a way that I can account for this variation (if it is even possible to to that). The options I can think of are:
mod1 <- brm(grade ~ proficiency + (1|school) + (1|researcher), data = df)
and
mod2 <- brm(grade ~ proficiency + (1|researcher/school) , data = df)
Which one is be the one that comes closest to what I’d like to achieve? Or do I need to specify the model in some other way?
Thanks in advance!
- Operating System: Windows 10
- brms Version: 2.14.4