首页 > 解决方案 > 如何在 R 中绘制多级模型处理效果

问题描述

我想绘制我的多级模型的 Group-Time-Interaction。我只设法在没有多级结构的情况下绘制它。我怎样才能包括嵌套?每位患者在同一台仪器上测量 3 次(治疗前、治疗中、治疗后)。患者被随机分为两组(候补名单和治疗组)。这是我的模型:

m8 <- lmer(score ~ 1 + +time*Group +(1| subject), data = df2) 

这就是我所做的:

score <- data %>%
  filter(!is.na(score)) %>%  
  group_by(ti, Gruppe, ar, ID) %>%
  summarise(Max_Height = max(score)) %>%  # Calculating max score
  ungroup() %>%  # Need to ungroup so that the pipe doesn't get confused
  group_by(ti, Gruppe, ar) %>%
  summarise(score = mean(Max_Height)) 
(basic_mm_scatter <- ggplot(score, aes(ti, score, colour = Gruppe)) +
    geom_point() +
    theme_bw() +stat_smooth(method = "lm",))

我也很想包括误差线。不知道怎么做。非常感谢您的帮助!!!非常感谢!

标签: rggplot2plotmodelmixed

解决方案


推荐阅读