Loglogistic as a Custom Distribution Family for brms
Source:R/dist-loglogistic.R
brms_custom_loglogistic.RdReturns the custom_family + stanvars pair required to fit a
brms model with a Loglogistic response distribution. The Stan code
is loaded from inst/stan/loglogistic.stan via
build_brms_custom_family; post-processing functions
(log_lik, posterior_predict, posterior_epred) are
wired in automatically.
Value
A list with elements custom_family and
stanvars_family ready for use with brms::brm(). The
returned custom_family object has log_lik,
posterior_predict, and posterior_epred registered so
that brms::loo(), brms::posterior_predict(), and
brms::posterior_epred() work without further setup.
Examples
# \donttest{
library(hbsaems)
library(brms)
#> Loading required package: Rcpp
#> Loading 'brms' package (version 2.23.0). Useful instructions
#> can be found by typing help('brms'). A more detailed introduction
#> to the package is available through vignette('brms_overview').
#>
#> Attaching package: ‘brms’
#> The following object is masked from ‘package:stats’:
#>
#> ar
ll <- brms_custom_loglogistic()
# fit <- brm(y ~ x, data = d,
# family = ll$custom_family,
# stanvars = ll$stanvars_family)
# loo(fit) # uses log_lik_loglogistic
# posterior_predict(fit) # uses posterior_predict_loglogistic
# posterior_epred(fit) # uses posterior_epred_loglogistic
# }