diff --git a/R/undirected_overlapping_sbm.R b/R/undirected_overlapping_sbm.R index cb67426..78f4980 100644 --- a/R/undirected_overlapping_sbm.R +++ b/R/undirected_overlapping_sbm.R @@ -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 @@ -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 diff --git a/man/overlapping_sbm.Rd b/man/overlapping_sbm.Rd index ad41365..2d22bbe 100644 --- a/man/overlapping_sbm.Rd +++ b/man/overlapping_sbm.Rd @@ -111,8 +111,10 @@ fields: \itemize{ \item \code{Z}: The block memberships of each node, as an \code{n} by \code{k} binary \code{\link[Matrix:Matrix]{Matrix::Matrix()}}. \code{Z[i, j]} is one if node \code{i} belongs -to block \code{j} and zero otherwise. Rows can contain any number of -ones, including none. Columns are ordered to match \code{pi} and \code{B}. +to block \code{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 \code{pi}. Columns are ordered to match \code{pi} and \code{B}. For this model, \code{Z} is identical to the latent positions \code{X}. \item \code{pi}: Block membership probabilities for each block, sorted in increasing order. @@ -129,8 +131,7 @@ To specify an overlapping stochastic blockmodel, you must specify the number of nodes (via \code{n}), the mixing matrix (via \code{k} or \code{B}), and the block membership probabilities (optional, via \code{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 \strong{strongly recommend} setting the \code{expected_degree} or \code{expected_density} argument diff --git a/tests/testthat/test-undirected-overlapping-sbms.R b/tests/testthat/test-undirected-overlapping-sbms.R index b330229..80989de 100644 --- a/tests/testthat/test-undirected-overlapping-sbms.R +++ b/tests/testthat/test-undirected-overlapping-sbms.R @@ -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)) +})