statnet / ergm.tapered

ergm.tapered: Tapered Exponential-Family Models for Networks
https://github.com/statnet/ergm.tapered
3 stars 0 forks source link

Unconstrained MCMC sampling did not mix at all. #1

Closed cbccbcc closed 3 months ago

cbccbcc commented 1 year ago

My code is gw1_help <- ergm.tapered(supnet ~ edges + nodefactor("work") + nodefactor("income") + nodefactor("edu") + nodefactor("religious") + nodefactor("gender") + nodecov("age") + edgecov(sup_loca2_net,"distance") + edgecov(kin_sup,"kinweight") + gwidegree(.1, T) + gwesp(.1, T) + gwdsp(.1, T), control = control.ergm.tapered(MCMC.samplesize = 1e+5, MCMC.burnin = 1e+6, MCMC.interval = 1000, seed = 567), eval.loglik = T, verbose = T) and I also tried the ergm model. Both models couldn't work out, and the ergm.tapered model gives this feedback:

"Error in ergm.MCMLE(init, nw, model, initialfit = (initialfit <- NULL), : Unconstrained MCMC sampling did not mix at all. Optimization cannot continue. Traceback:

  1. ergm.tapered(supnet ~ edges + nodefactor("work") + nodefactor("income") + . nodefactor("edu") + nodefactor("religious") + nodefactor("gender") + . nodecov("age") + edgecov(sup_loca2_net, "distance") + edgecov(kin_sup, . "kinweight") + gwidegree(0.1, T) + gwesp(0.1, T) + gwdsp(0.1, . T), control = control.ergm.tapered(MCMC.samplesize = 1e+05, . MCMC.burnin = 1e+06, MCMC.interval = 1000, seed = 567), eval.loglik = T, . verbose = T)
  2. ergm(newformula, control = control, response = response, constraints = constraints, . reference = reference, eval.loglik = eval.loglik, verbose = verbose, . ...)
  3. ergm.MCMLE(init, nw, model, initialfit = (initialfit <- NULL), . control = control, proposal = proposal, proposal.obs = proposal.obs, . verbose = verbose, ...)
  4. stop("Unconstrained MCMC sampling did not mix at all. Optimization cannot continue.")"

So I was wondering if this is a problem of my data & code, or it's a bug that could be fixed! Thank you!

cbccbcc commented 1 year ago

can someone help me? :::::(

krivit commented 1 year ago

This looks like an ergm.tapered issue, so transferring here.

Other than that, @cbccbcc, please be patient: package developers are very busy. Also, your example doesn't give us much to go on. If you want to maximise your chances of a fast response (or any response at all), please include a minimal reproducible example. I suggest making use of the following:

cbccbcc commented 1 year ago

Thank you! Sorry to bother you so frequently! I am an undergraduate student who just started using R so I know little about "reprex", so thank you so much for your reminder and advice! As for your answer, I started with ergm model but it reported "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 parameter." So Professor Hankcock advised me to use ergm.tapered. I am not that clear that which model you think would work? Thank you so much and again I am so sorry for any inconvenience!

cbccbcc commented 1 year ago

So sorry to bother but is there any feedback :( My model still cannot work for a whole week :((

cbccbcc commented 1 year ago

is there any solution plz :((((( @krivit @handcock

cbccbcc commented 1 year ago

I use the M2 core MBP to run my code which had little progress. It used the "bridges" and it seemed to have an outcome. But in the last sentence, it said

Warning: STATS is longer than the extent of 'dim(x)[MARGIN]'Error in array(STATS, dims[perm]) : 'dims' cannot be of length 0.

So I wonder if it's a problem with the package? I also uploaded the screenshot of the console, I was using the same code which I put in the replication materials :) WechatIMG1368

Thank you so much for the developers to look into my problem! 👍

cbccbcc commented 1 year ago

Also, I ran the same code several times, and different issues and errors came out, such as NA issues, so I don't know which problem is truly essential or correct.

handcock commented 1 year ago

This appears to be an installation error. I suggest manually deleting ergm and ergm.tapered and then reinstall via github:

devtools::install_github("statnet/ergm.tapered")

As for the model: Carter suggests using log(distance), which I agree with. Also here is a model that appears to work:

gw1_help <- ergm.tapered(supnet ~ edges + nodefactor("work") + nodefactor("income") + nodefactor("edu") + nodefactor("religious") + nodecov("age") + edgecov(sup_loca2_net,"ldistance") + edgecov(kin_sup,"kinweight") + nodemix("gender") + absdiff("age") + nodematch("work") + nodematch("edu") + nodematch("religious") + gwidegree(0.2, fixed=TRUE) + gwodegree(0.2, fixed=TRUE)+triangle, r=1, fixed=T)

Note that I have used a triangle term over the gwesp() term, but both would likely work. The overriding issue is that the model is very close to degenerate and likely misspecified. This network has complex structure not captured by these terms. It needs more and alternative terms. The tapering helps, but is quite strong in this case. So although the fit and MCMC diagnostics look good, I would interpret the substantive fit forced.

cbccbcc commented 1 year ago

It worked! Thank you so much!!! ps. My data and code can only work on MBP with M2 core....