Error message from system
Hello Michael,
I am reading your book Mixed Models with R and trying out your package “visibly”. I have come across the below message, which suggested to report it here:
plot_coefficients(fit2, ranef = TRUE, which_ranef = 'student') Warning message: Using
sizeaesthetic for lines was deprecated in ggplot2 3.4.0. ℹ Please uselinewidthinstead. ℹ The deprecated feature was likely used in the visibly package. Please report the issue at https://github.com/m-clark/visibly/issues. This warning is displayed once every 8 hours. Calllifecycle::last_lifecycle_warnings()to see where this warning was generated.
Kind regards, Emel
Hi Emel, thanks for pointing this out. This package hasn't been updated in many years, so many updates to ggplot and other packages will likely break some of the functionality. In this case, 'size' is no longer used for linewidth for geom_line and similar so probably any functions using those geoms will break. Unfortunately I don't have the time to mess with this package anytime soon.
However you do have options. I recommend easystats for exploring mixed models and they have a similar visualization available via the see package.
https://easystats.github.io/see/articles/parameters.html#including-group-levels-of-random-effects
Unfortunately the recent updates with ggplot2 4.0 seems incompatible with a lot of things (at least for me) and the most recent version of the see package requires it. However I downgraded to the previous versions of both and was able to create the plot that mimics what plot_coefficients does. Here is one example
library(tidyverse)
library(lme4)
library(parameters)
library(see)
model1 = lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy)
RE = model_parameters(model1, group_level=TRUE)
plot(RE |> arrange(Coefficient))
Alternatively you can see the underlying plot code and try and work with that.
https://github.com/m-clark/visibly/blob/master/R/plot_coefs.R
Sorry for the hiccup in your exploration of mixed models!