Repository navigation
Keep each node's own theta and block when sorting nodes - #71
Draft
alexpghayes wants to merge 1 commit into
Draft
alexpghayes wants to merge 1 commit into
alexpghayes wants to merge 1 commit into
Conversation
With sort_nodes = TRUE, dcsbm() and the co-factor branch of directed_dcsbm() sorted z first and then laid theta onto the sorted memberships in input order, so block 1 always got the first block_sizes[1] elements of theta. Unsorted models assigned theta to blocks at random, so sorted and unsorted models differed whenever theta was not exchangeable (e.g. sorted theta). Permute z and theta together from node order instead. This intentionally changes seeded output of sorted models with non-constant theta; regenerate the two sorted directed reference pins. 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.
Stacked on #70. The base is
fix/zero-theta; retarget it tomainonce #70 is merged.Bug
With
sort_nodes = TRUE(the default),dcsbm()and the co-factor branch ofdirected_dcsbm()sortedzfirst and then laidthetaonto the sorted memberships in input order. So block 1 always got the firstblock_sizes[1]elements oftheta, and so on:Sorted and unsorted models are therefore different models whenever
thetaisn't exchangeable, e.g. if it's sorted or correlated with anything the user cares about. Constanttheta(all SBMs, planted partitions) is unaffected.Fix
Permute
zandthetatogether from node order withorder(z, -theta), without pre-sortingz. This is what the shared-blocks branch ofdirected_dcsbm()already does, and it is the fix the maintainer picked for zero theta (#70). #70 kept the old positional pairing so that it didn't change any seeded output; this PR changes the pairing.Sorted models with non-constant
thetanow give different graphs for a given seed. The two sorted pins intest-directed-sbms.Rare regenerated (the sorted default, and explicitpi, renamed from "is unchanged" to "is pinned"). The comment there explains why. The unsorted pin is unchanged. As a check, the new sorted default pin'stheta_outvalues are a permutation of the unsorted pin's within each block, which is what correct pairing should give.If you'd rather not change seeded output in 1.0.0, close this; #70 stands on its own.
Tests
New test in
tests/testthat/test-block-and-theta-order.R: with equal block sizes (so no relabeling), the sorted model's(z, theta)pairs equal the unsorted model's, fordcsbm()and both sides ofdirected_dcsbm(), with and withoutforce_identifiability. Fails on #70's branch (8 failures), passes here. Full suite passes. Noman/changes.NEWS
Left out to avoid conflicting with #59. Suggested bullet under Bug fixes (or Breaking changes, since seeded output changes):
🤖 Generated with Claude Code