matthewjdenny / GERGM

An R package to estimate Generalized Exponential Random Graph Models
38 stars 10 forks source link

Errors when Metropolis accept rate = 0 #4

Closed jacob-long closed 6 years ago

jacob-long commented 6 years ago

If any iteration fails to accept any Metropolis proposals, the Geweke statistic can't be calculated. Well, it is calculated to be NaN, which results in this error:

Error in if (abs(geweke_stat) > 1.7) { : missing value where TRUE/FALSE needed

It's probably right to have an error in these cases --- I'm not sure --- but it would probably be best to catch these errors either at the point that the acceptance rate is calculated at 0 or when the Geweke statistic is calculated. If you think it shouldn't error, I suppose it would be a matter of making a bit more complicated conditional, e.g.,

if (is.finite(geweke_stat) && abs(geweke_stat) > 1.7) {
# whatever happens here
}
matthewjdenny commented 6 years ago

Hi Jacob,

Thanks for noting this! The new version of the pacakge (which should be on CRAN in a few days deals with this error in a cleaner way by trying the adjust the proposal variance and resimulate.

Best, Matt

matthewjdenny commented 6 years ago

GERGM 0.13.0 now gives a cleaner error message for this behavior. Let me know if you hit any more issues and thanks again for bringing this up!