I am trying to create a plot of predicted probabilities from a generalised multilevel linear model (random intercept) using sjPlot
package. I want to plot the effect of an interaction term. I am attempting to change the C.I. level, which I assume is 95% by default (the documentation of the package is not very clear about this...). However, the C.I.s do not seem to change. I reproduced what I am trying to do using the iris
dataset, to show what I mean. Below you can find the code:
library(patchwork)
library(lme4)
library(sjPlot)
data(iris)
iris$dummy <- rbinom(150, 1, 0.5)
iris$group <- round(runif(150, 1, 4), 0)
iris$Petal.Width <- as.factor(iris$Petal.Width)
iris$dummy <- as.factor(iris$dummy)
iris$group <- as.factor(iris$group)
model <- glmer(dummy ~ (1 | group) + Sepal.Width*Species, family = binomial, data = iris)
summary(model)
plot1 <- plot_model(model,
type = "pred",
terms = c("Sepal.Width[all]", "Species"))
plot2 <- plot_model(model,
type = "pred",
terms = c("Sepal.Width[all]", "Species"),
ci.lvl = 0.8)
plot1 + plot2
The two plots, plot1
and plot2
look exactly the same to me. How can I make this work? Thanks!
You want to pass the argument down to the ggeffects
package, where the argument is ci_level
.
library(sjPlot)
library(patchwork)
library(lme4)
plot1 <- plot_model(model,
type = "pred",
terms = c("Sepal.Width[all]", "Species"))
plot2 <- plot_model(model,
type = "pred",
terms = c("Sepal.Width[all]", "Species"),
ci_level = 0.8)
plot1 + plot2
Created on 2024-07-22 with reprex v2.1.0