I am using the ergm
package in R
to explore exponential random graph models for network data. Here's the network:
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
After fitting simpler models, one with a term for edges
and mutual
and one with edges
, mutual
, and nodefactor("membership", base = 4)
(where membership
is a factor with four levels), I fit a model with nodematch("membership", diff = T)
added, as follows:
model1 <- ergm(gn ~ edges +
mutual +
nodefactor("membership", base = 4) +
nodematch("membership", diff = T)
)
While the previous models converged, this model led to this message:
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.
As instructed, I took a look at ?control.ergm
: Passing control.ergm(init=coef(prev.fit)) can be used to “resume” an uncoverged ergm run, but see enformulate.curved.
OK, this sounds good, I searched for how control.ergm
is used, and found an example from this page, and I tested that this worked by passing control = control.ergm(MCMLE.maxit = 50)
as an argument, which increased the number of times the parameters for the MCMC should be updated by maximizing the MCMC likelihood
from 20 to 50. I then did the following:
model1a <- ergm(gn ~ edges +
mutual +
nodefactor("membership", base = 4) +
nodematch("membership", diff = T),
control = control.ergm(init=coef(prev.fit))
)
But, this message is returned: Error in coef(prev.fit) : object 'prev.fit' not found
.
I also tried to pass the model object (i.e., model1a
) instead of prev.fit
, but that led to this not-too-productive error:
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
So, how can I "resume" an unconverged model by passing control.ergm(init = coef(prev.fit))
- or via a different approach?