library(ergm)
data(florentine)
## Business as dyad covariate for marriage
flomarriage %n% "business" <- as.matrix(flobusiness)
summary(flomarriage~edgecov("business"))
#> edgecov.business
#> 8
## Consider a subgraph excluding nodes 1 and 2. Because the node IDs
## have shifted, the covariate matrix is now shifted relative to the
## sociomatrix:
summary(flomarriage~S(~edgecov("business"), ~3:16))
#> S(3:16)~edgecov.business
#> 1
## Correct value
sum((as.matrix(flomarriage) & as.matrix(flobusiness))[3:16,3:16])
#> [1] 16
Approaches
network API
Introduce the concept of a dyad attribute (%d%?) that functions such as add.nodes(), permute.vertexIDs(), and get.inducedSubgraph() understand and modify accordingly. This is probably the most seamless and elegant way. @CarterButts , what do you think?
%ergmlhs% API
It's up to the user to provide ergm() with a list of network attributes subject to adjustment. Then, something along the lines of
could inform the S() operator that a subgraph should be taken. This could be automated by providing a %d%<-.network() method that sets the network attribute and updates the %ergmlhs% metadata.
Vertex name matching
edgecov() and dyadcov() could be more clever. Firstly, if the dyadic covariate dimension does not match the current network size, they should at the very least detect that. They could then see if, e.g., the dyadic covariate matrix has row and column names, which could then be used to map onto the current vertex names.
The problem:
Approaches
network
APIIntroduce the concept of a dyad attribute (
%d%
?) that functions such asadd.nodes()
,permute.vertexIDs()
, andget.inducedSubgraph()
understand and modify accordingly. This is probably the most seamless and elegant way. @CarterButts , what do you think?%ergmlhs%
APIIt's up to the user to provide
ergm()
with a list of network attributes subject to adjustment. Then, something along the lines ofcould inform the
S()
operator that a subgraph should be taken. This could be automated by providing a%d%<-.network()
method that sets the network attribute and updates the%ergmlhs%
metadata.Vertex name matching
edgecov()
anddyadcov()
could be more clever. Firstly, if the dyadic covariate dimension does not match the current network size, they should at the very least detect that. They could then see if, e.g., the dyadic covariate matrix has row and column names, which could then be used to map onto the current vertex names.