View source: R/ergm_blockdiagonal.R
blockdiagonalize | R Documentation |
ergm
These two functions are used to go back and forth from a pooled ergm vs a blockdiagonal model, the latter to be fitted using ergm::ergm.
blockdiagonalize(x, attrname = "block")
splitnetwork(x, attrname)
ergm_blockdiag(formula, ...)
x |
In the case of |
attrname |
Name of the attribute that holds the block ids. |
formula |
An ergm model which networks' will be wrapped with blockdiagonalize (see details). |
... |
Further arguments passed to the method. |
The function ergm_blockdiag
is a wrapper function that takes the
model's network, stacks the networks into a single block diagonal net, and
calls ergm::ergm with the option constraints = blockdiag("block")
.
One side effect of this function is that it loads the ergm
package via
requireNamespace, so after executing the function ergm
the package will
be loaded.
An object of class ergm::ergm.
library(ergm)
data(fivenets)
fivenets2 <- blockdiagonalize(fivenets, attrname = "block") # A network with
ans0 <- ergm(
fivenets2 ~ edges + nodematch("female"),
constraints = ~blockdiag("block")
)
ans1 <- ergmito(fivenets ~ edges + nodematch("female"))
# This is equivalent
ans2 <- ergm_blockdiag(fivenets ~ edges + nodematch("female"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.