LSM.Gen: Generate Latent Space Model Network

View source: R/GRAND.R

LSM.GenR Documentation

Generate Latent Space Model Network

Description

Generates a random network following LSM (Latent Space Model) with specified parameters. LSM assumes that each node has a latent position in a k-dimensional space, and edge probabilities depend on the inner products between these latent positions.

Usage

LSM.Gen(n, k, K, avg.d = NULL)

Arguments

n

Integer. Number of nodes in the network.

k

Integer. Dimension of the latent space.

K

Integer. Number of communities/groups.

avg.d

Numeric. Target average node degree. If NULL, no degree adjustment is performed. Default is "NULL".

Details

Generate Latent Space Model Network

The Latent Space Model generates networks based on the following process:

  1. Node-specific intercept parameters: \alpha_i \sim \mathsf{Unif}(1, 3), then transformed as \alpha_i = -\alpha_i/2

  2. Community assignments: Each node is randomly assigned to one of K communities with equal probability

  3. Community centers: \mu_g sampled uniformly from [-1, 1]^k hypercube

  4. Latent positions: Z_i \sim \mathcal{N}_{[-2, 2]}(\mu_{g_i}, I_k) where \mu_{g_i} is the community center for node i's community

  5. Edge probabilities:

    P_{ij} = \text{logit}^{-1}(\alpha_i + \alpha_j + Z_i^\top Z_j) = \frac{1}{1 + \exp(-(\alpha_i + \alpha_j + Z_i^\top Z_j))}

  6. Adjacency matrix: A_{ij} \sim \mathsf{Bern}(P_{ij}) for i < j, with A_{ii} = 0 and A_{ji} = A_{ij}

If avg.d is specified, the edge probabilities are scaled to achieve the target average node degree.

For more details, see the "simulation studies" section of Ma, Ma, and Yuan (2020), noting that our implementation has slight differences.

Value

A list containing:

  • A: Adjacency matrix of the generated network

  • g: Graph object of the generated network

  • P: Probability matrix of the generated network

  • alpha: Node-specific intercept parameters

  • Z: Latent positions in k-dimensional space

  • idx: Community assignments for each node

References

P. D. Hoff, A. E. Raftery, and M. S. Handcock. Latent space approaches to social network analysis. Journal of the American Statistical Association, 97(460):1090–1098, 2002.

Z. Ma, Z. Ma, and H. Yuan. Universal latent space model fitting for large networks with edge covariates. Journal of Machine Learning Research, 21(4):1–67, 2020.

S. Liu, X. Bi, and T. Li. GRAND: Graph Release with Assured Node Differential Privacy. arXiv preprint arXiv:2507.00402, 2025.

Examples

# Generate a network with 400 nodes, 2D latent space, 3 communities
network <- LSM.Gen(n = 400, k = 2, K = 3)
# Generate with target average degree of 40
network2 <- LSM.Gen(n = 400, k = 2, K = 3, avg.d = 40)

GRANDpriv documentation built on Aug. 23, 2025, 1:12 a.m.