Skip to content

Transparently augment statistics tests using ergm.godfather(). #605

@krivit

Description

@krivit

summary(nw ~ stat) only tests the change statistics when adding edges. Most of the term tests augment this by running ergm(..., estimate = MPLE), but this has the disadvantage of assuming that the reference MPLE value is correct, and since there aren't other implementations we can use to verify it, we have to trust that what we have now is correct.

ergm.godfather() can apply any set of changes and return the difference, and so it can be used for more general tests, but that requires additional coding.

The idea is to replace the summary(nw~stat) with, e.g., gf_summary(nw ~ stat), which does the following:

gf_summary <- function(f){
  summ <- summary(f)
  el <- as.edgelist(ergm.getnetwork(f))
  el2 <- el[sample(rep(seq_len(nrow(el)), 2L)),]
  summ2 <- ergm.godfather(f, changes = el2)

  expect_equal(summ2, summ)
  summ
}

What el2 does is toggle each edge in nw twice, thus returning it to its original state, and it will do so in a random order, which means that if there are some inappropriate interactions, it will hopefully detect them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions