Can I enforce different priors (e.g. lower bounds for some parameters) for cox proportional hazard model in `brms`?

Hello! I have questions about employing different priors (e.g. lower bounds for some parameters) for cox proportional hazard model. From #86 and Prior Truncation in brms [lb,ub], I get the guidances to employ the nonlinear model syntax to specify different priors (lower bounds for some parameters) for cox proportional hazard model. So I have the following trials:

library(brms)
set.seed(1234)

data(kidney)
str(kidney)

# set different priors
priors <- c(
  set_prior("lognormal(0, 1)", class = "b", lb = 0, nlpar = "etax"),
  set_prior("normal(0, 1)", class = "b", ub = 1, nlpar = "etay"),
  set_prior("normal(0, 1)", class = "b", nlpar = "rest")
)


# both trials have errors
#  Trial 1
fit_coxph_brms_1 <- brm(
  bf(time | cens(censored) ~ rest + etax + etay, nl = TRUE) +
    lf(rest ~ 1 + age) +
    lf(etax ~ 0 + sex) +
    lf(etay ~ 0 + disease),
  data = kidney, family = brmsfamily("cox"), ,
  prior = priors
)


# Trial 2
fit_coxph_brms_1 <- brm(bf(time | cens(censored) ~ age + rest + etax + etay,
  rest ~ 1 + age,
  etax ~ 0 + sex, etay ~ 0 + disease,
  nl = TRUE
),
data = kidney, family = brmsfamily("cox"), ,
prior = priors
)

# Compiling Stan program...
# Start sampling
# Error in mod$fit_ptr() :
#   Exception: variable does not exist; processing stage=data initialization;
# variable name=Kbhaz; base type=int  (in 'model44bc658c9cf5_8367535651e62a616
# ff4442b18259879' at line 54)

My environment:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] brms_2.13.5    Rcpp_1.0.5.2   nvimcom_0.9-58

loaded via a namespace (and not attached):
 [1] Brobdingnag_1.2-6    splines_4.0.2        jsonlite_1.7.0       gtools_3.8.2         StanHeaders_2.21.0-6 RcppParallel_5.0.2   threejs_0.3.3
 [8] shiny_1.5.0          assertthat_0.2.1     stats4_4.0.2         backports_1.1.8      pillar_1.4.6         lattice_0.20-41      glue_1.4.1
[15] digest_0.6.25        promises_1.1.1       colorspace_1.4-1     htmltools_0.5.0      httpuv_1.5.4         Matrix_1.2-18        plyr_1.8.6
[22] dygraphs_1.1.1.6     pkgconfig_2.0.3      rstan_2.21.2         purrr_0.3.4          xtable_1.8-4         mvtnorm_1.1-1        scales_1.1.1
[29] processx_3.4.3       later_1.1.0.1        tibble_3.0.3         splines2_0.3.1       bayesplot_1.7.2      generics_0.0.2       ggplot2_3.3.2
[36] ellipsis_0.3.1       DT_0.14              withr_2.2.0          shinyjs_1.1          cli_2.0.2            survival_3.1-12      magrittr_1.5
[43] crayon_1.3.4         mime_0.9             ps_1.3.3             fansi_0.4.1          nlme_3.1-148         xts_0.12.1           pkgbuild_1.1.0
[50] colourpicker_1.0     rsconnect_0.8.16     tools_4.0.2          loo_2.3.1            prettyunits_1.1.1    lifecycle_0.2.0      matrixStats_0.56.0
[57] stringr_1.4.0        V8_3.2.0             munsell_0.5.0        callr_3.4.3          compiler_4.0.2       rlang_0.4.7          grid_4.0.2
[64] ggridges_0.5.2       htmlwidgets_1.5.1    crosstalk_1.1.0.1    igraph_1.2.5         miniUI_0.1.1.1       base64enc_0.1-3      codetools_0.2-16
[71] gtable_0.3.0         inline_0.3.16        abind_1.4-5          curl_4.3             markdown_1.1         reshape2_1.4.4       R6_2.4.1
[78] gridExtra_2.3        rstantools_2.1.1     zoo_1.8-8            bridgesampling_1.0-0 dplyr_1.0.0          fastmap_1.0.1        shinystan_2.5.0
[85] shinythemes_1.1.2    stringi_1.4.6        parallel_4.0.2       vctrs_0.3.2          tidyselect_1.1.0     coda_0.19-3

Well, could you please help for this problem? By the way, could I get a more detailed instructions about how you implement the Bayesian cox proportional hazard model? For example, about the introduction of the model parameters (e.g. Kbhaz) or data inputs. Thanks so much!

My first guess would be that the cox family doesn’t yet play nicely with the non-linear syntax (this is potentially a bug @paul.buerkner should know about)… Maybe there is an easy fix, but I don’t understand this enough to be able to tell whether making such models work would be a ton of work or just a minor tweak.

It might be possible to eventually have the coefficient-specific lower/upper bounds as new versions of Stan support providing an array of lower bounds, so it might get eventually implemented in brms as well, but I don’t think it is currently ready…