Closed benrosche closed 11 months ago
Thanks for the request. I am currently testing a proposal that will do that, but I want to check something: do you want to constrain the number of edges overall or within each block? The former should be in master
tonight, but the latter is a taller order.
Hi Pavel, I'd be happy with either. Within blocks would be great to have at some point but it's not urgent. Thank you so much! I'll update the package tomorrow then! Ben
Benjamin Rosche PhD candidate in Sociology at Cornell University benrosche.com
Sent from my phone. Terse, odd spellings, apologies.
On Tue, Jul 4, 2023, 6:20 PM Pavel N. Krivitsky @.***> wrote:
Thanks for the request. I am currently testing a proposal that will do that, but I want to check something: do you want to constrain the number of edges overall or within each block? The former should be in master tonight, but the latter is a taller order.
— Reply to this email directly, view it on GitHub https://github.com/statnet/ergm/issues/538#issuecomment-1620793759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG3M3NX6KNGVEQIPXC4UIP3XOSJJDANCNFSM6AAAAAAZ6DUSYM . You are receiving this because you authored the thread.Message ID: @.***>
Merged in in add1887606fb3f2dd78465f59b0a8de554804e58 (for full-network edge constraint).
Dear Pavel / ergm developers,
I tried implementing the new constraint combination ergm(...,constraints=~blockdiag("gid")+edges)
now with actual (larger) data. Unfortunately, the RStudio crashes when model parameters need to be fitted as soon as I add +edges
(both with CD and MLE algorithms). Simulating networks with ergm(...,constraints=~blockdiag("gid")+edges)
works, however. Fitting a model with the constraint combination produces the following error message. Alas, I cannot provide a reproducible example because the data I'm using (Add Health) is on a secured server. I wonder whether you have come across this error message before and whether this could be due to the ergm package or more likely due to the server I'm working on.
That's unfortunate. Can you try finding a minimal example, say stripping network attributes off?
It took a long time but I was finally authorized to create fake data that resembles the structure of the Add Health friendship networks. I am able to replicate the error outside the secure server. This model crashes on my Dell XPS 9370:
library(dplyr)
library(igraph)
library(intergraph)
library(ergm)
nd <- read.csv(file="nd.txt") %>% relocate(id)
ed <- read.csv(file="ed.txt") %>% relocate(id_from, id_to)
g <-
graph_from_data_frame(
d=ed,
vertices=nd,
directed = T
) %>%
asNetwork(., multiple=F)
g.ergm <-
ergm(
g ~
edges+mutual,
estimate="MLE",
constraints=~blockdiag("gid")+edges,
control=control.ergm(
seed=1,
MCMLE.maxit = 20
))
The data files can be downloaded here.
Dear Pavel,
I wanted to follow up one more time regarding the new constraint combination ergm(...,constraints=~blockdiag("gid")+edges)
.
Unfortunately, R crashes when both blockdiag()
and edges
are specified. This happens regardless of whether an ergm model is fitted using the ergm function or networks are simulated using the simulate function.
This code reproduces the error:
library(dplyr)
library(igraph)
library(intergraph)
library(ergm)
nd <- read.csv(file="nd.txt") %>% relocate(id)
ed <- read.csv(file="ed.txt") %>% relocate(id_from, id_to)
g <-
graph_from_data_frame(
d=ed,
vertices=nd,
directed = T
) %>%
asNetwork(., multiple=F)
g.ergm <-
ergm(
g ~
edges+mutual,
estimate="MLE",
constraints=~blockdiag("gid")+edges,
control=control.ergm(
seed=1,
MCMLE.maxit = 20
))
The data files can be downloaded here.
I'd appreciate it very much if you could have quick look.
I appreciate it.
Any chance you could enable this feature for ergm.multi? When using the edges (or (o)degrees) constraint with ergm.multi, it responds that blockdiag + edges is not supported.
Thank you,
Benjamin Rosche PhD candidate in Sociology at Cornell University benrosche.com
Sent from my phone. Terse, odd spellings, apologies.
On Sat, Dec 9, 2023, 3:05 AM Pavel N. Krivitsky @.***> wrote:
Closed #538 https://github.com/statnet/ergm/issues/538 as completed via 1ef5543 https://github.com/statnet/ergm/commit/1ef5543f5bc93c622d16bdc2b4d00fd3022b2129 .
— Reply to this email directly, view it on GitHub https://github.com/statnet/ergm/issues/538#event-11199945080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG3M3NTUXRMTY45YHZVP4CTYIQLWFAVCNFSM6AAAAAAZ6DUSYOVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGE4TSOJUGUYDQMA . You are receiving this because you authored the thread.Message ID: @.***>
I appreciate it. Any chance you could enable this feature for ergm.multi? When using the edges (or (o)degrees) constraint with ergm.multi, it responds that blockdiag + edges is not supported.
Odd. Can I trouble you to please open a new ticket with test code?
I tried to replicate the error just now and ergm.multi with constraint=~edges works. My bad!
~ Feature request ~
Dear Pavel / ergm developers,
As discussed at Sunbelt 2023, I would like to request the following constraint combination:
ergm(..., constraints=~blockdiag("gid")+edges)
orergm(..., constraints=~blockdiag("gid")+(o)degrees )
to model multiple networks while keeping the overall number of edges constant.
When using ergms to simulate networks, keeping the number of edges constant is often necessary to draw valid comparisons between network states. When modeling multiple networks, this is currently only possible with the following hack:
ergm(g~... + offset(F(~edges, ~!nodematch("gid"))), offset.coef=-Inf, constraints=~edges)
ergm.multi does not solve this problem because
ergm(Networks(gs) ~... , constraints=~edges)
is not possible either.
Thank you very much and best wishes,
Ben Rosche