ihmeuw / vivarium_census_prl_synth_pop

US Census Probabilistic Record Linkage synthetic population generation
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Fuzzy checking: Bayesian version #333

Closed zmbc closed 10 months ago

zmbc commented 1 year ago

Fuzzy checking: Bayesian version

Description

Description

Changes and notes

Terminology:

Statistically, this uses Bayesian hypothesis testing. Each check compares two models/hypotheses of the underlying rate, one that represents "if there is a bug" and one that represents "if there is not a bug." We use a simple Jeffreys beta prior for "if there is a bug." For "if there is not a bug" we fit a beta distribution to a 95% confidence interval provided by the user. In both cases, this is then fed through a binomial (creating a beta-binomial) for the actual count data. We fail the tests if any check is "decisive" (Bayes factor > 100) in favor of "there is a bug."

Technically, this uses a pytest fixture that is kept active for the entire test session and allows testing these hypotheses while maintaining a log of information about them. This diagnostic information is output at the end of a test run for optional human inspection. I have gitignored the diagnostic output -- is this the right call?

Verification and Testing

I have verified that these tests pass. I have also verified that they do not pass, even with relatively small population (20k), when I intentionally introduce bugs into the simulation. The two that I tried were:

zmbc commented 1 year ago

Note: I'm currently hoping to get review from RT on this math, both here and in https://github.com/ihmeuw/vivarium_research/pull/1382. Only after that do I think it makes sense for engineering folks to review this for code quality.