Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions R/undirected_overlapping_sbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ validate_undirected_overlapping_sbm <- function(x) {
#' the number of nodes (via `n`),
#' the mixing matrix (via `k` or `B`), and the block membership
#' probabilities (optional, via `pi`). In an overlapping stochastic
#' blockmodel, each node can belong to any number of blocks: zero, one,
#' or several. We provide defaults for most of these
#' blockmodel, each node belongs to one or more blocks. We provide defaults for most of these
#' options to enable rapid exploration, or you can invest the effort
#' for more control over the model parameters. We **strongly recommend**
#' setting the `expected_degree` or `expected_density` argument
Expand Down Expand Up @@ -148,8 +147,10 @@ validate_undirected_overlapping_sbm <- function(x) {
#'
#' - `Z`: The block memberships of each node, as an `n` by `k`
#' binary [Matrix::Matrix()]. `Z[i, j]` is one if node `i` belongs
#' to block `j` and zero otherwise. Rows can contain any number of
#' ones, including none. Columns are ordered to match `pi` and `B`.
#' to block `j` and zero otherwise. Every row contains at least one
#' one: nodes that join no block in the independent Bernoulli draws
#' are assigned to exactly one block, chosen with probability
#' proportional to `pi`. Columns are ordered to match `pi` and `B`.
#' For this model, `Z` is identical to the latent positions `X`.
#'
#' - `pi`: Block membership probabilities for each block, sorted in
Expand Down
9 changes: 5 additions & 4 deletions man/overlapping_sbm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/testthat/test-undirected-overlapping-sbms.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,17 @@ test_that("print() reports whether nodes are sorted", {
expect_output(print(unsorted), "Nodes \\(n\\): 20 \\(not sorted\\)")
expect_output(print(sorted), "Undirected Overlapping Stochastic Blockmodel")
})

test_that("overlapping_sbm() docs no longer say nodes can belong to no block", {
path <- testthat::test_path("..", "..", "man", "overlapping_sbm.Rd")
skip_if_not(file.exists(path))
txt <- paste(readLines(path), collapse = " ")

expect_no_match(txt, "zero, one", fixed = TRUE)
expect_no_match(txt, "including none", fixed = TRUE)

# and every node does belong to at least one block
set.seed(1)
m <- overlapping_sbm(n = 200, k = 3, pi = c(0.1, 0.1, 0.1))
expect_true(all(Matrix::rowSums(m$Z) >= 1))
})
Loading