Thank you @spinkney for responding to my request and for the update.
I have installed the branch, and it works fine. I’m now testing nonlinear models.
One issue I’ve run into is that I can’t use a prior that has been passed to the data block. For example, if I create:
stanvar(x = array(8.51), name = "prior_ult", block = "data")
and then try to use it in the prior via:
prior(normal(prior_ult, 0.25), nlpar = "ult")
it seems the prior must be a numeric value such as 8.51 and not a symbol like prior_ult. Could you advise on the intended way to pass such data-block priors into nonlinear parameters in this branch?
Here is the example code to reproduce the error:
library(brms)
form_loss <- bf(
cum ~ exp(ult) *
(1 - exp(-(dev / exp(theta))^exp(omega))),
# ult, omega, and theta are now on log scales
ult ~ 1 + (1 | gr(AY, s2z = TRUE, center = FALSE)),
omega ~ 1 + (1 | gr(AY, s2z = TRUE, center = FALSE)),
theta ~ 1 + (1 | gr(AY, s2z = TRUE, center = FALSE)),
nl = TRUE
)
prior_loss <- c(
prior(normal(prior_ult, 0.25), nlpar = "ult"), # log(5000)
# prior(normal(8.51719319141624, 0.25), nlpar = "ult"), # log(5000)
prior(normal(0, 0.5), nlpar = "omega"), # log(1)
prior(normal(3.80666248977032, 0.3), nlpar = "theta"), # log(45)
prior(exponential(2), class = "sd", group = "AY",
nlpar = "ult"),
prior(exponential(2), class = "sd", group = "AY",
nlpar = "omega"),
prior(exponential(2), class = "sd", group = "AY",
nlpar = "theta"),
prior(normal(0, 500), class = "sigma")
)
fit_loss_s2z <- brm(
form_loss,
data = loss,
family = gaussian(),
stanvars = stanvar(x = array(8.51), name = "prior_ult", block = "data"),
prior = prior_loss,
backend = "cmdstanr",
chains = 4,
cores = 4,
iter = 1000,
control = list(
adapt_delta = 0.8,
max_treedepth = 10
)
)
Error in `stop_re_s2z()`:
! All arguments of population-level priors used with the sum-to-zero parameterization must currently be numeric constants (coefficient 'Intercept').
S2Z capability 'active_prior_arguments' is unavailable for response 'cum', family 'gaussian', dpar 'mu', nlpar 'ult', group 'AY', ID '1', coefficient(s) 'Intercept', prior 'normal(prior_ult,0.25)'. Remedy: replace symbolic arguments with finite numeric constants.
Run `rlang::last_trace()` to see where the error occurred.
