I’m trying to model the positive predictive power of two serology tests but I want the results to be correlated at the individual level in the presence of multiple observations.
To achieve this I duplicated the gold standard variable:
data <- mutate(Ref1 = Ref, Ref2 = Ref)
Then I setup the following formula
f <- mvbrmsformula(
bf(Ref1 | subset(Test1) ~ (1 | g | group) ,
bf(Ref2 | subset(Test2) ~ (1 | g | group )
)
But when I try it I get:
Error: Length of ‘subset’ do not match the rows of ‘data’.
How can I use brms to keep the two outcome correlated even if different subsets of the data?
Note also that if the gold standard variable and the test outcomes are binary or categorical, then there are often good reasons to focus on sensitivity and specificity rather than overall predictive power in a regression (the latter will potentially be sensitive to the composition of the sample).