Repository navigation
Document that expectation() is on the Poisson scale - #61
Draft
alexpghayes wants to merge 1 commit into
Draft
alexpghayes wants to merge 1 commit into
alexpghayes wants to merge 1 commit into
Conversation
expectation() returns P = X S X' (or X S Y'), which is E[A | X, S] only for Poisson edges. For Bernoulli graphs, S is stored as -log(1 - p), so the expected adjacency matrix is 1 - exp(-P). Document this with an example, and add the same note to the eigs_sym() and svds() methods. Also fix svds.directed_factor_model() documenting `A` as an undirected factor model. 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.
expectation()returnsP = X S Xᵀ(orX S Yᵀ). That isE[A | X, S]only for Poisson edges. For Bernoulli graphs (poisson_edges = FALSE),Sis stored as-log(1 - p), and the sampler keeps one edge whenever a Poisson count is positive, soE[A[i, j] | X, S] = P(A[i, j] = 1) = 1 - exp(-P[i, j]).This was undocumented. The test-coverage work in #60 found it while checking Bernoulli models against
expectation().Changes (docs only)
?expectation:1 - exp(-P)and explains thatexpectation()overestimates Bernoulli edge probabilities, by little when probabilities are small. It notes that blockmodels recover the requested probabilities exactly, and that the diagonal is zero whenallow_self_loops = FALSE.expected_*(),eigs_sym()andsvds().B.eigs_sym()/svds()methods: a@notesays these are spectra of the Poisson-rate matrix, not of1 - exp(-P).svds.directed_factor_model():@param Asaid "An undirected_factor_model"; it now says directed.Verification
1 - exp(-expectation())recoversBexactly (values 0.1, 0.4, 0.6).theta, averaged over 20,000 sampled adjacency matrices:1 - exp(-P)matches every entry, diagonal included (largest |z| over 64 entries = 2.12);Pitself is off by up to 1.3.allow_self_loops = FALSE, the sampled diagonal is all zeros.NEWS.md is untouched, to avoid conflicting with the 1.0.0 reorganization in #59. Add a Documentation bullet there if you want one.
🤖 Generated with Claude Code