# Plotting conditional effects for model with subsetted missing data

**URL:** <https://discourse.mc-stan.org/t/plotting-conditional-effects-for-model-with-subsetted-missing-data/29008>\
**Category:** brms\
**Tags:** missing-data, conditional-effects\
**Created:** [October 3, 2022, 12:14am UTC](https://discourse.mc-stan.org/t/plotting-conditional-effects-for-model-with-subsetted-missing-data/29008 "2022-10-03T00:14:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott.claessens](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@scott.claessens](https://discourse.mc-stan.org/u/scott.claessens)\
**Post date:** [October 3, 2022, 12:14am UTC](https://discourse.mc-stan.org/t/plotting-conditional-effects-for-model-with-subsetted-missing-data/29008/1 "2022-10-03T00:14:06Z")

</div>

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:

```no-highlight
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
