Skip to content

Interrupted time series on grouped data with count outcome in glmmTMB

3 messages · Sokolovsky, Alexander, Ben Bolker

#
Hi all,

This is my first time sending a question to this list so apologies if I
miss something that is typically expected. I am trying to fit an
interrupted time series type model on grouped data (by individual).
Specifically, I am modeling compliance with a remote survey tool that
delivered 5 surveys a day for 28 days across two bursts. The outcome
variable is a count of missed surveys on days with any engagement (so range
0-4) (https://i.stack.imgur.com/FThRs.png). Ignoring covariates, the three
focal predictors are thus time (studyday_new), burst (wave), and time after
burst 2 starts (studyday_new_post). The model is specified as follows (and
I acknowledge I could be making a mistake here, I tried to follow Ben
Bolker's thoughts on fitting this models with temporal autocorrelation in
glmmTMB from
https://bbolker.github.io/mixedmodels-misc/notes/corr_braindump.html):

mod1_mde <- glmmTMB(missed_surveys ~ w1age + school + w1sex + w1hislat +
w1racer + studyday_new + wave + studyday_new_post + ar1(studyday_new_t +
0|id) + (1 |id), data = daily_data3_mde, family = "poisson")

This model converges. But when I plot the predicted values
(using ggpredict from ggeffects) over the observed daily means, the
predicted values appear to be underestimating the observed means.

Here is the plot: https://i.stack.imgur.com/bRfue.png

Now what's interesting to me is that when I fit this model to a gaussian
distribution instead, the resulting predicted values are reasonable:
https://i.stack.imgur.com/rIYnZ.png

And when I fit this model to a poisson distribution but exclude the AR
covariance structure and random intercept (both of which are obviously
critical) I also get reasonable predicted values:
https://i.stack.imgur.com/dWlho.png

(Please ignore the different labels on the plots I just copied the syntax
from other parts of my code when I was writing it).

So is there something I'm missing about getting predicted values from this
model?

All the best,
-- Alex
#
Check the section on "bias adjustment" in the emmeans vignette:

https://cran.r-project.org/web/packages/emmeans/vignettes/transformations.html#bias-adj

   I think? you can probably pass these options through ggpredict ...
On 2023-08-22 9:48 p.m., Sokolovsky, Alexander wrote:
#
Hello Ben,

Thanks for the reply I totally missed the part on "bias adjustment"; this
seems to have done the trick. Wasn't able to figure out how to send it
through to emmeans from ggmeans for whatever reason, but I just went
through the emmeans vignette to get them. Appreciate your help and I'll
avoid cross-posting in the future.

All the best,
-- Alex
On Tue, Aug 22, 2023 at 9:59?PM Ben Bolker <bbolker at gmail.com> wrote: