Closed simonpcouch closed 3 years ago
Thanks for the report!
I'm still able to pull these elements from the fit object:
library(ergm)
data(faux.mesa.high)
fit <- ergm(faux.mesa.high ~ edges + degree(1:3))
...
> fit$control$MCMC.interval
[1] 256
> fit$control$MCMC.burnin
[1] 8192
> fit$control$MCMC.samplesize
[1] 1506
Can you send a reprex that fails?
@krivit, is it worth creating an accessor for the control
component?
Thank you for the quick reply! A quick reprex:
library(broom)
library(ergm)
#> Loading required package: network
#>
#> 'network' 1.17.0 (2021-06-06), part of the Statnet Project
#> * 'news(package="network")' for changes since last version
#> * 'citation("network")' for citation information
#> * 'https://statnet.org' for help, support, and other information
#>
#> 'ergm' 4.0.0 (2021-06-14), part of the Statnet Project
#> * 'news(package="ergm")' for changes since last version
#> * 'citation("ergm")' for citation information
#> * 'https://statnet.org' for help, support, and other information
#> 'ergm' 4 is a major release that introduces a fair number of
#> backwards-incompatible changes. Please type 'news(package="ergm")' for
#> a list of major changes.
data(florentine)
x <- ergm(flomarriage ~ edges + absdiff("wealth"))
#> Starting maximum pseudolikelihood estimation (MPLE):
#> Evaluating the predictor and response matrix.
#> Maximizing the pseudolikelihood.
#> Finished MPLE.
#> Stopping at the initial estimate.
#> Evaluating log-likelihood at the estimate.
x$control$MCMC.interval
#> NULL
x$control$MCMC.burnin
#> NULL
x$control$MCMC.samplesize
#> NULL
packageVersion("ergm")
#> [1] '4.0.0'
Created on 2021-06-16 by the reprex package (v2.0.0)
Lol. That's because that model doesn't use MCMC. And it doesn't because it has only dyad.independent
terms (in this case, just a function of nodal attributes).
You'll need to condition on that, tho I'm surprised if this worked before. Here's what to condition on (assuming the reprex above is still in your session:
x$MPLE_is_MLE
[1] TRUE
> y <- ergm(flomarriage ~ edges + degree(0:2))
Starting maximum pseudolikelihood estimation (MPLE):
Evaluating the predictor and response matrix.
Maximizing the pseudolikelihood.
Finished MPLE.
Starting Monte Carlo maximum likelihood estimation (MCMLE):
Iteration 1 of at most 60:
Optimizing with step length 1.0000.
The log-likelihood improved by 0.3147.
Estimating equations are not within tolerance region.
Iteration 2 of at most 60:
Optimizing with step length 1.0000.
The log-likelihood improved by 0.0244.
Convergence test p-value: 0.0014. Converged with 99% confidence.
Finished MCMLE.
Evaluating log-likelihood at the estimate. Fitting the dyad-independent submodel...
Bridging between the dyad-independent submodel and the full model...
Setting up bridge sampling...
Using 16 bridges: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 .
Bridging finished.
This model was fit using MCMC. To examine model diagnostics and check for
degeneracy, use the mcmc.diagnostics() function.
> y$MPLE_is_MLE
[1] FALSE
if x$MPLE_is_MLE == TRUE
then there's no MCMC info, b/c the fit used the MPLE algorithm instead.
Ah, thank you so much for the helpful details! Will adjust the tidiers' logic accordingly.
And thanks for building a tidier for ergm
:)
Hey there,
We're seeing a breakage in
broom
related to the newest version ofergm
. I just wanted to confirm that our fix correctly adjusts to the new model object structure! Here's the old code for extracting MCMC related info:https://github.com/tidymodels/broom/blob/9260363a4a771e0949e8d5af7d36c1cecf4ffc56/R/ergm-tidiers.R#L155-L157
Where are these parameters now stored in the outputted model object?
Much appreciated!