Description Usage Arguments Value References Examples
This function estimates an ego-ERGM. Code taken from Salter-Townshend and Murphy (2015)'s replication archive.
| 1 2 3 4 | 
| net | The cross-sectional network that an ego-ERGM will be fit on. Must be presented as a network object. Any vertex attributes should be attached to networks. Currently the function does not support comparisons of whole networks. | 
| form | The formula comprised of ERGM or TERGM terms used to distinguish between clusters assignments. Specified as a vector of comma separated terms. No default. | 
| core_size | The order of alters to include. The default value of one implies only looking at an ego's alters and the connections among them. | 
| min_size | The minimum number of nodes an ego-network must achieve to be included. Defaults to five. | 
| roles | The number of roles that should be fit. Defaults to 3. | 
| directed | Should the longitudinal network be treated as directed? If so, specify as the default TRUE. | 
| edge_covariates | Are edge covariates included in the form term? IF so, specify as TRUE. No default. | 
| seed | The seed set to replicate analysis for pseudorandom number generator. | 
| forking | If parallelization via forking should be used (TRUE) or if no parallel processing should be used (FALSE). Currently, sockets are not supported. | 
| ncpus | The number of CPUs that should should be used for estimation, defaults to 1. | 
| steps | The number of default EM steps that should be taken, defaults to 50. | 
| tol | The difference in parameter estimates between EM iterations to determine if the algorithm has converged. Defaults to 1e-6. | 
A list of model results, including lambda (the probability of assignments), group.theta (the roles by terms cluster centroids), EE.BIC (the Salter-Townshend and Murphy BIC cross-sectional BIC), role_assignments (a data frame of the most likely assignments), and reduced_networks (network with excluded ego).
Box-Steffensmeier, Janet M., Benjamin W. Campbell, Dino P. Christenson, Zachary Navabi. (2018): Role analysis using the ego-ERGM: A Look at environmental interest group coalitions. Social Networks 52: 213-227. https://doi.org/10.1016/j.socnet.2017.08.004
Campbell, Benjamin W. (2018): Inferring Latent Roles in Longitudinal Networks. Political Analysis 26(3): 292-311. https://doi.org/10.1017/pan.2018.20
Salter-Townshend, Michael and Thomas Brendan Murphy. (2015): Role Analysis in Networks using Mixtures of Exponential Random Graph Models. Journal of Computational and Graphical Statistics 24(2): 520-538. https://doi.org/10.1080/10618600.2014.923777
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # Code from xergm.common and their preparation of the Knecht network
library(xergm.common)
set.seed(1)
data("knecht")
for (i in 1:length(friendship)) {
 rownames(friendship[[i]]) <- paste("Student.", 1:nrow(friendship[[i]]), sep="")
 colnames(friendship[[i]]) <- paste("Student.", 1:nrow(friendship[[i]]), sep="")
}
rownames(primary) <- rownames(friendship[[1]])
colnames(primary) <- colnames(friendship[[1]])
sex <- demographics$sex
names(sex) <- rownames(friendship[[1]])
# step 2: imputation of NAs and removal of absent nodes:
friendship <- xergm.common::handleMissings(friendship, na = 10, method = "remove")
friendship <- xergm.common::handleMissings(friendship, na = NA, method = "fillmode")
# step 3: add nodal covariates to the networks
for (i in 1:length(friendship)) {
  s <- xergm.common::adjust(sex, friendship[[i]])
  friendship[[i]] <- network::network(friendship[[i]])
  friendship[[i]] <- network::set.vertex.attribute(friendship[[i]], "sex", s)
  idegsqrt <- sqrt(sna::degree(friendship[[i]], cmode = "indegree"))
  friendship[[i]] <- network::set.vertex.attribute(friendship[[i]],
                                                   "idegsqrt", idegsqrt)
  odegsqrt <- sqrt(sna::degree(friendship[[i]], cmode = "outdegree"))
  friendship[[i]] <- network::set.vertex.attribute(friendship[[i]],
                                                   "odegsqrt", odegsqrt)
}
sapply(friendship, network::network.size)
net <- friendship
rm(list=setdiff(ls(), "net"))
# Reduce down to first time-step
ego_ergm_fit <- ego_ergm(net = net[[1]],
                          form = c("edges", "mutual", "triangle",
                                   "nodeicov('idegsqrt')", "nodeocov('odegsqrt')",
                                   "nodematch('sex')"),
                          core_size = 1,
                          min_size = 5,
                          roles = 3,
                          forking = FALSE,
                          ncpus = 1,
                          directed = TRUE,
                          edge_covariates = FALSE,
                          seed = 12345,
                          steps = 50,
                          tol = 1e-06)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.