Чтобы выполнить это действие, я изменил структуру для data.frame
и использовал ggplot2
.
library(lme4)
library(ggplot2)
library(scales)
library(sjPlot)
df_test <- data.frame('subj' = c('Joe', 'Joe', 'Moe', 'Moe'), 'A' = c(1, 0, 1, 0), 'B' = c(3, 2, 1, 4))
m <- lme4::glmer(A ~ B + (B | subj), data=df_test, family='binomial')
p <- sjPlot::plot_model(m, type='pred', colors = 'blue')
df <- as.data.frame(p$B$data)
df
ggplot2::ggplot(df, aes(x = x)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), fill = "grey70") +
geom_line(aes(y = predicted), col = "blue") +
scale_y_continuous(labels = scales::percent,
limits = c(0, 1))

ggplot2::ggplot(df, aes(x = x)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high),
fill = "deepskyblue", alpha = 0.25) +
geom_line(aes(y = predicted), col = "darkred") +
scale_y_continuous(labels = scales::percent,
limits = c(0, 1))
