From 025ae0ee907b4fdf6da6502766e328046fb1fcaa Mon Sep 17 00:00:00 2001 From: julianlheureux <“lheureuxjulian@gmail.com”> Date: Wed, 28 Aug 2024 15:00:47 -0300 Subject: [PATCH] Add docstring --- bambi/backend/utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bambi/backend/utils.py b/bambi/backend/utils.py index 94915e06..625afad3 100644 --- a/bambi/backend/utils.py +++ b/bambi/backend/utils.py @@ -7,6 +7,26 @@ def horseshoe(name, tau_nu=3, lam_nu=1, dims=None): + """Simulate a beta coefficient value with a horseshoe prior. + This is an internal function which is not supposed to be used by users. + This will be used only when a horseshoe prior is called for beta coefficients. + + Parameters + ---------- + name: str + is the name of the parameters as registered in the PyMC model + tau_nu: int, float + Degrees of freedom of tau. Default: 3 + lam_nu: int, float + Degrees of freedom of lam. Default: 1 (equivalent to a HalfCauchy) + dims: str + dimensions passed to PyMC. Default: None + + Returns + ------ + np.ndarray + Array with the beta coefficient simulated. + """ tau = pm.HalfStudentT(f"{name}_tau", nu=tau_nu) lam = pm.HalfStudentT(f"{name}_lam", nu=lam_nu, dims=dims) beta_raw = pm.Normal(f"{name}_raw", 0, 1, dims=dims)