statnet / ergm

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

Using an offset together with the Godambe information for the MPLE does not work #561

Closed corneliusfritz closed 5 months ago

corneliusfritz commented 5 months ago

Using an offset in an ergm specification while wanting to use the Godambe information for the MPLE does currently not work. Here is a small sample script to showcase it:

data(molecule)
gest <- ergm(molecule ~ offset(edges)+ triangle ,
             offset.coef = -1, estimate = "MPLE", 
             control = control.ergm(MPLE.covariance.method = "Godambe"))

The reason must lie in the ergm_mplecov function, where the offset term is included in the net.stat matrix (which are the statistics of the simulated network), but not in the matrix of change statistics (pl$xmat). The code wants to equate the column names, which then leads to the aforementioned error. The easiest fix might be to exclude the offset term from the statistics, as the uncertainty quantification does not relate to it. I, however, do not know if this leads to downstream problems ...

mbojan commented 5 months ago

Thanks @corneliusfritz for reporting. Looks like a bug.

mbojan commented 5 months ago

I think these...

https://github.com/statnet/ergm/blob/90020d23ecdb32ecff0c8a18b5c83ea04fd02339/R/ergm_mplecov.R#L86-L87

... two lines, of which the second throws the error, are completely unnecessary because the net.stat object is never used in this function.

krivit commented 5 months ago

Thanks, @mbojan!