I’ve created a model using the glmmTMB R package which produces acceptable results. My model uses several years of data. The years are included as a random intercept.
I have plotted the model using the jtools package, which uses GGPLOT. I’m happy with the combined year plot. Next, I want to plot the individual years using GGPLOT’s facet wrap function. The manual indicates that I should be able to do this (P34):
groups: If you would like to have facets (i.e., separate panes) for different groups of coefficients, you can specify those groups with a list here. See details for more on how to do this. facet.rows The number of rows in the facet grid (the nrow argument to ggplot2::facet_wrap()). facet.cols The number of columns in the facet grid (the nrow argument to ggplot2::facet_wrap())
Example code:
data(mpg)
fit <- glmmTMB(cty ~ displ + (1 | year), data = mpg)
jtools::effect_plot(fit, pred = displ,
interval = TRUE,
groups = list(year = unique(mpg$year)))
I've tried a few variations on the following code:
effect_plot(
fit,
pred = displ,
interval = TRUE,
groups = unique(mpg$year))
I've also using '+ facet_wrap(~year, scales = "free_y", ncol = 2)' but it produces the same plot given in my example code.
Can anyone shed any light on how to resolve this?
Thanks in advance.