statnet / lolog

Latent Order Logistic (LOLOG) Graph Models
Other
5 stars 1 forks source link

constraints/offset not working as expected #5

Closed tylerandrewscott closed 3 years ago

tylerandrewscott commented 3 years ago

Hello, I can't seem to get the constraint/offset functionality mentioned in the package writeup to work at all. Using example code from the manual produces the following error -- perhaps I am missing something?

library(lolog) data(ukFaculty) net <- as.BinaryNet(ukFaculty) lolog(net ~ edges + constraint(boundedDegree(0L, 10L))) Initializing Using Variational Fit Error in model$addOffset(names(offsets)[i], offsets[[i]]) : Unknown offset: boundedDegree

ifellows commented 3 years ago

boundedDegree is currently only implemented for undirected networks. This is listed on page 9 of https://github.com/statnet/lolog/blob/master/inst/doc/lolog-introduction.pdf . I am open to extending functionality as needed for specific analyses or use cases.

tylerandrewscott commented 3 years ago

Ah, so I was missing something obvious, my apologies, and thank you. If you'll permit me a related (possibly also obvious) question, I'm likewise having trouble with the offset() option, which doesn't seem to behave as I would expect based upon how offset() calls work in the ergm package. Is there an example somewhere of using offset() in a lolog call?

ifellows commented 3 years ago

ergm and lolog are different creatures. An offset is just a statistic where the parameter is set to 1. Internally, constraints are implemented as a type of offset that sets the likelihood to ~0 when the constraint is not met and doesn't alter the likelihood otherwise. I don't have any exported offset terms, but their use would be something like:

net ~ ... + offset(offsetTermName())

tylerandrewscott commented 3 years ago

Perfect, thank you, I was trying to set the offset coefficient to -Inf and that was not working obviously. Thanks again for your help, and for developing a great package!