Repository navigation
Error on Bernoulli edge probabilities of 1; check poisson_edges first - #72
Draft
alexpghayes wants to merge 1 commit into
Draft
alexpghayes wants to merge 1 commit into
alexpghayes wants to merge 1 commit into
Conversation
The Bernoulli check in undirected_factor_model() and directed_factor_model() used `max(S) > 1`, so a probability of exactly 1 passed and became an infinite Poisson rate via -log(1 - S), failing later in sample_sparse() with "missing value where TRUE/FALSE needed". Error when any probability is >= 1. Also check `poisson_edges` and `allow_self_loops` with check_flag() before they are used: `if (!poisson_edges)` ran before validation, so values like "yes" or NA failed with cryptic base R errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugs
Probability 1 (bug 3 of the handoff):
undirected_factor_model()anddirected_factor_model()checkedmax(S) > 1, so a probability of exactly 1 passed and became-log(1 - 1) = Inf.Non-logical
poisson_edges(bug 15):poisson_edges = "yes"gave "invalid argument type", andNAgave "missing value…", becauseif (!poisson_edges)ran before the validator.Fix
>= 1: "Elements ofS(after … scaling to achieve expected degree or density) must be less than 1 for Bernoulli graphs (poisson_edges = FALSE)." This covers every model, since they all go through the two factor model constructors, including scaling that reaches exactly 1 (e.g.erdos_renyi(n = 10, expected_degree = 10, poisson_edges = FALSE)). Thepoisson_edgesdocs now say so.check_flag()onpoisson_edgesandallow_self_loopsat the top of both constructors: "poisson_edgesmust beTRUEorFALSE." The directed message no longer mentions symmetrizing.Tests
New
tests/testthat/test-bernoulli-probability-one.R. Fails onmain(6 failures, 1 error), passes here. Full suite passes. Docs regenerated with roxygen2 7.3.2.Interaction with #66
#66 makes
erdos_renyi()/directed_erdos_renyi()requirep < 1for Bernoulli graphs. That is consistent with this PR, and the two PRs touch different files.NEWS
Left out to avoid conflicting with #59. Suggested bullet under Bug fixes:
🤖 Generated with Claude Code