Plotting interaction effects from "mira" or "mipo" objects in R (after multiple imputation using mice)

75 views Asked by At

I have imputed data and I am not able to plot the effects of a multilevel linear regression model (yet!).

These are the objects that I work with in my environment:

class(df_1_imp) # data frame with all imputed cases

class(imp_final) # mids object (converted back from df_1_imp) -\> with this object, I've fitted the model mi_wellbeing

class(mi_wellbeing) # "mira" "matrix"

class(pooled_model) # "mipo" "data.frame" -\> from pool(mi_wellbeing)

class(rounded_summary) # "mipo.summary" "data.frame"

# extracting interaction effects

em_int.pooled <- emmeans(mi_wellbeing, ~gaming.cw*native.gmc, pbkrtest.limit = 3078)
tidy <- as_tibble(em_int.pooled)

#plotting
pd <- position_dodge(0.5)

int.plot <- ggplot(tidy, aes(y = gaming.cw, x = emmean, colour = factor(native.gmc))) +
  geom_line(aes(xmin = lower.CL, xmax = upper.CL), position = pd, linewidth = 2) +
  geom_point(position = pd, size = 4) +
  ggtitle('Interactions') +
  labs(x = "Aggregated Interaction Effect") +
  #scale_color_bright() +
  theme_light()

However, the code didn't work and I have no idea in general, how to plot effects from extracted pooled regression coefficients and interaction effects after using mice for multiple imputations.

0

There are 0 answers