undirected_factor_model: Create an undirected factor model graph

View source: R/undirected_factor_model.R

undirected_factor_modelR Documentation

Create an undirected factor model graph

Description

An undirected factor model graph is an undirected generalized Poisson random dot product graph. The edges in this graph are assumed to be independent and Poisson distributed. The graph is parameterized by its expected adjacency matrix, which is ⁠E[A|X] = X S X'⁠. We do not recommend that casual users use this function, see instead dcsbm() and related functions, which will formulate common variants of the stochastic blockmodels as undirected factor models with lots of helpful input validation.

Usage

undirected_factor_model(
  X,
  S,
  ...,
  expected_degree = NULL,
  expected_density = NULL,
  poisson_edges = TRUE,
  allow_self_loops = TRUE
)

Arguments

X

A matrix() or Matrix() representing real-valued latent node positions. Entries must be positive.

S

A matrix() or Matrix() mixing matrix. S is symmetrized if it is not already, as this is the undirected case. Entries must be positive.

...

Ignored. Must be empty.

expected_degree

If specified, the desired expected degree of the graph. Specifying expected_degree simply rescales S to achieve this. Defaults to NULL. Do not specify both expected_degree and expected_density at the same time.

expected_density

If specified, the desired expected density of the graph. Specifying expected_density simply rescales S to achieve this. Defaults to NULL. Do not specify both expected_degree and expected_density at the same time.

poisson_edges

Logical indicating whether or not multiple edges are allowed to form between a pair of nodes. Defaults to TRUE. When FALSE, sampling proceeds as usual, and duplicate edges are removed afterwards. Further, when FALSE, we assume that S specifies a desired between-factor connection probability, and back-transform this S to the appropriate Poisson intensity parameter to approximate Bernoulli factor connection probabilities. See Section 2.3 of Rohe et al. (2017) for some additional details.

allow_self_loops

Logical indicating whether or not nodes should be allowed to form edges with themselves. Defaults to TRUE. When FALSE, sampling proceeds allowing self-loops, and these are then removed after the fact.

Value

An undirected_factor_model S3 class based on a list with the following elements:

  • X: The latent positions as a Matrix() object.

  • S: The mixing matrix as a Matrix() object.

  • n: The number of nodes in the network.

  • k: The rank of expectation matrix. Equivalently, the dimension of the latent node position vectors.

Examples


n <- 10000
k <- 5

X <- matrix(rpois(n = n * k, 1), nrow = n)
S <- matrix(runif(n = k * k, 0, .1), nrow = k)

ufm <- undirected_factor_model(X, S)
ufm

ufm2 <- undirected_factor_model(X, S, expected_degree = 50)
ufm2

svds(ufm2)


fastRG documentation built on Aug. 22, 2023, 1:08 a.m.