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

Should Liesel.model be more strict about consistent parameter and observed nodes? #206

Open
jobrachem opened this issue Aug 28, 2024 · 0 comments
Labels
comp:model This issue is related to the model module

Comments

@jobrachem
Copy link
Contributor

jobrachem commented Aug 28, 2024

At the moment, Liesel lets you initialize a variable with a distribution without declaring it as a parameter or an observed variable. This can lead to inconsistencies in the model, such that it could be that:

lsl.Model.log_prob ≠ (lsl.Model.log_lik + lsl.Model.log_prior)

i.e. the posterior is not equal to the likelihood plus the prior. This is, because the log_lik and log_prior attributes rely on the lsl.Var.parameter and lsl.Var.observed attributes to identify the variables to count for the respective values.

Possible options would be:

  • Add parameter: bool and observed: bool as init arguments to lsl.Var.
    • raise an error with both are true.
    • raise an error if the variable is being initialized with a distribution and both parameter and observed are false.
    • Loophole: For parameters with a constant prior, you do not usually specify a distribution. So these parameters are not covered by this case: you could have a lsl.Var object that should be a parameter, but that does not have a distribution. At the moment, nothing bad will happen as a result - but it is a little unsatisfying to me.
  • Check for consistent decomposition of the log_prob in the lsl.Model initialization. Raise an error if the decomposition is inconsistent.
    • The same constant-prior-loophole as above applies.
    • Loophole: If a Var with .parameter=False just so happens to have Var.log_prob = 0.0, the test will not discover an inconsistency in the log prob decomposition caused by this var.

I am not sure if this should be solved with code, but I'd like to discuss the issue.

@jobrachem jobrachem added the comp:model This issue is related to the model module label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:model This issue is related to the model module
Projects
None yet
Development

No branches or pull requests

1 participant