I want to plot my model regressions with confidence intervals.
I have used ggplot but it only shows the confidence intervals for one of my two categories. Could it be that the range of standard error for one category is too small relative to the other and that's why ggplot only displays confidence intervals for one?
When I plot the two categories separately then I get confidence intervals but when I merge them into one plot in ggplot then only one of them is displayed with confidence intervals.
I want to plot the linear regression of the how food consumption rate changes with increasing temperature (temp) and compare this between two day types .
This is my model: m1 <- glmmPQL(totbeakfuls ~ scale(temp)*day.type + offset(log(duration/60)), random=~1|birdid, family=quasipoisson(link="log"),data = focaldata)
Then I use ggeffects to produce predictions of my model, taking to account that it is an interaction model between day type and temperature.
dat<- ggeffects::ggpredict(m1, terms = c("temp", "day.type"), type = "re")
As I said in a comment on Stack Overflow, you need to calculate your CI from your model. Right now you are having geom_smooth() calculate the standard error based on a linear model fit to your predictions with lm(). Ideally ggpredict() will calculate the CI for you (I haven't checked the documentation), which should make things a little more straightforward.
I show a basic example of adding CI calculated from the model with geom_ribbon() in this section of a blog post, which may help demonstrate the concept.
Just to follow up, I looked at the "Examples" section of the documentation for ggpredict() and I think the closest example to what you are trying to do in terms of plotting is this:
Hey thank you for your reply. Your suggestion does work however the predicted confidence intervals look really weird. The predictions are all less than 0 which is correct because I'm predicting a rate. But then my confidence intervals go up to 150 max. So I'm trying to just find different code for confidence intervals for glmpql models to see if they all predict confidence intervals in the same range. But your suggestion works. Finding code that works for Glmmpql models is really difficult from my experience.