statnet / ergm

Fit, Simulate and Diagnose Exponential-Family Models for Networks
Other
94 stars 36 forks source link

Inquiry about 'diff-ergmTerm' in ERGM package #524

Closed dleeao closed 1 year ago

dleeao commented 1 year ago

Dear,

I hope this email finds you well. I am currently a Ph. student at KAIST, studying network theory using the ERGM package in R language. I wanted to express my gratitude for your packages in my studies.

I have a question regarding the 'diff-ergmTerm' in the ERGM package, specifically related to the directionality of the tail-head and the use of posonly and negonly.

I created a network with 19 nodes (numbered from 1 to 19) and assigned sequential attributions to each node, with higher attribution values for smaller node numbers (e.g., 1 having the highest attribution and the attribution decreasing as the node number increases). Then, I generated edges using code to create links with higher probabilities from nodes with higher attribution to nodes with lower attribution. Specifically, I designed the links to have a higher probability of tail(i)-head(j) with a positive sign.action(attr[i]-attr[j]) in the 'diff' function.

However, when I included both "diff('Att', pow=1, dir="t-h", sign.action="posonly")" and "diff('Att', pow=1, dir="t-h", sign.action="negonly")" in the code and ran it, I obtained unexpected results, where 'negonly' showed statistically significant effects instead of 'posonly'.

I would appreciate it if you could review my code and data set to confirm if my interpretation and implementation are correct. Please find the attached data set and code for your reference.

Thank you in advance for your assistance.

Best regards, Deok-Young Lee.

Datasets: test_edge.csv test_node.csv Result I got: diff_results

Codes:

library('ergm')
library('igraph')
library('intergraph')

link_test <- read.csv("test_edge.csv")
G <- graph.data.frame(link_test[, c(1,2)], directed = TRUE)
property_test <- read.csv("test_node.csv")
colnames(property_test)
V(G)$Att <- property_test[,2]

nx_test <- asNetwork(G, ignore.eval=FALSE)
nx_test

base_test <- ergm(nx_test ~ edges)
base_test_diffsign <- ergm(nx_test ~ edges 
                           + diff('Att', pow=1, dir="t-h", sign.action="posonly")
                           + diff('Att', pow=1, dir="t-h", sign.action="negonly"))
summary(base_test_diffsign)
mbojan commented 1 year ago

I believe you have perfect separation in your data, i.e. tie exist only in those dyads in which the difference on 'att' is positive.

dleeao commented 1 year ago

I believe you have perfect separation in your data, i.e. tie exist only in those dyads in which the difference on 'att' is positive.

Yes, that’s right. I checked again and found that there is a perfect separation. Nevertheless, in the ergm results, only 'negonly' seems to be statistically significant (see the results in the original article), so I ask a question. https://cran.r-project.org/web/packages/ergm/ergm.pdf According to the link above ('diff-ergmTerm'), seeing that it says: ["posonly": positive differences are kept, negative differences are replaced by 0] , I thought that only 'posonly' should be statistically significant.

mbojan commented 1 year ago

The estimates, and the SEs are meaningless in this case because the MPLE does not exist.