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

Syntax issues when defining hyperpriors #450

Open
gingjehli opened this issue May 30, 2024 · 4 comments
Open

Syntax issues when defining hyperpriors #450

gingjehli opened this issue May 30, 2024 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation upstream Related to upstream packages

Comments

@gingjehli
Copy link

Michael and I just noticed the following syntax issue for prior specification.
Specifically, it matters whether one uses: "1 |participant_id" or "1|participant_id".

Example with the spacing:

sm6 = hssm.HSSM( data=data, include=[ { "name": "v", "formula": "v ~ 0 + (1 | participant_id)", "prior": { "1 |participant_id": {"name": "Normal", "mu": {"name": "Normal", "mu": 1, "sigma": 2, "initval": 1}, "sigma": {"name": "HalfNormal", "sigma": 1 }, }, }, }, ], noncentered = False, )

provides this output:

v: Formula: v ~ 0 + (1 | participant_id) Priors: v_1|participant_id ~ Normal(mu: 0.0, sigma: HalfNormal(sigma: 2.5)) Link: identity Explicit bounds: (-inf, inf)

Example without the spacing:

sm6 = hssm.HSSM( data=data, include=[ { "name": "v", "formula": "v ~ 0 + (1 | participant_id)", "prior": { "1|participant_id": {"name": "Normal", "mu": {"name": "Normal", "mu": 1, "sigma": 2, "initval": 1}, "sigma": {"name": "HalfNormal", "sigma": 1 }, }, }, }, ], noncentered = False, )

provides this output:

v: Formula: v ~ 0 + (1 | participant_id) Priors: v_1|participant_id ~ Normal(mu: Normal(mu: 1.0, sigma: 2.0, initval: 1.0), sigma: HalfNormal(sigma: 1.0)) Link: identity Explicit bounds: (-inf, inf)

note that the model should be specified with hyperpriors (so the example without the spacing is correct!)

@digicosmos86
Copy link
Collaborator

Hi @gingjehli,

This is expected behavior. When specifying priors there should not be spaces. Spaces in formulas are simply parsed out, like in many programming languages, so even if you write (1 | participant_id), the correct name for the term is still 1|participant_id.

I am going to close this issue for now. Please feel free to reopen it if you still run into problems :).

@frankmj
Copy link
Collaborator

frankmj commented May 31, 2024 via email

@digicosmos86
Copy link
Collaborator

Hi Michael,

I agree that it can be confusing that the formula does the parsing but not prior specifications. I think the best solution to this is for bambi to throw an error when there are prior specification without corresponding terms, which it currently doesn't do yet. This will handle this issue and also accidental typos. We could do that but it's probably best to fix this at the bambi level so we don't duplicate the effort.

Let me coordinate with Tomi about this and see what the best way forward. For now, it'd probably be best to document this as a rule in our documentation. I'll work on this.

@digicosmos86 digicosmos86 reopened this May 31, 2024
@digicosmos86 digicosmos86 self-assigned this May 31, 2024
@digicosmos86 digicosmos86 added documentation Improvements or additions to documentation upstream Related to upstream packages labels May 31, 2024
@digicosmos86
Copy link
Collaborator

Bambi issue here bambinos/bambi#815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation upstream Related to upstream packages
Projects
None yet
Development

No branches or pull requests

3 participants