mlergm (version 0.8)

simulate_mlnet: Simulate a multilevel network

Description

Function simulates a multilevel network by specifying a network size, node block memberships, and within-block and between-block models. The function currently only suppports block-models where between-block edges are dyad-independent.

Usage

simulate_mlnet(
  form,
  node_memb,
  theta,
  parameterization = "standard",
  seed = NULL,
  between_form = NULL,
  between_theta = NULL,
  between_prob = NULL,
  options = set_options()
)

Arguments

form

A formula object of the form network ~ model terms which specifies how the within-block subgraphs are modeled.

node_memb

Vector of node block memberships.

theta

A vector of model parameters (coefficients) for the ERGM governing the within-subgraph edges.

parameterization

Parameterization options include 'standard', 'offset', or 'size'.

  • 'standard' : Does not adjust the individual block parameters for size.

  • 'offset' : The offset parameterization uses edge and mutual offsets along the lines of Krivitsky, Handcock, and Morris (2011) and Krivitsky and Kolaczyk (2015). The edge parameter is offset by \(-log n(k)\) and the mutual parameter is offset by \(+log n(k)\), where \(n(k)\) is the size of the kth block.

  • 'size' : Multiplies the block parameters by \(log n(k)\), where \(n(k)\) is the size of the kth block.

seed

Seed to be provided for reproducibility.

between_form

A formula object of the form ~ model terms which specifies how the within-block subgraphs are modeled.

between_theta

A vector of model parameters (coefficients) for the ERGM governing the between-subgraph edges.

between_prob

A probability which specifies how edges between blocks are governerd. An ERGM (between_form and between_theta) cannot be specified together with between_prob.

options

Use set_options to change the simulation options. Note that some options are only valid for estimation using mlergm.

Value

simulate_mlnet returns an objects of class mlnet.

Details

Simulation of multilevel block networks is done with a Monte-Carlo Markov chain (MCMC) and can be done in parallel where set_options can be used to adjust the simulation settings (such as burnin, interval, and sample_size). Each within-block subgraph is given its own Markov chain, and so these settings are the settings to be used for each within-block chain.

Examples

Run this code
# NOT RUN {
# Create a K = 2 block network with edge + gwesp term 
net <- simulate_mlnet(form = network.initialize(30, directed = FALSE) ~ edges + gwesp, 
                      node_memb = c(rep(1, 15), rep(2, 15)),
                      theta = c(-3, 0.5, 1.0), 
                      between_prob = 0.01,
                      options = set_options(number_cores = 2, burnin = 2000))

# Simulate a K = 2 block directed network, specifying a formula for between edges
net <- simulate_mlnet(form = network.initialize(30, directed = TRUE) ~ edges + gwesp,
                      node_memb = c(rep(1, 15), rep(2, 15)),
                      theta = c(-3, 0.5, 1.0),
                      between_form = ~ edges + mutual, 
                      between_theta = c(-4, 2),
                      options = set_options(number_cores = 2, burnin = 2000))
# }

Run the code above in your browser using DataLab