Skip to content

Document that expectation() is on the Poisson scale - #61

Draft
alexpghayes wants to merge 1 commit into
mainfrom
docs/expectation-poisson-scale
Draft

alexpghayes wants to merge 1 commit into
mainfrom
docs/expectation-poisson-scale

Conversation

@alexpghayes

Copy link
Copy Markdown
Collaborator

expectation() returns P = X S Xᵀ (or X S Yᵀ). That is E[A | X, S] only for Poisson edges. For Bernoulli graphs (poisson_edges = FALSE), S is stored as -log(1 - p), and the sampler keeps one edge whenever a Poisson count is positive, so

E[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:
    • The return value is now described as the Poisson-scale matrix.
    • A new Bernoulli graphs section derives 1 - exp(-P) and explains that expectation() 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 when allow_self_loops = FALSE.
    • The section points to the same Poisson scale in expected_*(), eigs_sym() and svds().
    • New examples compare a Poisson SBM, a Bernoulli SBM, and the recovered B.
  • eigs_sym() / svds() methods: a @note says these are spectra of the Poisson-rate matrix, not of 1 - exp(-P).
  • svds.directed_factor_model(): @param A said "An undirected_factor_model"; it now says directed.

Verification

  • Bernoulli SBM: 1 - exp(-expectation()) recovers B exactly (values 0.1, 0.4, 0.6).
  • Bernoulli DC-SBM with heterogeneous theta, averaged over 20,000 sampled adjacency matrices:
    • 1 - exp(-P) matches every entry, diagonal included (largest |z| over 64 entries = 2.12);
    • P itself is off by up to 1.3.
  • No self-loops: with allow_self_loops = FALSE, the sampled diagonal is all zeros.
  • The examples run, and the docs were regenerated with roxygen2 7.3.2.

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

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

No deployments
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

Successfully merging this pull request may close these issues.

1 participant