'ERGM simulation of a network does not work when using a constraint
I am trying to use the ERGM simulation to impute missing tie data in my network, but it does not work. Every time I run the simulate command either the RStudio Session gets aborted or the result I get is not the expected one. What I want is that only the Edges which are NA are imputed model-based. The observed edges (0 - non existant; 1 - existant) should remain as they are. I created a random dataset that resembles mine regarding the number of vertices and the approximate density: 42 vertices, 156 edges, Edges of 4 actors missing, one attribute "Class" (1-3) you can find the dataset here: https://drive.google.com/drive/folders/1wTgnv9jQ6cVnfpuJNTCh-Bc3EpA0kmDu?usp=sharing
This is my code in a simplified way, but the same error occurs:
library(ergm)
load("my_random_network.RData")
#estimate ERGM
test_imp_simple <- ergm(random_nw ~ edges
+ mutual
+ nodematch('Class'))
summary(test_imp_simple)
#Simulate and keep observed edges fixed
imp_random1 <- simulate(test_imp_simple, nsim=5, constraints = ~observed)
summary(imp_random1)
Now I add the original network and one of the imputed networks as matrices to check if the observed edges are reproduced (2 in the table) and the imputed edges are as many as edges in the imputed dataset minus edges in the original dataset (1 in the table). But this is not the case.
random_nw_zero <- as.matrix(random_nw)
random_nw_zero[is.na(random_nw_zero)] <- 0
test1 <- random_nw_zero + as.matrix(imp_random1[[1]])
table(test1)
I tried the same strategy of imputation with the undirected dataset faux.mesa.high (inculded in ergm package) in which I created some missings and in that case it worked. Does anyone have an idea what I did wrong in my imputation approach? Many thanks in advance for any hint or idea what the problem might be!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
