1

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?

Joshua Rosenberg
  • 4,014
  • 9
  • 34
  • 73
  • 1
    You are right--you need to pass an ergm object (or vector of coefficients) to the `init` argument--the `prev.fit` term is a placeholder for that (poorly presented in documentation). I cannot reproduce your error. Check to see if you are passing an ergm object (`class(model1)`) or try assigning the coefficients to a vector (`coefs <- coef(model1)`) and pass that to the `init` argument. Also--there are other (better) ways to get convergence using burn-in, thinning, and sample size. – paqmo Nov 27 '16 at 19:12
  • Thanks, `class(model3)` returns `[1] "ergm"`, but assigning the coefficients to a vector and then passing that to `init` worked! I'd like to check out those other ways (burn-in, thinning, & sample size). if you could point me in the right direction (even more than you already have, thanks again), I would be appreciative – Joshua Rosenberg Nov 27 '16 at 23:15
  • 1
    Default values for thinning interval and sample size are 1024 and for burn-in is 16384. I like to set my burn-in at 100000 and other values at 10000, so `control=control.ergm(MCMC.burnin=100000, MCMC.samplesize=10000, MCMC.interval=10000`. This does dramatically increase computational time, so start small and work your way up. That said, a poorly specified model will have convergence problems as well. For example, if the reciprocity isn't that high, asymmetric may be a better term. – paqmo Nov 28 '16 at 01:50

0 Answers0