我正在使用ergm
包R
来探索网络数据的指数随机图模型。这是网络:
gn
Network attributes:
vertices = 678
directed = TRUE
hyper = FALSE
loops = FALSE
multiple = FALSE
bipartite = FALSE
total edges= 1663
missing edges= 0
non-missing edges= 1663
Vertex attribute names:
indegree membership num_tweets vertex.names
Edge attribute names not shown
edges
在拟合更简单的模型后,一个带有and的术语,mutual
一个带有edges
, mutual
, and的模型nodefactor("membership", base = 4)
(其中membership
是一个具有四个级别的因子),我拟合了一个nodematch("membership", diff = T)
添加的模型,如下所示:
model1 <- ergm(gn ~ edges +
mutual +
nodefactor("membership", base = 4) +
nodematch("membership", diff = T)
)
虽然以前的模型融合了,但这个模型导致了这样的信息:
MCMLE estimation did not converge after 20 iterations. The estimated coefficients may not be accurate. Estimation may be resumed by passing the coefficients as initial values; see 'init' under ?control.ergm for details.
按照指示,我看了看?control.ergm
:Passing control.ergm(init=coef(prev.fit)) can be used to “resume” an uncoverged ergm run, but see enformulate.curved.
好的,这听起来不错,我搜索了如何使用,并从这个页面control.ergm
中找到了一个示例,我通过作为参数传递来测试它是否有效,它将从 20 增加到 50。然后我做了以下事情:control = control.ergm(MCMLE.maxit = 50)
number of times the parameters for the MCMC should be updated by maximizing the MCMC likelihood
model1a <- ergm(gn ~ edges +
mutual +
nodefactor("membership", base = 4) +
nodematch("membership", diff = T),
control = control.ergm(init=coef(prev.fit))
)
但是,返回此消息:Error in coef(prev.fit) : object 'prev.fit' not found
。
我还尝试传递模型对象(即model1a
)而不是prev.fit
,但这导致了这个不太高效的错误:
Error in if (drop) { : argument is not interpretable as logical
In addition: Warning message:
In if (drop) { :
the condition has length > 1 and only the first element will be used
那么,我如何通过传递control.ergm(init = coef(prev.fit))
或通过不同的方法“恢复”未收敛的模型?