-
Hi! I'm trying to run an ergm.multi model with an edgecov term but can't find the correct way to specify an edgecov using a matrix. I prefer the matrix approach because it's faster for large networks.
Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
krivit
Jan 30, 2025
Replies: 1 comment
-
While in principle, you can treat the data structure returned by library(ergm.multi)
data(Goeyvaerts)
g <- Goeyvaerts[1:5]
# 5 ec_matrices that represent an edgecov
ec_matrices <-
purrr::map(g,\(x) {
n <- network.size(x)
m <- matrix(rnorm(n*n,0,1),n,n)
return(m)
})
# attach each covariate matrix to its respective network
for(i in seq_along(g)) g[[i]] %n% "weight" <- ec_matrices[[i]]
summary(Networks(g) ~ N(~edges + edgecov("weight")))
#> N(1)~edges N(1)~edgecov.weight
#> 28.000000 -2.354922 I hope this helps. If not, feel free to reopen. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
krivit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While in principle, you can treat the data structure returned by
Networks()
as a block-diagonal matrix, it is generally better to use theN()
, which takes care of the bookkeeping and handles things consistently. Here's how I would do it: