new_rergmito: ERGMito sampler

View source: R/new_rergmito.R

new_rergmitoR Documentation

ERGMito sampler

Description

Create a sampler object that allows you simulating streams of small networks fast.

Usage

new_rergmito(model, theta, ...)

## S3 method for class 'ergmito_sampler'
x[i, ...]

Arguments

model

A formula.

theta

Named vector. Model parameters.

...

Further arguments passed to ergmito_formulae().

x

An object of class ergmito_sampler.

i

i is an integer vector indicating the indexes of the networks to draw.

Details

While the ergm package is very efficient, it was not built to do some of the computations required in the ergmito package. This translates in having some of the functions of the package (ergm) with poor speed performance. This led us to "reinvent the wheel" in some cases to speed things up, this includes calculating observed statistics in a list of networks.

The indexing method, ⁠[.ergmito_sampler⁠, allows extracting networks directly by passing indexes. i indicates the index of the networks to draw, which go from 1 through 2^(n*(n-1)) if directed and 2^(n*(n-1)/2) if undirected .

Value

An environment with the following objects:

  • calc_prob A function to calculate each graph's probability under the specified model.

  • call A language object with the call.

  • counts A list with 3 elements: stats the sufficient statistics of each network, weights and statmat the overall matrices of sufficient statistics used to compute the likelihood.

  • network The baseline network used to either fit the model or obtain attributes.

  • networks A list with the actual sample space of networks.

  • probabilities A numeric vector with each graph's probability.

  • sample A function to draw samples. n specifies the number of samples to draw and theta the parameter to use to calculate the likelihoods.

  • theta Named numeric vector with the current values of the model parameters.

The indexing method ⁠[.ergmito_sampler⁠ returns a list of networks

Examples


# We can generate a sampler from a random graph
set.seed(7131)
ans <- new_rergmito(rbernoulli(4) ~ edges, theta = -.5)

# Five samples
ans$sample(5)

# or we can use some nodal data:
data(fivenets)
ans <- new_rergmito(
  fivenets[[3]] ~ edges + nodematch("female"),
  theta = c(-1, 1)
)

# Five samples
ans$sample(5) # All these networks have a "female" vertex attr


muriteams/ergmito documentation built on Sept. 15, 2023, 7:07 a.m.