Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Horseshoe Prior #836

Merged
merged 19 commits into from
Sep 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding horseshoe prior and example2
julianlheureux committed Aug 23, 2024

Verified

This commit was signed with the committer’s verified signature.
torkelrogstad Torkel Rogstad
commit b5c8d4f46550f0fb234047a6c40835948e887a45
10 changes: 6 additions & 4 deletions bambi/backend/utils.py
Original file line number Diff line number Diff line change
@@ -5,14 +5,16 @@
import pytensor.tensor as pt
import pymc as pm

def Horseshoe(name, tau_nu = 3, lam_nu = 1, dims=None):

def horseshoe(name, tau_nu=3, lam_nu=1, dims=None):
tau = pm.HalfStudentT(f"{name}_tau", nu=tau_nu)
lam = pm.HalfStudentT(f"{name}_lam", nu=lam_nu, dims=dims)
lam = pm.HalfStudentT(f"{name}_lam", nu=lam_nu, dims=dims)
beta_raw = pm.Normal(f"{name}_raw", 0, 1, dims=dims)
beta = pm.Deterministic(name, beta_raw * tau ** 2 * lam ** 2, dims=dims)
beta = pm.Deterministic(name, beta_raw * tau**2 * lam**2, dims=dims)
return beta

MAPPING = {"Cumulative": pm.Categorical, "StoppingRatio": pm.Categorical, "Horseshoe": Horseshoe}

MAPPING = {"Cumulative": pm.Categorical, "StoppingRatio": pm.Categorical, "Horseshoe": horseshoe}


def get_distribution(dist):