ASKurz / Applied-Longitudinal-Data-Analysis-with-brms-and-the-tidyverse

Translating ML into Bayes, one line at a time
https://bookdown.org/content/4253/
Creative Commons Zero v1.0 Universal
75 stars 21 forks source link

Ch 7 #4

Open ASKurz opened 2 years ago

ASKurz commented 2 years ago
opposites_pp %>% 
  ggplot(aes(x = time, y = opp, group = id)) +
  geom_line(size = 1/4, alpha = 1/4)
ASKurz commented 2 years ago

Also, I don't know that S&W made this point, but it is possible to combine their various alternative error structures with random effects. Hoffman (2015) perhaps does a better job at this in Chapter 4, Section 3 (p. 131). You might show how to, say, fit a random intercept model with an AR1 like

fit7.5b <-
  brm(data = opposites_pp,
      family = gaussian,
      opp ~ 0 + Intercept + time + ccog + time:ccog + ar(gr = id, cov = TRUE) + (1 + time | id),
      iter = 2000, warmup = 1000, chains = 4, cores = 4,
      seed = 7,
      control = list(adapt_delta = .999,
                     max_treedepth = 12))

Note my use of control. Even with this setting, the chains still aren't mixing well. You may have to think carefully about regularizing priors.