statnet / tergm

Fit, Simulate and Diagnose Models for Network Evolution Based on Exponential-Family Random Graph Models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error using offset terms in Form() and Persist() with new version of tergm?

JeffreyAlanSmith opened this issue · comments

Hi folks, I have a quick question about specifying offset terms as part of the Form or Persist equations within tergm. Previously this was possible using the offset() function, but that leads to errors with the newest version of the package. Take the example below:

library(tergm)
data(samplk)
samp <- list(samplk1, samplk2, samplk3)
tergm.fit <- tergm(samp ~ Form(~ edges + offset(nodematch("group"))) +
                          Persist(~ edges + offset(nodematch("group"))),
                          offset.coef = c(1, 1), estimate = "CMLE", times=0:2)

Error in ergm_Init_abort():
! In term ‘N’ in package ‘ergm.multi’ (called from term ‘Form’ in package ‘tergm’): The ERGM ‘formula=’ argument of an ‘N()’ operator may not have offsets. See ‘ergmTerm?N’ section on fixing parameters for details.
Run rlang::last_trace() to see where the error occurred.

I am not sure if this is a bug or by design but how would I specify a formula with offset terms in the current version of the package? I didn't see any examples in the help files, but maybe I missed them?

Much appreciated,

Jeffrey

@JeffreyAlanSmith thanks for that inquiry. For that scenario I think you'd need to use the offset= argument to Form() and Persist(), but I'll pass the baton to @krivit to corroborate if it is the case and how to do it exactly.

I am not sure if this is a bug or by design but how would I specify a formula with offset terms in the current version of the package? I didn't see any examples in the help files, but maybe I missed them?

Please see the section in ergmTerm?N documentation on specifying offsets and fixing parameters. It also applies to operators that use it, such as Form() and Persist().

Thanks Michal (@mbojan) and Pavel (@krivit). I'll see if I can find a simple way to specify this.