Function used to set up R2D2 priors for population-level effects in brms. The function does not evaluate its arguments -- it exists purely to help set up the model.
R2D2(mean_R2 = 0.5, prec_R2 = 2, cons_D2 = 0.5, autoscale = TRUE, main = FALSE)
Mean of the Beta prior on the coefficient of determination R^2.
Precision of the Beta prior on the coefficient of determination R^2.
Concentration vector of the Dirichlet prior on the variance decomposition parameters. Lower values imply more shrinkage.
Logical; indicating whether the R2D2
prior should be scaled using the residual standard deviation
sigma
if possible and sensible (defaults to TRUE
).
Autoscaling is not applied for distributional parameters or
when the model does not contain the parameter sigma
.
Logical (defaults to FALSE
); only relevant if the R2D2
prior spans multiple parameter classes. In this case, only arguments given
in the single instance where main
is TRUE
will be used.
Arguments given in other instances of the prior will be ignored.
See the Examples section below.
Currently, the following classes support the R2D2 prior: b
(overall regression coefficients), sds
(SDs of smoothing splines),
sdgp
(SDs of Gaussian processes), ar
(autoregressive
coefficients), ma
(moving average coefficients), sderr
(SD of
latent residuals), sdcar
(SD of spatial CAR structures), sd
(SD of varying coefficients).
Even when the R2D2 prior is applied to multiple parameter classes at once,
the concentration vector (argument cons_D2
) has to be provided
jointly in the the one instance of the prior where main = TRUE
. The
order in which the elements of concentration vector correspond to the
classes' coefficients is the same as the order of the classes provided
above.
Zhang, Y. D., Naughton, B. P., Bondell, H. D., & Reich, B. J. (2020). Bayesian regression using a prior on the model fit: The R2-D2 shrinkage prior. Journal of the American Statistical Association. https://arxiv.org/pdf/1609.00046.pdf
Aguilar J. E. & Bürkner P. C. (2022). Intuitive Joint Priors for Bayesian Linear Multilevel Models: The R2D2M2 prior. ArXiv preprint. https://arxiv.org/pdf/2208.07132.pdf
set_prior(R2D2(mean_R2 = 0.8, prec_R2 = 10))
#> b ~ R2D2(mean_R2 = 0.8, prec_R2 = 10)
# specify the R2D2 prior across multiple parameter classes
set_prior(R2D2(mean_R2 = 0.8, prec_R2 = 10, main = TRUE), class = "b") +
set_prior(R2D2(), class = "sd")
#> prior class coef group resp dpar
#> R2D2(mean_R2 = 0.8, prec_R2 = 10, main = TRUE) b
#> R2D2() sd
#> nlpar lb ub source
#> <NA> <NA> user
#> <NA> <NA> user