statnet / ergm

Fit, Simulate and Diagnose Exponential-Family Models for Networks
Other
94 stars 36 forks source link

Valued ERGMs not running properly - bridge sampling error + Metropolis Hastings error #483

Closed PernilleBrams closed 1 year ago

PernilleBrams commented 1 year ago

I am currently working with a directed network, wanting to run a valued ERGM with weighted edges representing the frequency of connections made between the vertices. While a unvalued ERGM runs perfectly with all sorts of different terms modelling the network and closure, running any valued ERGM yields this bridge sampling error after having reached convergence:

Model syntax and excerpt of output:

 m <- ergm(network ~ sum, response = "weight", reference = ~Binomial(3))
      Starting contrastive divergence estimation via CD-MCMLE:
      ...
      Estimating equations are not within tolerance region.
      Iteration 6 of at most 60:
      Optimizing with step length 1.0000.
      The log-likelihood improved by 0.0177.
      Convergence test p-value: 0.0021. Converged with 99% confidence.
      Finished MCMLE.
      Evaluating log-likelihood at the estimate. Setting up bridge sampling...
      Using 16 bridges: 1 Error in UseMethod("ergm.estfun") : 
        no applicable method for 'ergm.estfun' applied to an object of class "NULL"

This happens regardless of reference distribution used and regardless of terms included in the model. I followed this tutorial and built up my dataset just like the monks-dataset - and I tried fitting the models both having the data in the form of a sociomatrix (adjacency matrix) and edgelist, so the error is quite weird. As mentioned the unvalued ERGMs fit fine using this dataset, but of course does not consider weights.

As can be seen MCMLE is finished, but the computation halts when setting up bridge sampling for the model. Looking into the function 'ergm.estfun' as the error prompts one to do, it seems that the problem may be with the 'target.stats' argument in specifying the model. Trying to add this argument and putting a number or a string to ensure the class is not NULL yields another error which is thrown immediately when running the model fitting:

 Error: Metropolis-Hastings proposal ‘DiscTNT’ function ‘InitErgmProposal.DiscTNT’ not found.

My session info shows that I am using ergm 4.2.2, which as far as I can tell online is the newest package out. I'll put my version of R and other session info that might be relevant here: R version 4.2.1 (2022-06-23) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Monterey 12.5.1

Any idea as to what may be causing the problem here?

krivit commented 1 year ago

I can't reproduce the problem. Can you please attach the network object?

krivit commented 1 year ago

Also, can you try installing the current GitHub version and seeing if it helps? You can download a nightly build from https://nightly.link/statnet/ergm/workflows/R-CMD-check.yaml/master/Windows-rrelease-binaries.zip ?

krivit commented 1 year ago

It doesn't look like there was any further communication from the reporter. If the issue persists, please reopen with an update.