# \dontshow{
require(ergm)
require(network)
require(sna)
set.seed(21093)
a1<-network::as.network(matrix(c(rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3)),
nrow=10,ncol=10))
network::set.vertex.attribute(a1,"var.1",rbinom(10,1,.3))
a<-ergm(a1~edges+nodeifactor("var.1")+nodeofactor("var.1"))
compare_MEMS(partial_model=a,
full_model=a,
micro_process="nodeifactor.var.1.1",
macro_function=gtrans,
nsim=20,
silent=TRUE)
# }
# \donttest{
##############
# Not run
###############
library(statnet)
library(igraph)
data("faux.mesa.high")
#how much of the effect of racial homophily on transitivity
#is explained by triadic closure effects?
model<-ergm(faux.mesa.high~edges+nodecov("Grade")+nodefactor("Race")+
nodefactor("Sex")+nodematch("Race")+nodematch("Sex")+absdiff("Grade"))
model2<-ergm(faux.mesa.high~edges+nodecov("Grade")+nodefactor("Race")+
nodefactor("Sex")+nodematch("Race")+nodematch("Sex")+absdiff("Grade")+
gwesp(.5,fixed=TRUE))
compare_MEMS(partial_model=model,
full_model=model2,
micro_process="nodematch.Race",
macro_function=transitivity,
object_type = "igraph",
silent=FALSE,
algorithm="parametric")
# }
Run the code above in your browser using DataLab