I am trying to plot conditional effects predictions for the model fit3
included in the ?mi
help documentation. The model fits fine, but I’m unable to run the conditional_effects()
function, or the fitted()
function for that matter. These functions produce the following error:
Error: Index of response ‘’ contains duplicated values.
Here’s the code to fit the model, taken from the help documentation for the mi()
function:
data("nhanes", package = "mice")
N <- nrow(nhanes)
# simulate some measurement noise
nhanes$se <- rexp(N, 2)
# 'mi' terms can also be used when some responses are subsetted
nhanes$sub <- TRUE
nhanes$sub[1:2] <- FALSE
nhanes$id <- 1:N
nhanes$idx <- sample(3:N, N, TRUE)
# this requires the addition term 'index' being specified
# in the subsetted part of the model
bform3 <- bf(bmi | mi() ~ age * mi(chl, idx)) +
bf(chl | mi(se) + subset(sub) + index(id) ~ age) +
set_rescor(FALSE)
fit3 <- brm(bform3, data = nhanes)
plot(conditional_effects(fit3, resp = "bmi"), ask = FALSE)
I am running a similar model with missing data on a subsetted predictor (specifically, a group-level predictor in a multilevel model). It would be really useful to get posterior predictions! Many thanks in advance.
Operating System: Windows 10
Interface Version: brms 2.18.0