simulate_sis {networksis} | R Documentation |
The function simulate_sis
draws bipartite graphs
from the space of graphs with the same marginals as
the passed network using sequential importance sampling.
That is, the degrees of the nodes are fixed and specified.
The formula
specifies a set of network statistics that are
evaluated on the sampled networks.
See ergm-terms
for more information on
the available statistics.
simulate_sis(formula, nsim=1, ..., control=ergm::control.simulate.formula(), verbose=FALSE)
formula |
formula; an R |
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 |
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
.
Returns a single bipartite network
object.
In addition the object has network attributes (using %n%
):
samplestatistics |
The n\times p matrix of the graph statistics produced by the sampled graphs, where n is the number of simulated graphs and p is the number of different graph statistics under consideration. |
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. |
ergm, network
data(finch) ## Simulate graphs and record the networks statistics ## ## specified by 'coincidences(x)' ## sim<-simulate_sis(finch~coincidences(0:17), nsim=10000) observed.stats<-summary(finch~coincidences(0:17)) sampled.stats<-sim %n% "samplestatistics" ## Calculate 95% confidence intervals for the network statistics ## library(Hmisc) p<-exp(sim %n% "log.prob") p<-p/sum(p) maxs<-apply(sampled.stats,2,wtd.quantile, weights=p,probs=0.975,normwt=TRUE) mins<-apply(sampled.stats,2,wtd.quantile, weights=p,probs=0.025,normwt=TRUE) means<-apply(sampled.stats,2,wtd.mean,weights=p) ## Plot the means and CIs for the null distributions of the ## ## statistics. Also plot the observed statistics ## plot(0:17, means, type="b", ylim=c(0,24.5), lwd=3, lty=3, xlab="Number of Islands", ylab="Pairs of Finches") for(i in 1:18) { points(rep(i-1,2), c(maxs[i],mins[i]), type="l", lwd=2) } points(0:17, observed.stats, type="b", pch=4, lwd=3) ## Calculate the p-value for 'coincidences(0)' ## r0<-(p%*%sweep(sampled.stats,2,observed.stats,"<"))[1,] r1<-(p%*%sweep(sampled.stats,2,observed.stats,">"))[1,] round(apply(cbind(r0,r1),1,min),digits=8)[1]