0

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")

then I use ggplot to those predictions

ggplot(data = focaldata, aes(x = temp, y = consumption)) +
  geom_point(aes(color = day.type)) +
  geom_smooth(data= dat, method = "lm", 
    aes(x = x, y= predicted, fill= group, color=day.type), 
    se = TRUE)

Even through I specify "se = TRUE" It only plots the confidence intervals for one of the day type categories.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 2
    Without your data, we can't run any of your code or see what's going on. Can you please post a picture of the graph you're seeing, and (preferably) some sample data too to illustrate the issue? Also please include any necessary `library` calls--I'm not familiar with `glmmPQL`. Lastly, if your hypothesis is correct, and your confidence intervals are so tight that they don't show up, what do you want to do? – Gregor Thomas Jul 02 '19 at 15:03
  • If you want to show CI around predictions you'll need to calculate those from your model. That may be an option in `ggpredict()`. If so, get the CI from `ggpredict()` and plot them with `geom_ribbon()` (you'll plot the predicted line with `geom_line()`, not `geom_smooth()`). Otherwise you would need to calculate approximate CI "by hand" along the lines of what's shown in the GLMM FAQ [here](https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#predictions-andor-confidence-or-prediction-intervals-on-predictions). – aosmith Jul 02 '19 at 15:08
  • 1
    How are we supposed to know? We can't see what you're seeing without a reproducible example. – Axeman Jul 02 '19 at 15:08
  • I am new to stackoverflow so I was not allowed to post any pictures. Not sure if I can upload my data but I will try to edit the post. Thank you – miqkayla_with_a_Q Jul 02 '19 at 15:41
  • [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making a reproducible question, including adding data (*not* a picture of it) – camille Sep 15 '19 at 14:25

0 Answers0