Applied-Longitudinal-Data-Analysis-with-brms-and-the-tidyverse
Applied-Longitudinal-Data-Analysis-with-brms-and-the-tidyverse copied to clipboard
Ch 7
trafficstars
- Add a basic line plot of the
opposites_ppdata at the top of the chapter, something like
opposites_pp %>%
ggplot(aes(x = time, y = opp, group = id)) +
geom_line(size = 1/4, alpha = 1/4)
- Somewhere toward the end of the chapter, explicitly mention how the alternatives to the standard multilevel model of change do not have
id-specific equations (what frequentists would call empirical Bayes).
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.