Help with formula notation for multivariate model in brms vignette

I’m trying to understand the multivariate model formula implied by fit3 from the brms vignette on multivariate models. To bring everything into one place from that vignette, that model can be reproduced by running the following:

library(brms)
data("BTdata", package = "MCMCglmm")

bf_tarsus <- bf(tarsus ~ sex + (1|p|fosternest) + (1|q|dam)) +
  lf(sigma ~ 0 + sex) +
  skew_normal()
bf_back <- bf(back ~ s(hatchdate) + (1|p|fosternest) + (1|q|dam)) +
  gaussian()

fit3 <- brm(
  bf_tarsus + bf_back + set_rescor(FALSE), 
  data = BTdata, chains = 2, cores = 2,
  control = list(adapt_delta = 0.95)
)

If I’m following the narrative & syntax correctly, this model implies correlations between parameters in the tarsus and back components of the multivariate model. Specifically, the “random” effects of fosternest and dam are correlated among model components and are linked by |p| and |q|, respectively. Using the fitted coefficients and the prior summary tables,

summary(fit3)
prior_summary(fit3)

I think the formula notation should be something like*:

\begin{aligned} \text{tarsus}_i &\sim \text{SkewNormal}(\xi_i,\omega^2_i, \vartheta) \\ \xi_i &= \alpha^t + \beta^t_{\text{sex}[i]}A_i + \alpha_{\text{fosternest}[i]}^\text{t} + \alpha_{\text{dam}[i]}^\text{t} \\ \omega^2_i &= \gamma^t_{\text{sex}[i]}A_i \\ \left(\beta^t,\gamma^t\right) &\sim \text{Student}(3,0,10) \\ \vartheta &\sim \text{Normal}(0, 4) \\ \text{back}_i &\sim \text{Normal}(\mu_i,\sigma) \\ \mu_i &= \beta^b_\text{hatchdate[1]} + \sum_{k=1}^Kb_kz_{ik}+ \alpha_{\text{fosternest}[i]}^\text{b} + \alpha_{\text{dam}[i]}^\text{b} \\ \left(\beta^b_\text{hatchdate[1]},b_k,\sigma\right) &\sim \text{Student}(3,0,10) \\ \left[\begin{matrix} \alpha_{\text{fosternest}}^\text{t} \\ \alpha_{\text{fosternest}}^\text{b} \end{matrix}\right] &\sim \text{MVNormal}\left(\left[\begin{matrix} 0 \\ 0 \end{matrix}\right], \mathbf{S}_\text{fosternest}\right) \\ \left[\begin{matrix} \alpha_{\text{dam}}^\text{t} \\ \alpha_{\text{dam}}^\text{b} \end{matrix}\right] &\sim \text{MVNormal}\left(\left[\begin{matrix} 0 \\ 0 \end{matrix}\right], \mathbf{S}_\text{dam}\right) \\ \mathbf{S}_\text{fosternest} &= \left(\begin{matrix} \sigma_{\alpha_\text{fosternest}^t} & 0 \\ 0 & \sigma_{\alpha_\text{fosternest}^b} \end{matrix}\right) \mathbf{R}_\text{fosternest} \left(\begin{matrix} \sigma_{\alpha_\text{fosternest}^t} & 0 \\ 0 & \sigma_{\alpha_\text{fosternest}^b} \end{matrix}\right) \\ \mathbf{S}_\text{dam} &= \left(\begin{matrix} \sigma_{\alpha_\text{dam}^t} & 0 \\ 0 & \sigma_{\alpha_\text{dam}^b} \end{matrix}\right) \mathbf{R}_\text{dam} \left(\begin{matrix} \sigma_{\alpha_\text{dam}^t} & 0 \\ 0 & \sigma_{\alpha_\text{dam}^b} \end{matrix}\right) \\ \left(\mathbf{R}_\text{fosternest},\mathbf{R}_\text{dam}\right) &\sim \text{LKJcorr}(1) \end{aligned}

My questions:

1. Is this the correct correlation structure implied by the brms model syntax in the vignette? I’ve largely followed this example from Solomon’s Statistical Thinking Recoded.
2. How should the GAMM smooth term be expressed in the formula? I’m especially unsure about how to express (a) the population-level effect for back_shatchdate_1 that appears in the model summary table and (b) the additive term for class sds. What you see in the formula above is what I managed to (feebly) adapt from Crainiceanu et al. (2005) J Stat Soft.
3. Is there a way to adapt this model to infer the number of knots (K) for the smooth term? I’d be interested in both the brms and formula syntax to accomplish this.

I’m grateful for any help you’re able to offer.

*Notation: I’ve substituted \vartheta in for the shape parameter of the skew normal distribution (usually called \alpha). Superscripts on model parameters refer to ^t tarsus and ^b back, respectively.

  • Operating System: OSX 10.14.6
  • brms Version: 2.11.6
2 Likes

Hi!

  1. Yes, this looks like the correct correlation structure.
  2. There is some nice paper introducitng splines here that might help you: https://peerj.com/articles/6876/
  3. I am not sure if knots are usually “inferred” in the context of splines brms uses. Since brms relies on mgcv for all the handling of splines, its documentation should be the best place to start.
2 Likes