statnet / ergm

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

`ergm_preprocess_response` removes response character string from the environment #463

Closed phuang5 closed 2 years ago

phuang5 commented 2 years ago

Hello again Pavel,

The ergm_preprocess_response function takes a character string argument specifying the response of the network to identify which edge covariate to be processed. However, after running this function, the character string gets removed from the environment. Sometimes this won't be an issue because the information about response gets integrated into the network after preprocessing. But it can create issues when this character string indicating the network response needs to be reused later, which can happen when we later call other ergm functions that asks for response string as argument (ergm_model, summary_formula, ergm, ergm_godfather etc.). Here is a toy example demonstrating this issue.

library(network);library(ergm.count)
#configure graph from adjancency matrix
mat <- matrix(nrow = 3, ncol = 3, 0)
mat[1,2] <- 2
mat[2,1] <- 3
mat
net <- network(mat, names.eval = "e", ignore.eval=F)
as.sociomatrix(net, attrname = "e")

#response
response="e"
ergm_preprocess_response(net, response = response)
response #response character was removed

This is a followup of issue #459

Thanks!

krivit commented 2 years ago

This is the intended, documented behaviour. Please see ? ergm_preprocess_response.