Where to find the link for the scale parameter in location scale models in `brms`?

I am writing functions to work with location scale models in brms.
What is the best way to identify the link used for the scale parameter, sigma?

If ls.me was a location scale mixed effect model fit in brms, I thought the family element may have info, but although it shows the two parameters, mu and sigma
the identity link is just for mu. The summary() does show that the link for sigma is a log link, but I dug around awhile in the brmsfit model object without success.

ls.me <- brm(bf(
  y ~ 1 + x + (1 + x | ID),
  sigma ~ 1 + x + (1 + x | ID)),
  family = "gaussian",
  data = d, seed = 1234,
  silent = 2, refresh = 0,
  chains = 4L, cores = 4L, backend = "cmdstanr")

> str(ls.me$family)
List of 11
 $ family    : chr "gaussian"
 $ link      : chr "identity"
 $ linkfun   :function (mu)  
 $ linkinv   :function (eta)  
 $ dpars     : chr [1:2] "mu" "sigma"
 $ type      : chr "real"
 $ ybounds   : num [1:2] -Inf Inf
 $ closed    : logi [1:2] NA NA
 $ ad        : chr [1:7] "weights" "subset" "se" "cens" ...
 $ normalized: chr [1:5] "_time_hom" "_time_het" "_lagsar" "_errorsar" ...
 $ specials  : chr [1:2] "residuals" "rescor"
 - attr(*, "class")= chr [1:2] "brmsfamily" "family"

Thanks for any tips or suggestions!

1 Like

After digging in summary.brmsfit it seems a possible solution is:

vapply(
  brmsterms(ls.me$formula)$dpars,
  function(x) x$family$link,
FUN.VALUE = character(1))

Would still appreciate any comments whether using brmsterms() is the best / a reliable way to go.