statnet / ergm

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

predict.ergm() should fail nicely for non-binary ERGMs #528

Closed mbojan closed 1 year ago

mbojan commented 1 year ago

predict.ergm() capability is at this moment limited to binary ERGMs. For other specifications it won't work, e.g.:

library(ergm)
library(ergm.count)
data("zach")
zach.fit1 <- ergm(
  zach ~ nonzero + sum + nodefactor("role",base=2) + absdiffcat("faction.id"),
  response="contexts", 
  reference=~Binomial(8)
  )
predict(zach.fit1)
## Error: ERGM term ‘nonzero’ function ‘InitErgmTerm.nonzero’ not found.

Fix it by failing nicely after checking if ERGM is binary.

mbojan commented 1 year ago

Thanks @krivit , you beat me to it :))