'how to resolve the ergm degeneracy?
this is a question for your help. i use the ergm to model the formation of network.but it is always degeneracy.there are just 174 nodes(vertices), 304 deges. i use the code as follow
my.ergm.3 <- formula(gg04.1 ~ edges+nodecov("width")+
nodecov("depth")+nodecov("numbers")+gwesp(0.2,fixed=T)+gwdegree(2,fixed=T))
gg03.ergm.fit <- ergm(my.ergm.3,control = control.ergm(MCMLE.maxit = 20,
parallel =2,
parallel.type = "PSOCK",
MCMC.interval = 10000,
MCMC.burnin =10000,
MCMC.samplesize = 10000,
MCMLE.density.guard =5000)
,verbose=3)
the question is from the parameter -----gwesp(0.2,fixed=T) and gwdegree(2,fixed=T)),the speed is very low.and the error as follows: Estimating equations are not within tolerance region. Error in ergm.MCMLE(init, nw, model, initialfit = (initialfit <- NULL), : MCMLE estimation stuck. There may be excessive correlation between model terms, suggesting a poor model for the observed data. If target.stats are specified, try increasing SAN parameters.
i want to know if the code haves mistakes or i should how to correct the mistake. thank you very much
Solution 1:[1]
The code in and of itself looks good and does not seem to have any mistakes as far as I can tell. It is hard however, to give a definitive answer on this, since your example is not reproducable. I think the issue is rather in the data
The GWESP is similar to a triangles parameter (the number of closed triangles in a model, with the distinction that the GWESP is less susceptible to model degeneracy. If one of your parameters in the estimation does a similar thing to the GWESP (e.g. a homophily term), then there can be a high correlation between the parameters. In the error term, it then says you have a "poor model specification" since two terms in the estimation are highly correlated, making one of them redundant.
I would suggest revisiting the theoretical foundations to see if your model specification is reasonable.
Solution 2:[2]
try sorted:
def sort_by_second(arr):
return sorted(arr, key=lambda x: (-1*x[1],x[0]),reverse=False)
arr = [('apple', 5), ('tv', 500), ('bee', 1000), ('cat', 500)]
print(list(map(lambda x:x[0],sort_by_second(arr))))
output:
[bee', 'cat', 'tv', 'apple']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DharmanBot |
| Solution 2 |
