simulate.sisnetwork {networksis} | R Documentation |
simulate
is used to draw from exponential family
random network models in their natural parameterizations.
See ergm
for more information on these models.
The method simulate.sisnetwork
draws it from graphs with
the same marginals as the passed network
through sequential importance sampling.
That is, the degrees of the nodes are fixed and specified.
## S3 method for class 'sisnetwork' simulate(object, nsim=1, ..., save.networks=TRUE, control=ergm::control.simulate(), verbose=FALSE)
object |
a |
nsim |
Number of networks to be randomly drawn from the set of all networks. |
control |
A list of control parameters for algorithm
tuning. Constructed using |
save.networks |
If this is |
verbose |
If this is |
... |
further arguments passed to or used by methods. |
A sample of networks is randomly drawn from the space of networks with the
same degrees for each node.
More information can be found by looking at the documentation of
ergm
.
simulate
returns an object of class network.series
that is a list consisting of the following elements:
log.prob |
The vector of the logarithm of the probability of being sampled. |
log.graphspace.size |
The logarithm of the mean estimate of the number of graphs in the graph space. |
log.graphspace.SE |
The logarithm of the standard error of the mean estimate of the number of graphs in the graph space. |
log.graphspace.size.lne |
The logarithm of the lognormal-based estimate of the number of graphs in the graph space. |
log.graphspace.SE.lne |
The logarithm of the standard error of the lognormal-based estimate of the number of graphs in the graph space. |
In the case of a single network sampled, only the network is returned (as a
network
object), and the additional information is returned as attributes of the network.
ergm, network
bipartite.graph<-scan() 1 1 0 0 0 0 1 1 1 1 1 0 bipartite.graph<-matrix(bipartite.graph, nrow=3, byrow=TRUE) example.net<-network(bipartite.graph) ## Specify which set each node belongs to ## example.net %v% "set" <- c(rep(1,3),rep(2,4)) ## Simulate 1000 graphs with the same ## ## marginals as 'example.net' ## sim<-simulate(example.net, nsim=1000) ## Estimated graph space size and SE ## exp(sim %n% "log.graphspace.size") exp(sim %n% "log.graphspace.SE") ## Darwin's finches example ## data(finch) sim<-simulate(finch, nsim=1000) ## Calculate importance weights from the graph probabilities ## importance.weights<-1/exp(sim %n% "log.prob") hist(importance.weights,breaks=75, xlab="Inverse Graph Probability",main="") prob.vec<-rep(0,500) s.bar.squared.vec<-rep(0,500) for(i in 1:500) { sim<-simulate(finch, nsim=1) ## Extract new bipartite graph ## new.graph<-as.matrix.network(sim) ## Calculate custom graph statistic ## s.bar.squared<-(sum((new.graph%*%t(new.graph))^2)- sum(diag((new.graph%*%t(new.graph))^2)))/(13*12) s.bar.squared.vec[i]<-s.bar.squared ## Graph probability ## prob.vec[i]<-exp(sim %n% "log.prob") }