| new_rergmito {ergmito} | R 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 |
x |
An object of class |
i |
|
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_probA function to calculate each graph's probability under the specified model. -
callA language object with the call. -
countsA list with 3 elements:statsthe sufficient statistics of each network,weightsandstatmatthe overall matrices of sufficient statistics used to compute the likelihood. -
networkThe baseline network used to either fit the model or obtain attributes. -
networksA list with the actual sample space of networks. -
probabilitiesA numeric vector with each graph's probability. -
sampleA function to draw samples.nspecifies the number of samples to draw andthetathe parameter to use to calculate the likelihoods. -
thetaNamed 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