statnet / ergm

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

After dropping extreme values, MPLE and MLE likelihoods report different numbers of observations. #574

Open krivit opened 4 months ago

krivit commented 4 months ago
suppressPackageStartupMessages(library(ergm))
data(sampson)

samplike.m <- as.matrix(samplike, matrix.type="adjacency")
samplike.m[4:10,4:10] <- 0

mple <- ergm(samplike~edges+edgecov(samplike.m))
#> Observed statistic(s) edgecov.samplike.m are at their greatest attainable values. Their coefficients will be fixed at +Inf.
mcmc <- ergm(samplike~edges+edgecov(samplike.m), control=control.ergm(force.main=TRUE, MCMLE.maxit=10))
#> Observed statistic(s) edgecov.samplike.m are at their greatest attainable values. Their coefficients will be fixed at +Inf.
waldo::compare(logLik(mple), logLik(mcmc), tolerance = 0.01)
#> `attr(old, 'nobs')`: 237
#> `attr(new, 'nobs')`: 306
#> 
#> `attr(old, 'br')` is absent
#> `attr(new, 'br')` is a list

Created on 2024-07-23 with reprex v2.1.1

NB: Here, the br attribute being different is as intended. The problem is with nobs.