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

[BUG] Incorrect Posterior Probability with dnUniformInteger and mvRandomIntegerWalk #435

Open
minghao-du opened this issue Mar 21, 2024 · 5 comments

Comments

@minghao-du
Copy link

minghao-du commented Mar 21, 2024

Describe the bug
When using dnUniformInteger and mvRandomIntegerWalk, it is not possible to obtain the correct posterior probability.

To Reproduce
I generated 1000 samples ($y_i, i=1,...,1000$) from a Bernoulli distribution with $p=0.1$ and conducted inference on $p$.
$$y_i \sim \text{Bernoulli}(p)$$

$$p_\text{int} \sim \text{UniformInteger}(0,10)$$

$$p \coloneqq \frac{p_\text{int}}{10}$$

However, the inferred posterior distribution of $p_\text{int}$ is almost the same as the prior, uniformly distributed between $0$ and $10$, rather than being mostly $1$.
image

When inferring directly using a uniform distribution, there is no problem with the inference.
$$y_i \sim \text{Bernoulli}(p)$$

$$p_\text{int} \sim \text{Uniform}(0,10)$$

$$p \coloneqq \frac{p_\text{int}}{10}$$

The scripts used and the output are in this file.
UniInt_bug.zip

Expected behavior
When inferring using a UniformInteger distribution, the inferred $p_\text{int}$ is $1$.

Computer info
I am using a Mac, and the version of RevBayes I am using is development (rapture-2388-ge4baa8).

@bredelings
Copy link
Contributor

Note that the Posterior and Likelihood are constant. So they aren't getting updated when p_int changes. This is the underlying source of the problem.

I tweaked the script to replace the collection of Bernoulli observations with a single Binomial observation, and the problem doesn't go away. So this could possibly be a problem with mvRandomIntegerWalk( )... but I'm not sure how the move can prevent the likelihood and prior from changing.

@bjoelle
Copy link
Contributor

bjoelle commented Apr 4, 2024

This seems tied to the model() call

  • when using model(uni_int) as in the example script, p_estimated and the Bernouilli distribution do not get integrated into the model (so uni_int updates but then nothing else does)
  • when using model(p_estimated) or model(y), the graph does get included correctly, but uni_int is set as constant and loses its prior distribution (so uni_int doesn't update and neither does anything else)
  • when using model(data), it gives the error "Cannot find node with name 'uni_int' in the model but received a move working on it." so I'm assuming it just lost uni_int entirely

Overall, there seems to be something weird going on with understanding the graph, tied to (I assume) deterministic nodes and/or integer parameters

@bredelings
Copy link
Contributor

Interestingly, it looks like this problem seems not to happen if the integer distribution is dnPoisson( ) instead of dnUniformInteger( ).

@bredelings
Copy link
Contributor

Here's what we see if dnPoisson is used (and the sample size is changed to 10:
Screenshot from 2024-04-09 16-52-22

@bredelings
Copy link
Contributor

Here is what we see if dnUniformInteger is used:
Screenshot from 2024-04-09 16-53-30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants