Simulate networks under Exponential Random Graph Models (ERGMs) under local dependence
simulate_bigergm.Rd
This function simulates networks under Exponential Random Graph Models (ERGMs) with local dependence.
There is also an option to simulate only within-block networks and a S3 method for the class bigergm
.
Usage
simulate_bigergm(
formula,
coef_within,
coef_between,
network = ergm.getnetwork(formula),
control_within = ergm::control.simulate.formula(),
only_within = FALSE,
seed = NULL,
nsim = 1,
output = "network",
verbose = 0,
...
)
Arguments
- formula
An R
formula
object of the formy ~ <model terms>
, wherey
is anetwork
object. The network object must contain block information as a vertex attribute with the name 'block'. For the details on the possible<model terms>
, seeergmTerm
and Morris, Handcock and Hunter (2008). All terms that induce dependence are excluded from the between block model, while the within block model includes all terms. TheL-ergmTerm
is supported to enable size-dependent coefficients for the within-blocks model. Note, however, that for size-dependent parameters of terms that are included in the between-blocks model, the intercept in the linear model provided toL-ergmTerm
should not include the intercept. See the second example ofbigergm
for a demonstration.- coef_within
a vector of within-block parameters. The order of the parameters should match that of the formula.
- coef_between
a vector of between-block parameters. The order of the parameters should match that of the formula without externality terms.
- network
a network object to be used as a seed network for the simulation (if none is provided, the network on the lhs of the
formula
is used).- control_within
auxiliary function as user interface for fine-tuning ERGM simulation for within-block networks.
- only_within
If this is TRUE, only within-block networks are simulated.
- seed
seed value (integer) for network simulation.
- nsim
number of networks generated.
- output
Normally character, one of "network" (default), "stats", "edgelist", to determine the output format.
- verbose
If this is TRUE/1, the program will print out additional information about the progress of simulation.
- ...
Additional arguments, passed to
simulate_formula
.
Value
Simulated networks, the output form depends on the parameter output
(default is a list of networks).
References
Morris M, Handcock MS, Hunter DR (2008). Specification of Exponential-Family Random Graph Models: Terms and Computational Aspects. Journal of Statistical Software, 24.
Examples
data(toyNet)
# Specify the model that you would like to estimate.
model_formula <- toyNet ~ edges + nodematch("x") + nodematch("y") + triangle
# Simulate network stats
sim_stats <- bigergm::simulate_bigergm(
formula = model_formula,
# Formula for the model
coef_between = c(-4.5,0.8, 0.4),
# The coefficients for the between connections
coef_within = c(-1.7,0.5,0.6,0.15),
# The coefficients for the within connections
nsim = 10,
# Number of simulations to return
output = "stats",
# Type of output
)