Я провожу анализ надежности повторного тестирования и хотел бы знать, влияет ли количество дней на разницу в моих оценках результатов. У меня есть 12 зависимых переменных, которые я хотел бы оценить, поэтому я создал 12 моделей. Я следую шагам, чтобы создать такой сюжет из этого сообщения .
Это сюжет, который я хотел бы создать
#d
lmer_ch_n_d <- lmer(chall_neg_d ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_ch_p_d <- lmer(chall_pos_d ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_cr_n_d <- lmer(crit_neg_d ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_cr_p_d <- lmer(crit_pos_d ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_ch_sc_d <- lmer(chall_score_d ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_cr_sc_d <- lmer(crit_score_d ~ measurement_round + days + (1 | id), data = final_day_diff)
#rt
lmer_ch_n_rt <- lmer(chall_neg_rt ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_ch_p_rt <- lmer(chall_pos_rt ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_cr_n_rt <- lmer(crit_neg_rt ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_cr_p_rt <- lmer(crit_pos_rt ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_ch_sc_rt <- lmer(chall_score_rt ~ measurement_round + days + (1 | id), data = final_day_diff)
lmer_cr_sc_rt <- lmer(crit_score_rt ~ measurement_round + days + (1 | id), data = final_day_diff)
Это мои модели. Теперь я собираюсь добавить прогнозы в свой основной фрейм данных.
pred <- final_long %>%
mutate(
pred = ifelse(final_long$block == "chall_neg" & final_long$measurement_type == "d", predict(lmer_ch_n_d, re.form = NA),
ifelse(final_long$block == "chall_pos" & final_long$measurement_type == "d", predict(lmer_ch_p_d, re.form = NA),
ifelse(final_long$block == "crit_neg" & final_long$measurement_type == "d", predict(lmer_cr_n_d, re.form = NA),
ifelse(final_long$block == "crit_pos" & final_long$measurement_type == "d", predict(lmer_cr_p_d, re.form = NA),
ifelse(final_long$block == "chall_score" & final_long$measurement_type == "d", predict(lmer_ch_sc_d, re.form = NA),
ifelse(final_long$block == "crit_score" & final_long$measurement_type == "d", predict(lmer_cr_sc_d, re.form = NA),
#rt
ifelse(final_long$block == "chall_neg" & final_long$measurement_type == "rt", predict(lmer_ch_n_rt, re.form = NA),
ifelse(final_long$block == "chall_pos" & final_long$measurement_type == "rt", predict(lmer_ch_p_rt, re.form = NA),
ifelse(final_long$block == "crit_neg" & final_long$measurement_type == "rt", predict(lmer_cr_n_rt, re.form = NA),
ifelse(final_long$block == "crit_pos" & final_long$measurement_type == "rt", predict(lmer_cr_p_rt, re.form = NA),
ifelse(final_long$block == "chall_score" & final_long$measurement_type == "rt", predict(lmer_ch_sc_rt, re.form = NA), predict(lmer_cr_sc_rt, re.form = NA)))))))))))),
pred1 = ifelse(final_long$block == "chall_neg" & final_long$measurement_type == "d", predict(lmer_ch_n_d),
ifelse(final_long$block == "chall_pos" & final_long$measurement_type == "d", predict(lmer_ch_p_d),
ifelse(final_long$block == "crit_neg" & final_long$measurement_type == "d", predict(lmer_cr_n_d),
ifelse(final_long$block == "crit_pos" & final_long$measurement_type == "d", predict(lmer_cr_p_d),
ifelse(final_long$block == "chall_score" & final_long$measurement_type == "d", predict(lmer_ch_sc_d),
ifelse(final_long$block == "crit_score" & final_long$measurement_type == "d", predict(lmer_cr_sc_d),
#rt
ifelse(final_long$block == "chall_neg" & final_long$measurement_type == "rt", predict(lmer_ch_n_rt),
ifelse(final_long$block == "chall_pos" & final_long$measurement_type == "rt", predict(lmer_ch_p_rt),
ifelse(final_long$block == "crit_neg" & final_long$measurement_type == "rt", predict(lmer_cr_n_rt),
ifelse(final_long$block == "crit_pos" & final_long$measurement_type == "rt", predict(lmer_cr_p_rt),
ifelse(final_long$block == "chall_score" & final_long$measurement_type == "rt", predict(lmer_ch_sc_rt, re.form = NA), predict(lmer_cr_sc_rt))))))))))))
)
Наконец, я собираюсь создать график
pred %>%
filter(measurement_type == "d") %>%
ggplot(aes(measurement_round, value)) +
geom_point(alpha = 0.3) +
theme_classic() +
geom_line(aes(group = id), alpha = 0.3) +
facet_grid(cols = vars(block)) +
geom_line(colour = "grey", aes(y=pred1, group = id), alpha = 0.1) +
geom_line(colour = "red", aes(y=pred, group=id))
И вот что я получаю. Какие лишние красные линии?