Last chance! 50% off unlimited learning
Sale ends in
simulate
is used to draw from exponential family
random network models in their natural parameterizations.
See ergm
for more information on these models.## S3 method for class 'formula':
simulate(object, nsim=1, seed=NULL, \dots, theta0,
burnin=1000, interval=1000,
basis=NULL,
sequential=TRUE,
constraints = ~.,
control = control.simulate.formula(),
verbose=FALSE)
## S3 method for class 'ergm':
simulate(object, nsim=1, seed=NULL, \dots, theta0,
burnin=1000, interval=1000,
sequential=TRUE,
constraints = NULL,
control = control.simulate.ergm(),
verbose=FALSE)
sample(10000000, size=1)
.prob
is not specified. When given either
a formula
or an object of class ergm
,
burnin
should be set to a fairly large number.network
object to start the MCMC
algorithm from. This overrides the left-hand-side of the formula
.
If neither a left-hand-side nor a basis
is present, anergm
for more informationcontrol.simulate.ergm
or
control.simulate.formula
, sequential=TRUE
option is useful for dynamic dTRUE
, we will print out more information as
we run the program, including (currently) some goodness of fit
statistics.nsim==1
, simulate.ergm
returns an object of
class network
. If nsim>1
, it returns an object of class
network.series
that is a list with the following elements:formula
used to generate the sample.formula
then this defines
the model. If the
first argument is the output of a call to ergm
then the model
used for that call is the one fit - and unless theta0
is specified,
the sample is from the MLE of the parameters.
If neither of those are given as the
first argument then a Bernoulli network is generated with the probability
of ties defined by prob
or theta0
. Note that the first network is sampled after burnin
+ interval
steps, and any subsequent networks are sampled each
interval
steps after the first.
More information can be found by looking at the documentation of
ergm
.
#
# Let's draw from a Bernoulli model with 16 nodes
# and density 0.5 (i.e., theta0 = c(0,0))
#
g.sim <- simulate(network(16) ~ edges + mutual)
#
# What are the statistics like?
#
summary(g.sim ~ edges + mutual)
#
# Now simulate a network with higher mutuality
#
g.sim <- simulate(network(16) ~ edges + mutual, theta0=c(0,2))
#
# How do the statistics like?
#
summary(g.sim ~ edges + mutual)
#
# Let's draw from a Bernoulli model with 16 nodes
# and tie probability 0.1
#
g.use <- network(16,density=0.1,directed=FALSE)
#
# Starting from this network let's draw 5 realizations
# of a edges and 2-star network
#
g.sim <- simulate(~edges+kstar(2),nsim=5,theta0=c(-1.8,0.03),
basis=g.use,
burnin=100000,interval=1000)
g.sim
#
# attach the Florentine Marriage data
#
data(florentine)
#
# fit an edges and 2-star model using the ergm function
#
gest <- ergm(flomarriage ~ edges + kstar(2))
summary(gest)
#
# Draw from the fitted model
#
g.sim <- simulate(gest,nsim=100,burnin=1000,interval=1000)
g.sim
Run the code above in your browser using DataLab